Multiple Onewire bus connections

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
ajocius
Posts: 83
Joined: Mon Feb 19, 2018 6:31 am

Multiple Onewire bus connections

Post by ajocius » Thu Apr 16, 2020 5:48 am

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?

kevinkk525
Posts: 969
Joined: Sat Feb 03, 2018 7:02 pm

Re: Multiple Onewire bus connections

Post by kevinkk525 » Thu Apr 16, 2020 7:30 am

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
Kevin Köck
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode

ajocius
Posts: 83
Joined: Mon Feb 19, 2018 6:31 am

Re: Multiple Onewire bus connections

Post by ajocius » Thu Apr 16, 2020 9:27 am

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 :)

User avatar
tve
Posts: 216
Joined: Wed Jan 01, 2020 10:12 pm
Location: Santa Barbara, CA
Contact:

Re: Multiple Onewire bus connections

Post by tve » Thu Apr 16, 2020 4:41 pm

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.

User avatar
tve
Posts: 216
Joined: Wed Jan 01, 2020 10:12 pm
Location: Santa Barbara, CA
Contact:

Re: Multiple Onewire bus connections

Post by tve » Thu Apr 16, 2020 4:47 pm

>t2 = machine.Pin(34)

gpio 34 is input-only

Post Reply