arendst / Tasmota

Alternative firmware for ESP8266 and ESP32 based devices with easy configuration using webUI, OTA updates, automation using timers or rules, expandability and entirely local control over MQTT, HTTP, Serial or KNX. Full documentation at
https://tasmota.github.io/docs
GNU General Public License v3.0
21.98k stars 4.77k forks source link

problems with DS18B20 #1239

Closed ppisljar closed 6 years ago

ppisljar commented 6 years ago

Hello,

i am using sonoff basic, latest version of sonoff tasmoa (from today) and have the following setup:

connections:

nothing in the log (like sensor busy or anything), seems the sensors are just not detected

i also tried moving it to GPIO1 (serial in) and GPIO3 (serial out) with same results.

however i am sure the sensors function, as i tried using ESP32 with this code: https://github.com/DavidAntliff/esp32-ds18b20-example/tree/master/main

and i get all 3 sensors detected, and read, with 0 errors (same connection, 3.3v power source from esp32)

should i connect DS18B20 in a different way for sonoff tasmoa ? or what would be my next debugging steps ?

thanks.

ppisljar commented 6 years ago

oh, and i compiled the code by uncommenting this line in platformio.ini:

env_default = sonoff-ds18x20

no other changes to the code.

davidelang commented 6 years ago

what version of tasmota are you running, and did you configure the GPIO to the sensor type in the module configuration page?

ppisljar commented 6 years ago

as mentioned in my first post, i downloaded tasmoa from github today (master branch), and yes, GPIO is set to 4 (ds18b20)

arendst commented 6 years ago

No problem at all:

image

image

image

You might want to try to connect only one sensor and disable USE_DS18x20 in user_config.h to see if one sensor works fine using default enabled single senosr support.

arendst commented 6 years ago

Try the latest development repository version 5.9.1i.

ppisljar commented 6 years ago

i tried with a single sensor today, compiled without USE_DS18x20 ... also doesn't work. i'll try with development branch tomorrow.

pascalsaul commented 6 years ago

Looks good to me also: tele/dual_sw/SENSOR {"Time":"2017-11-25T13:54:49","DS18x20":{"DS1":{"Type":"DS18B20","Address":"28FFE48601170396","Temperature":24.2},"DS2":{"Type":"DS18B20","Address":"28FFDE8D0117033B","Temperature":22.7}},"TempUnit":"C"} stat/dual_sw/RESULT {"OtaUrl":"http://192.168.1.12/sonoff.bin"} stat/dual_sw/RESULT {"Upgrade":"Version 5.9.1f from http://192.168.1.12/sonoff.bin"} tele/dual_sw/LWT Offline tele/dual_sw/LWT Online cmnd/dual_sw/POWER (null) stat/dual_sw/UPGRADE Successful. Restarting

tele/dual_sw/LWT Offline tele/dual_sw/LWT Online cmnd/dual_sw/POWER (null) tele/dual_sw/INFO1 {"Module":"Sonoff Dual","Version":"5.9.1i","FallbackTopic":"dual_sw","GroupTopic":"sonoffs"} tele/dual_sw/INFO2 {"WebServerMode":"Admin","Hostname":"dual_sw","IPAddress":"192.168.1.122"} tele/dual_sw/INFO3 {"RestartReason":"Software/System restart"} stat/dual_sw/RESULT {"POWER1":"0"} stat/dual_sw/POWER1 0 stat/dual_sw/RESULT {"POWER2":"0"} stat/dual_sw/POWER2 0 tele/dual_sw/STATE {"Time":"2017-11-25T13:56:43","Uptime":0,"Vcc":3.322,"POWER1":"0","POWER2":"0","Wifi":{"AP":1,"SSId":"","RSSI":82,"APMac":"78:C1:A7:3D:B0:B8"}} tele/dual_sw/SENSOR {"Time":"2017-11-25T13:56:43","DS18x20":{"DS1":{"Type":"DS18B20","Address":"03170186E4FF","Temperature":24.0},"DS2":{"Type":"DS18B20","Address":"0317018DDEFF","Temperature":23.2}},"TempUnit":"C"}

ppisljar commented 6 years ago

i tried with latest development version, and a different sonoff basic (just to be sure something is not wrong with the first one). still no success ....

in the meantime i tried to connect DHT22 sensor, and this one seems to work ok.

ppisljar commented 6 years ago

also tried with version 5.8 (with and without #define USE_DS18x20 ) ... no luck ... at this point i am almost sure something is wrong with the connections or my sensors are not compatible ...

ppisljar commented 6 years ago

i tried with smaller resistor, and this seems to work ... yay (3k) ... atleast for a single sensor ... lets try with multiple now :)

pascalsaul commented 6 years ago

I use 4.7k resistors with 1 or even with 5 DS18B20's...

ppisljar commented 6 years ago

yup, it works now with 3 sensors. in case anyone else runs in the same problem ... i tried with smaller resistor, which solved my problem. the code referenced above (for esp32) works with the original resistor as well. my cable is 1m long.

ppisljar commented 6 years ago

ok i am getting into more issues, i hope somebody here can advise me ... i tried to connect the 3 sensors over 10m CAT5 cable now

i am using two 4.7k resistors, one on each end of the cable ( i also tried with single 4.7k resistor as well as single 2k resistor)

the readings on all 3 sensors are 85* most of the time, from time to time jumping down a bit to something like:

DS18B20-1 Temperature | 78.9°C DS18B20-2 Temperature | 85.0°C DS18B20-3 Temperature | 75.4°C

reading around internet, for example here: https://forum.arduino.cc/index.php?topic=20574.0 or here: http://www.protonbasic.co.uk/showthread.php/60921-DS18B20-Long-Wires

makes me think that 10m should not be a problem (its actually a bit less, more like 7m)

the first link mentions something about timing, but i haven't tried changing the timings yet, i am wondering if anyone here is using longer cables and has good results before doing that.

using latest version of tasmota firmware 5.9.1h

ppisljar commented 6 years ago

i shortened the cable to the minimum i need (4 meters), still the same issue

mkh595 commented 6 years ago

If sensor returns 85 (default value in scratchpad after power up before first conversion is triggered) it means that conversion and writes to internal scratchpad doesn't finished succesfully. It can be problem with timing, means that your sensor is bad quality and needs more time for conversion. Try another sensor or you have to use logic analyzer to check comunication. I have few sensors which I throw away because permanently returns 85.

Frogmore42 commented 6 years ago

There are lots of things that can go wrong with OneWire communication and DS18x20 devices. I have been using them for years and they are generally pretty reliable, but they can be tricky. I have never tried a 10m cable, but I have 5m or more. I typically use the solid orange wire for 3V3 or 5V (on other controllers that support it), the solid brown wire for ground, and the white with brown stripe for the data line. I chose this because the data is in a twisted pair with ground (which seemed like a good idea) and it uses the pairs that are not typically used in normal CAT5 T568B wiring for network or phone (which seemed like an even better idea in case they accidentally got plugged into a phone/network port.

In my code, I throw out readings of exactly 85 or 0, since either could be caused by bad power or a short (both of which I have seen, due to poor soldering and/or corrosion over time).

Are you using raw parts or ones that already have 1m or longer cables attached? I stopped making my own sensor cables and now buy the premade ones in stainless steel casing with 1m or longer cables. I do typically solder the provided cables to CAT5 cable (only the flexible kind used for patch cables, not the in-wall stuff which uses solid wire and is too easy to bend and break) to make longer cables.

I have not tried long cables on the esp8266 so I don't know how well it can handle them, but check your soldering first.

ppisljar commented 6 years ago

thanks @Frogmore42, seems my problem was bad contacts. I have sensors with 1m wire, and then i used CAT5 cable to extend them, but i didn't solder them together, used the screw kind cable joints (no idea how to properly call that in english).

I soldered them now and it seems to work OK.

Frogmore42 commented 6 years ago

I use solder and then heat shrink tube if they will not be subject to moisture. For ones that will be outside, I encase them in epoxy or hot melt glue.

comtechnik commented 6 years ago

I have a problem with the DS8B20 on Sonoff RF. The DS18B20 gets hot and sonnoff does not start anymore. I have connected to Pin1, GND and GPIO14, between Pin1 and GPIo14 is a 4.7k resistor. Who can help me ??? Thank you

lobocobra commented 5 years ago

Does anyone know if using a DS1820 does work? => I can connect a DS18S20 to my Sonoff Basic and it works. But none of the DS1820 I tried does show a signal. I have a 10kOhm resistor and a 1m long wire.

As said the "S" version works. Before I return the 10 DS1820, I wanted to check if somebody can confirm, that they do not rund with the latest standard firmware?

I ordered the DS18S20 and they sent me the DS1820. Does somebody knows the answer?

Thanks

lobocobra commented 5 years ago

Solved the issue myself :-) 2 out of the 10x I bought were defect, guess which of the 2 ones I tested ^^ => all others work.

