HydraFerret ds1820 support

Enfield Cat's Blog: Arduino and other projects.


Introduction

the Dallas ds1820 family temperature sensors use a OneWire bus to connect to the processor. Each sensor has a unique ID and multiple sensors can be connected to the bus. HydraFerret allows for up to 4 OneWire busses each with multiple sensors.

The OneWire protocol allows for sensors to operate using "parasitic power" where the sensors connect using just the earth and signal wires. The positive power is drawn from the signal wire. However, the current release of HydraFerret does not support the use of parasitic power. In order to avoid signal "reflection" a resistor is placed between the positive power supply and the signal. This resistor drains any voltages remaining on the signal wire due to capacitance. The longer the cable run and the more sensors attached the higher the line capacitance may be. For 5v systems the recommended value is 4k7. But this value should be reduced for lower power and longer cable runs. On 3.3v systems such as ESP32, a 3k3 or 3k9 resistor may give a cleaner signal.

Configuration

First configure the OneWire bus to use. Specify the bus number (between 0 and 3), followed by either disable or the I/O pin number. Reboot after configuring the bus to make it effective.

onewire <bus-number> [disable|<pin>]

Now scan the bus(es) for devices using:

onewire

This should discover OneWire devices. You can add up to 5 new sensors between reboots of the system. This allows multiple sensors to be identified correctly by adding them one at a time. The onewire command will also return an index number for each sensor. This can be used with the devicename command to name individual senors. Once the sensors have been named, successive onewire scans will show the device name, eg:

conservatory> onewire
OneWire temperature sensors:
 * ID: 03, UID 28ec6a79a2000386, Name: ds-alpha, Type: DS18B20/MAX31820
 * ID: 04, UID 287aab79a200036a, Name: ds-bravo, Type: DS18B20/MAX31820
 * ID: 05, UID 2815c279a200036f, Name: ds-charlie, Type: DS18B20/MAX31820

Note the leading zero of the ID number can be left off when defining a name, warning or critical range for these devices. eg:

onewire 1 14
restart
onewire
devicename ds1820 4 ds-bravo
warning ds1820 4 temp 30 >
interval ds1820 1

troubleshooting

Dropping readings may be caused by poor electrical connections, too long cable runs, too many devices and too high a value pull up resistor on the data line. This may cause echoes on the data line resulting in missed packets. The example graph below shows sesnors on a bus where there is a one second interval between readings. Therefore the should be 300 readings per sensor, so some readings are being dropped. Natably for the sensor labeled ds-alpha. Things to look for include:

graph showing missing readings on some sensors


Thank you for visiting camelthorn.cloudHome