Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DS18B20 extended temperature sensors not working #1361

Closed
peteeee opened this issue Nov 22, 2018 · 14 comments
Closed

DS18B20 extended temperature sensors not working #1361

peteeee opened this issue Nov 22, 2018 · 14 comments

Comments

@peteeee
Copy link

peteeee commented Nov 22, 2018

Recently switched over from Tasmota to Espurna for my Sonoff WiFi basic switches and multiple DS18B20s.

I am impressed with the Espurna feature set and using less than 500k of memory.

Initial testing with Tasmota firmware had 3 DS18B20 sensors from about 3 meters out to around 10 meters. This has been working well now for a few months.

Initial testing was connecting 3 DS18B20's on the work bench with short wires. All three worked fine with ESPURNA 1.13.3.

Extending one of the sensors to around 10 meters took out all of the sensors where I cannot see any of the sensors.

Not sure why the three sensors (extended) worked with Tasmota firmware and no longer work now with ESPurna firmware.

Did a similiar test with one DHT22 sensor. Worked great near the Sonoff and it doesn't work at all extended to around 10 meters.

@Valcob
Copy link
Contributor

Valcob commented Nov 22, 2018

@peteeee could you please share the schematics of how you are connecting the sensors you ll need some pull ups as the cable is quite long also you can try using CAT5 Ethernet cable

@AlbertWeterings
Copy link
Contributor

I did extended testing with ds18b20 sensors on long cable, run into multiple issues. Most issues can be solved doing this.
Use twisted pair cable like cat5
Place all sensors on only 1 cable (don't wire a star)
Place the pullup resistance on the most remote sensor

@peteeee
Copy link
Author

peteeee commented Nov 25, 2018

Thank you gentlemen.

Here looking to shrink down 1-wire temperature sensors hub to a SonOff basic.

Initially tested here with an RPi / Node Red / OWFS / MQTT out set up. This current RPi is multitasking doing ZWave (serial to ethernet), SD Radio NOAA map downloads, Node Red, Mosquitto Broker, OWFS. Looking to off load 1-wire temperature sensors to SonOff basic with only 4 temperature sensors.

It worked fine with resistor at terminal end on SonOff basic (3.3VDC, GPIO14, Ground) star connected to 4 DS18B20 sensors connected via 22/4 alarm cable 1-3 meters in length using waterproof DS18B20 cables, raw DS18B20 chips, AAG 18B20 boards, Midon 18B20 boards and Hobby Boards 18B20 boards.

Here is a drawing of configuration and Tasmota console messages with 3 sensors connected all extended from Sonoff basic terminals in a star configuration. SonOff basic with Tasmota runs fine with 4 temperature sensors hooked up in a similar fashion (star) with all of the sensors extended via 22/4 alarm cable.

Using this configuration with Home Assistant. I like Espurna firmware flexibility versus Tasmota firmware.

image

Goal here is to use one SonOff basic in basement to cover outside, basement, main floor (2) and Sonoff basic in attic (of two story) to cover attic, second floor rooms.

Using / tested firmware Espurna V. 1.13.3 ITEAD SonOff basic Dallas and basic and TH

Debug only shows one sensor:

[246529] [MQTT] Sending SonOff-1Wire-2/data => {"temperature":69.8,"time":"2018-11-25 09:21:53","mac":"BC:DD:C2:0F:4E:8A","host":"ICS-SonOff2","ip":"192.168.244.222","id":80042} (PID 52)
[252530] [MQTT] Sending SonOff-1Wire-2/data => {"temperature":69.7,"time":"2018-11-25 09:21:59","mac":"BC:DD:C2:0F:4E:8A","host":"ICS-SonOff2","ip":"192.168.244.222","id":80043} (PID 53)
[258533] [MQTT] Sending SonOff-1Wire-2/data => {"temperature":69.7,"time":"2018-11-25 09:22:05","mac":"BC:DD:C2:0F:4E:8A","host":"ICS-SonOff2","ip":"192.168.244.222","id":80044} (PID 54)
[264543] [MQTT] Sending SonOff-1Wire-2/data => {"temperature":69.7,"time":"2018-11-25 09:22:11","mac":"BC:DD:C2:0F:4E:8A","host":"ICS-SonOff2","ip":"192.168.244.222","id":80045} (PID 55)
[270548] [MQTT] Sending SonOff-1Wire-2/data => {"temperature":69.7,"time":"2018-11-25 09:22:17","mac":"BC:DD:C2:0F:4E:8A","host":"ICS-SonOff2","ip":"192.168.244.222","id":80046} (PID 56)
[276558] [MQTT] Sending SonOff-1Wire-2/data => {"temperature":69.7,"time":"2018-11-25 09:22:23","mac":"BC:DD:C2:0F:4E:8A","host":"ICS-SonOff2","ip":"192.168.244.222","id":80047} (PID 57)
[282560] [MQTT] Sending SonOff-1Wire-2/data => {"temperature":69.7,"time":"2018-11-25 09:22:29","mac":"BC:DD:C2:0F:4E:8A","host":"ICS-SonOff2","ip":"192.168.244.222","id":80048} (PID 58)

In Tasmota configured this for multiple DS18X20 sensors connected to GPIO14 in user_config.h..

#define USE_DS18x20 // Optional using OneWire library for multiple DS18B20 and/or DS18S20 (+2k code)

@peteeee peteeee closed this as completed Nov 25, 2018
@peteeee peteeee reopened this Nov 25, 2018
@peteeee
Copy link
Author

peteeee commented Nov 26, 2018

Left it on all day with 1 short and 2 extended DS18B20's. Looking at it 3-4 hours later it now shows three sensors. Debug showing some errors relating to DHT sensor which doesn't make sense to me.

image

@Valcob
Copy link
Contributor

Valcob commented Nov 26, 2018

@peteeee All you need to do is to comment the line with #define DHT_SUPPORT 1 ;) and reprogram the device

@peteeee
Copy link
Author

peteeee commented Nov 27, 2018

Thank you Valcob.

Yes; went to 4 extended DS18B20 sensors and it is working now with one 4.7K ohm resistor except for the DHT debug errors.

I have wired the terminals on the SonOff basic WiFi for two GPIO pins. Can I redefine the firmware to use GPIO 14 for DS18B20's and GPIO XX for one DHT22 combo sensor?

@Valcob
Copy link
Contributor

Valcob commented Nov 27, 2018

@peteeee sure just find the line or add one to your configuration in hardware.h #define DHT_PIN 5 <- this one might be something else and then just reflash the device

@peteeee
Copy link
Author

peteeee commented Nov 27, 2018

Thank you Valcob.

Here had set up PlatformIO to work with Tasmota and just configured it to work with Espurna firmware.

Still learning.

Found this section in sensors.h file.

//------------------------------------------------------------------------------
// Dallas OneWire temperature sensors
// Enable support by passing DALLAS_SUPPORT=1 build flag
//------------------------------------------------------------------------------

#ifndef DALLAS_SUPPORT
#define DALLAS_SUPPORT 0
#endif

#ifndef DALLAS_PIN
#define DALLAS_PIN 14
#endif

#define DALLAS_RESOLUTION 9 // Not used atm
#define DALLAS_READ_INTERVAL 2000 // Force sensor read & cache every 2 seconds

//------------------------------------------------------------------------------
// DHTXX temperature/humidity sensor
// Enable support by passing DHT_SUPPORT=1 build flag
//------------------------------------------------------------------------------

#ifndef DHT_SUPPORT
#define DHT_SUPPORT 0
#endif

#ifndef DHT_PIN
#define DHT_PIN 14
#endif

#ifndef DHT_TYPE
#define DHT_TYPE DHT_CHIP_DHT22
#endif

So here can I keep the GPIO dallas sensors to GPIO 14 and change the DHT sensors to GPIO4 or any other. Here modded my SonOff WiFi basic adding outside terminals for multiple GPIO pins, 3.3VCC and 5.0VCC and ground for multiple sensors connectivity.

@peteeee peteeee closed this as completed Nov 27, 2018
@peteeee peteeee reopened this Nov 27, 2018
@peteeee
Copy link
Author

peteeee commented Nov 27, 2018

Keep closing thread by accident fat fingering it.

@peteeee
Copy link
Author

peteeee commented Nov 27, 2018

Got 5 DS18B20 sensors working now. 2 are local which are less than 2 meters and 3 are further away.

I put one 4.7k Ohm resistor at the terminal end of the SonOff basic Wifi device and one 4.7k Ohm resistor at the end run of the longest wire (50 feet or so).

image

Next looking to add two DHT22 combo sensors on different GPIO pins.

So modding firmware to work with wired terminals and multiple GPIO pins.

GPIO 14 - will be utilized for 5 DS18B20 temperature sensors
GPIO 4 - will be used for one extended DHT22 sensor
GPIO X - will be utilized for #2 extended DHT22 sensor

@Valcob
Copy link
Contributor

Valcob commented Nov 27, 2018

@peteeee OMG stop adding temperature sensors ))))
but I would say that there is no way to add more DTHs then only one that is a software limitation sadly but there is a hope that it will be removed some day :)

