Page 1 of 1

Multiple Onewire bus connections

Posted: Thu Apr 16, 2020 5:48 am
by ajocius
I had working code for several DS18B20 sensors connected on one bus. However, once number of devices increased to 11 I started to get no readings from several sensors. Tried all sensors individually, all work fine, but once all 11 were connected, I got same issue. So I thought to try to split sensors into two groups and have two bus. Both would have connection to same 3,3V power supply from ESP32, same ground connection, but separate data connectors to separate ESP32 pins with 4,7K pull up resistors.
My code looks like this:

Code: Select all

t1 = machine.Pin(5)   # DS18B20 temp THsensor device is on GPIO5
ds1 = ds18x20.DS18X20(onewire.OneWire(t1))  # create the onewire object
t2 = machine.Pin(34)   # DS18B20 temp THsensor device is on GPIO34
ds2 = ds18x20.DS18X20(onewire.OneWire(t2))  # create the onewire object
code stops in line starting with "ds2"

Does that mean that only one one wire can be created?

Re: Multiple Onewire bus connections

Posted: Thu Apr 16, 2020 7:30 am
by kevinkk525
ajocius wrote:
Thu Apr 16, 2020 5:48 am
However, once number of devices increased to 11 I started to get no readings from several sensors.
Try pull-up with only ~1.3k

Re: Multiple Onewire bus connections

Posted: Thu Apr 16, 2020 9:27 am
by ajocius
Had 1,8K and 1,2K. Tried with 1,8K and it reads them all! Thank you. Would be great to understand the logic behind.

Also, would be great to understand if two Onewire objects can be running within the code.

One step closer to moving sensors to greenhouse, just in time :)

Re: Multiple Onewire bus connections

Posted: Thu Apr 16, 2020 4:41 pm
by tve
Another trick you can try is to put a 180Ohm resistor in series at the esp32 end: it reduces the slew rate causing less over/undershoot.

Re: Multiple Onewire bus connections

Posted: Thu Apr 16, 2020 4:47 pm
by tve
>t2 = machine.Pin(34)

gpio 34 is input-only