Multiple DS18B20 sensor issue

2,010 views
Skip to first unread message

Mike Ramsay

unread,
Feb 18, 2017, 11:23:14 AM2/18/17
to SonoffUsers
For some reason I am unable to get multiple DS18B20 sensors on a single data line to function as I thought I could (using Sonoff SV, version 3.9.17, GPIO14).  Single sensors work as expected.  I am unsure if I need to change some compile time confiq options  - I don't see anything on the web interface that helps. 

Thanks Mike.
Message has been deleted

DavidVT

unread,
Feb 18, 2017, 1:20:56 PM2/18/17
to SonoffUsers
Trying to do the same on a Sonoff 4ch. Only single sensors work at the moment on this software.
Multiple sensors on one GPIO worked on EasyEsp pretty well so I suspect there is a path to make it work on Tasmota.
I saw mention of another library but un-commenting that did not result in any improvement thus far.
I will get this working and will share how.  If you beat me to it, I will be watching.. :)

I prefer to try this software so I can compare both directions.
I intend to roll this out as an add-hoc solution for 8 locations once I decide on a software path.
The image is of my first mod to allow connection of my pre-existing one-wire network cable.  The needed one-wire resistor is on the jack, just inside the case. I just left a tail on the two wires (data and Vcc) so to solder the resistor in place.  Plenty of room in the Sonoff 4ch din mountable box to do these kinds of mods!



Mike Ramsay

unread,
Feb 18, 2017, 2:15:05 PM2/18/17
to SonoffUsers
The error returned in the console is:   DSB: Sensor CRC error.  This code is contained ONLY in xsns_d18b20.ino so it seems likely that we need to use xsns_d18x0.ino - which makes sense. I think you have ready tried this so I am not sure what it means.  I have become a little confused with the use of a 'one file' approach with configuration done in the web interface.    I will see if I can get the multi-sensor version included with a new upload.
 



DavidVT

unread,
Feb 18, 2017, 3:03:34 PM2/18/17
to SonoffUsers
My digging and a related question:

IN "user_config.h":
#define USE_DS18x20                              // Optional using OneWire library for multiple DS18B20 and/or DS18S20

IN "sonoff":
#ifndef USE_DS18x20
#define USE_DS18B20                         // Default DS18B20 sensor needs no external library
#endif

Very weak in this environment, but does this not force the code to use "xsns_DS18B20" regardless of what is set in user_config.h?

DavidVT

unread,
Feb 18, 2017, 3:28:12 PM2/18/17
to SonoffUsers

Mike,
I am having some limited success.
IN 'sonoff':
I changed the code below and used that uncomment in 'user_config.h':

#ifndef USE_DS18x20
#define USE_DS18B20                         // Default DS18B20 sensor needs no external library
#endif

TO:

#ifndef USE_DS18x20
#undef USE_DS18B20                         // force not loading default library
#endif

When I tried to use my entire network of sensors it failed.  However when I used one to three sensors, I had success.   
Might be my wiring but it did work before on EasyEsp and on Windows with the onewire usb dongle...
I will see what the MQTT looks like with these three working for now...
Result on web page showing three sensors:


DavidVT

unread,
Feb 18, 2017, 3:46:48 PM2/18/17
to SonoffUsers
Final note for now on this:

I see the address of the third sensor is being truncated and the message is chopped off.   I see this in the web console and in the MQTT client on my iPhone.
Not sure if this is relevant to why I can not add more sensors?  Clearly the three sensor temperature data is making it to both the web console and the MQTT server.

Off to other things on this sunny winter day, good luck..

David 

Mike Ramsay

unread,
Feb 26, 2017, 2:41:15 PM2/26/17
to SonoffUsers
Issue was traced to MESSZ (line 125 in sonoff.ino).  It is set a 240 which is not long enough for the MQTT message generated with multiple sensors.  It needs to be increased as appropriate.  Note that you may also want to increase MQTT_MAX_PACKET_SIZE beyond the recommended 400.  Thanks to arendst to the speedy resolution.


simon horner