@peteeee
Copy link
Author

peteeee commented Nov 28, 2018

Yes here got addicted to 1-Wire sensors in the late 1990's and weather using an AAG Weather station.
Over the years expanded to multiple 1-wire hubs using Midon Temp05, Temp08's and Dallas serial hubs...then added 1-Wire Hobby Board sensors.

First MQTT testing was relating to using an RPi / Node Red / OWFS / Dallas hub...works great today..
and it is also a ZWave GPIO to ethernet box and an SDR radio box for downloading NOAA weather maps..

image

....and now wanting to downsize a bit and go to a hub and spoke topology using updated SonOffs.

Ideally incorporating the OWFS library would be a nice thing.

I did notice that with Tasmota firmware you can connect 3 DHT22's and did find a patch to update an old ino file:

Single wire sensor
The following single wire sensors are supported:
DHT22 Temperature and Humidity - DHT22 (3) in group 1

I am good here now with 5 DS18B20 sensors (extended) connected.

[402188] [MQTT] Sending SonOff-1Wire-1/temperature/0 => 68.0 (PID 734)
[402191] [MQTT] Sending SonOff-1Wire-1/temperature/1 => 71.1 (PID 735)
[402193] [MQTT] Sending SonOff-1Wire-1/temperature/2 => 70.5 (PID 736)
[402199] [MQTT] Publish ACK for PID 734
[402202] [MQTT] Sending SonOff-1Wire-1/temperature/3 => 71.7 (PID 737)
[402209] [MQTT] Sending SonOff-1Wire-1/temperature/4 => 67.8 (PID 738)
[402214] [MQTT] Publish ACK for PID 735
[402222] [MQTT] Publish ACK for PID 736
[402368] [MQTT] Publish ACK for PID 737
[402370] [MQTT] Publish ACK for PID 738

and will close this thread.

Thank you for your help Valcob.

@peteeee peteeee closed this as completed Nov 28, 2018
@peteeee
Copy link
Author

peteeee commented Nov 28, 2018

Officially closed this thread as I have fixed my multiple extended DS18B20 issue. Great stuff here!!!!

@JBSullivan
Copy link

Is this conversion also possible with Sonoff SV boards?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants