-->
Page 1 of 2

ds18b20 and ow.search(pin) bug

PostPosted: Fri Jul 03, 2015 9:21 am
by apache
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...

Re: ds18b20 and ow.search(pin) bug

PostPosted: Fri Jul 24, 2015 7:04 am
by Gareth.d
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.

Re: ds18b20 and ow.search(pin) bug

PostPosted: Fri Sep 18, 2015 1:16 am
by kniazio
Could you share the entire code lua for multiple sensors?

Re: ds18b20 and ow.search(pin) bug

PostPosted: Fri Sep 18, 2015 7:40 am
by picstart
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.