Btw if you connect multiple DS18S20 then they are shown as different sensors and what is really magic, is that they all show the same temperature at the same spot.... All other sensors I have bought for my weather station give any near temperature but not the same (if you have multiple sensors) but those small cheap DS show all the same temp!!!! coool

Frogmore42 commented 5 years ago

Here is an article on the differences https://www.maximintegrated.com/en/app-notes/index.mvp/id/4377

Depending on the resolution you have selected, you might see differences in temperature. The higher the resolution the more likely there will be a difference shown. It is rare for the temperature to be exactly uniform. There is usually some difference/gradient.

dhlii commented 5 years ago

I have a DS1820 with a Sonoff-Basic and Tasmota 6.4.1(basic) Data is connected to GPIO14. Power and GND connected. A 4.7K resistor between power and data. In configure Module I have "GPIO14 Sensor" set to DS18x20(04) Should I see any evidence Tasmota found the DS18x20 via the web interface ? In the console Log ?

ehorohorin commented 5 years ago

I have connected two ds18b20 sensors to the sonoff 4ch pro r2, but it shows me only one of it. Is there any action need to be done to access both of them?

default_env = sonoff-sensors, GPIO2 is configured as DS18x20 (04) 4.7k resistor was soldered between red and yellow cables.

Is there any relation between resistance and amount of 1wire sensors?

Frogmore42 commented 5 years ago

There are three different versions of support for DS18B20 sensors. Which one are you using? 2 of the 3 appear to have logging, so try turning that on: weblog 4 Will turn on maximum logging. Then see what gets printed.

2 of the 3 can handle multiple sensors. But USE_DS18x20 is the one you want to handle multiple.

Double check the value of your resistor, many people think they have a 4K7 but sometimes pick something else. 4K7 is fine typically. It is to pull-up the data line. There is both an art and a science to picking the value, but if you have a simple setup (i.e. no long wires) most values in the 2K to 10K range will work.

It is MUCH better to use the realtime discord channel for troubleshooting help, instead of a CLOSED issue

ehorohorin commented 5 years ago

Ok, thank you for instant reply. Will join discord channel and continue there.

dhlii commented 5 years ago

The firmware is sonoff-basic.bin from the git repository. I did not build firmware. I already have weblog 4 on and there is no mention of a DS1820 or anything 1wire in the log. I checked the resistor with a VOM before soldering it between +3.3 and GPIO14 I have only a single sensor/DS1820

Should I create a new topic ?

ehorohorin commented 5 years ago

@dhlii try another ds18b20 if you have one more

edgiru commented 5 years ago

I look, not only one does not work for me. Obviously the problem is in the firmware. Also worth 4.7k resistor. but does not see the sensor. other firmware (espeasy) immediately see the sensor. The sensor works exactly, because I checked on other similar firmware. set module to Generic doesn't work either.

Program Version | 6.5.0(release-basic) Снимок5 Снимок4

ascillato commented 5 years ago

You have upload the version sonoff-basic.bin. Please read the release notes. The sonoff-basic.bin DOES NOT HAVE SENSORS.

Please, for sensor use sonoff-sensors.bin

Thanks

If you need further assistant, please find us in the Tasmota support chat. Thanks