Left here for archival purposes.

User avatar
By apache
#22346 Hi,

I'm trying to connect multiple DS18B20 sensors to ESP8266.

My test code is something like this:
Code: Select allrequire("ds18b20")
ds18b20.setup(1)
addrs = ds18b20.addrs()

if (addrs ~= nil) then
  print("Total DS18B20 sensors: "..table.getn(addrs))
end
-- Don't forget to release it after use
t1=ds18b20.read()
print(string.format("temperature: %.1f °C", t1))
ds18b20 = nil
package.loaded["ds18b20"]=nil


I'm getting something like that:
Code: Select allTotal DS18B20 sensors: 0
temperature: 28.6 °C


I think that something is not right with ow.search() function. In my case it says that I have no sensors connected but it get temperature from the sensor...
User avatar
By Gareth.d
#24153 I have been trying to get 4 temp sensors to work and like you it would report 0 sensors connected and only give temp from the same sensor every time.
I finally changed the resistor from 4.7 k to 27 k and now all sensors work and it reports 4 sensors connected.
I only changed the resistor after first trying with no resistor connected and found it reported the right number of sensors and temps correctly but didn't work reliable, so tried various values and found 27 k to work reliably.
This works for me not saying its for everyone but worth a try.
User avatar
By picstart
#29343 The one wire protocol requires that any connected device be able to pull the line down to ground. The more devices and the greater the pull up potential and the less likely any device can get things to ground. That's why a weaker 27k pull up works better than 4.7k for multiple devices.