unread,
Apr 16, 2017, 5:54:08 AM4/16/17
to SonoffUsers
Mike, David, couple of questions...

Did you get this working for multiple sensors? I have a set of 6 which I'm currently reading through a home brew ESP8266 system which I want to replace with my sonoff 4CH.

Also looking at the schematics for the 4CH and the board itself, there is a location for a 2.5mm socket on the board which is shown as conecting to GPIO7 and GPIO8 for the connection of 2 temperature sensors. Although on the board I can see that there is provision for  a couple of (I assume) zero ohm surface mount resistors to make the connection near led #5. 

I've ordered some sockets and was planning to connect 6 DS18B20s via this route. Any thoughts on this as a viable way of connecting things up?

Simon

javier gonzalez

unread,
Apr 16, 2017, 7:13:37 PM4/16/17
to SonoffUsers
Hi,

I'm also looking to use two spare outputs to control a come of optoacouplers using GPIO7 & 8 but I've seen the following post:

It looks like they can't be used as they are used to connect the flash chip to the ESP8285.

Does anyone know if there are any other accesible output pins? (like GPIO1 & GPIO3 to be used after flashing)

Thanks, 

simon horner

unread,
Apr 17, 2017, 10:03:03 AM4/17/17
to SonoffUsers
Good point Javier. That would have made debugging interesting!

I wonder why they show those connections on the schematic and have put the traces in on the boards. Strange...

Simon

Ralf Buck

unread,
Jul 26, 2017, 1:37:19 PM7/26/17
to SonoffUsers
have also problems with a DS18B20

Tasmota 5.2.4

change 
#ifndef USE_DS18x20
#undef USE_DS18B20                         // force not loading default library
#endif
in the sonoff file
and uncomment
ds18b20 in the user file to 
#define USE_DS18x20

flash and change in the webgui to Sonoff 4CH and GPIO2 to DSx1820.

but i see no values. see only 4x toggle buttons in the main menu

Ralf Buck

unread,
Jul 27, 2017, 4:24:38 PM7/27/17
to SonoffUsers
Ist IT possible that Thema gpio2 Not Work in the Rev 2.0 of the sonoff2 4ch ?

Try now my second 4ch, anderes thus will also not work

Gabriele Galloppa

unread,
Apr 5, 2018, 1:44:33 PM4/5/18
to SonoffUsers
You solve this problem?

Thanks

Afonso Bonifacio

unread,
Apr 18, 2019, 6:02:38 PM4/18/19
to SonoffUsers
Hi

How do you connect the three DS18 sensors to the Sonoff?

Thanks

Ron L

unread,
Apr 18, 2019, 7:57:36 PM4/18/19
to SonoffUsers
Just connect the 3 black wires from the sensors together, all 3 red wires together and the other 3 wires (mine were yellow) together.  Then connect Red to +3.3v, Black to Gnd and Yellow to GPIO14.  Lastly and most important, put a resistor between the +3.3v and GPIO14 at or near the Sonoff device.  Value of resistor can be about anything between 4.7k and 10k ohms.  I have read that a star pattern (all 3 sensors terminated near the Sonoff device) is not ideal, but have not caused me any issues.  I also have run a main cable (old CAT5 cable) running from Sonoff device up into attic and then branch the sensors of that main cable.  Both ways work fine for me - just don't forget the resistor and don't forget to configure you device GPIO for the sensor type.

Philip Knowles

unread,
Apr 19, 2019, 1:42:14 AM4/19/19
to Afonso Bonifacio, SonoffUsers

I have 5 sensors on one TH16 using unshielded 3 core flex over 5m so it should work.
I have a 4k7 resistor close to the Sonoff. Two sensors close to the TH16 and the other 3 at the end of the 5m flex. I'm using the pre-compiled 'sensors' bin.
With multiple sensors you need to use a lower resistor (not higher). The sensors should 'daisy chain' not 'star'.
Add the additional sensors one at a time (with the power off) and find out which one is causing the problem. Often just reconnecting it may get it to work.

Regards

Phil K

--
You received this message because you are subscribed to the Google Groups "SonoffUsers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonoffusers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages