emsesp / EMS-ESP32

ESP32 firmware to read and control EMS and Heatronic compatible equipment such as boilers, thermostats, solar modules, and heat pumps
https://emsesp.github.io/docs
GNU Lesser General Public License v3.0
623 stars 107 forks source link

Bug in temperature readings of DS18b20 #466

Closed gaszu closed 1 year ago

gaszu commented 2 years ago

Hi! I have a EMS-ESP for over 5 months connected to Home Assistant, im always stay up to date with firmware. I've connected 8 DS sesnsors with additional pullup resistor. Frequently i have readings of all sensors 85deg Celsius for few seconds (85deg C in the same time for all sensors). I try to change, harness, manufacturer and number of sensor - it doesn't matter. All the time the same... I've try to connect EMS gateway to my HA by wifi or Lan - no change. It looks like in attachment : canvas1 canvas canvas2 canvas3

All the time glitches.... I have no problem with lan connection, no mqtt errors and no errors in log. All works perfectly, but that strength random readings...

EMS-ESP Version

v3.4.0b11 Device (Platform / SDK)

ESP32 / v3.3.5-1-g85c43024c System Uptime

006+21:52:05.112 CPU Frequency

240 MHz Heap (Free / Max Alloc)

143 396 / 72 208 bytes Flash Chip (Size / Speed)

4 194 304 bytes / 40 MHz File System (Used / Total)

24 576 / 65 536 bytes (40 960 bytes free)

harvey637 commented 2 years ago

Hi, this 85 degrees reading is a kind of error readout ("something went wrong") by the ds1820 itself, it is not a bug in the ems-esp firmware. pls google "ds1820 85 degree". possible solutions might be:

good luck Harvey

gaszu commented 2 years ago

I have other 2 projects with 2x 8 Ds build by myself and i don't have any problems with 1-wire connection (8266 to mqtt and arduino with display). Changing pullup res no resolved problem. I think this may be just a case of bad timing in temperature conversing. Typically 900ms it is enough to original DS. Most o them is China fake and need more time to conversing:)

proddy commented 2 years ago

interesting. Saw this too. We could add a check in the code to ignore this value. @MichaelDvP ?

MichaelDvP commented 2 years ago

85 degrees are in valid range of sensor measurement, ignoring it will also skip correct measurements. I have 7 sensors on my working ems-esp and 3 sensors on my test-ems-esp and never seen this 85 °C issue. All sensors connected direct to ems-esp, no extra pull-ups. Actualy i have one scratchpad-crc error in ~400000 reads. Long time ago there was this issue.

Checked the logged sensors, sensors publishes on change, so there is no value missing. Not a single 85°C value in this year (before the sensors are not named and logs stored with ID). grafik

bbqkees commented 2 years ago

I think just one of your 8 sensors is faulty. I have been running two Aliexpress DS18B20 sensors since it was implemented in EMS-ESP like 2 years ago and never had a single faulty 85 degree readout.

gaszu commented 2 years ago

Yesterday i enabled "clean session" in mqtt settings, and now only 2 sensors have glitches 85degC... maybe i don't understand ems-esp software algorithm? co_zasil solar

gaszu commented 2 years ago

I think just one of your 8 sensors is faulty. I have been running two Aliexpress DS18B20 sensors since it was implemented in EMS-ESP like 2 years ago and never had a single faulty 85 degree readout.

I have a lot of different kind of DS sensors and try to change it, cable harness, etc... In other post i wrote, that it doesn't matter. I have other 2 projests with 8 DS sensors - i connected existed with all cable harnesses (connected to EMS) to this hardware and all is ok.

In each project sensors works in parasite mode.

MichaelDvP commented 2 years ago

Mqtt settings have no inflluence on dallas. What port are you using (add settings), The default port have an internal pull-up, no need to add one. What resistance do you have added? What power do you use (parasite/3.3/5V)? BTW: ems-esp uses 1000ms timing and checks conversion complete flag in non-parasite mode.

gaszu commented 2 years ago

Mqtt settings have no inflluence on dallas. What port are you using (add settings), The default port have an internal pull-up, no need to add one. What resistance do you have added? What power do you use (parasite/3.3/5V)? BTW: ems-esp uses 1000ms timing and checks conversion complete flag in non-parasite mode.

With EMS default hardware pullup resistor only up to 4 sensors working propelly. When I added more - i have no readings from all sensor. I added external pullup - sensor now working ok, but glitches :). Power - parasite, and sensors i have, working propely in parasite power - believe me! I have in my house 2 projects (EMS and ESP8266) and in other house one with the same kind of sensors, but connected to Arduino with long, long cheap cable harnesses (parallel with grid 230v cables), and all it's ok. Maybe ems-esp should check conv. complete flag in PARASITE mode? BTW - tell me (if U know) where to buy ori DS18B20??? I'll made special parallel test of sensors for U :)

MichaelDvP commented 2 years ago

Maybe ems-esp should check conv. complete flag in PARASITE mode?

From the datasheet:

If the DS18B20 is powered by an external supply, the master can issue read
time slots after the Convert T command and the DS18B20
will respond by transmitting a 0 while the temperature
conversion is in progress and a 1 when the conversion is
done. In parasite power mode this notification technique
cannot be used since the bus is pulled high by the strong
pullup during the conversion.
gaszu commented 2 years ago

Maybe ems-esp should check conv. complete flag in PARASITE mode?

From the datasheet:

If the DS18B20 is powered by an external supply, the master can issue read
time slots after the Convert T command and the DS18B20
will respond by transmitting a 0 while the temperature
conversion is in progress and a 1 when the conversion is
done. In parasite power mode this notification technique
cannot be used since the bus is pulled high by the strong
pullup during the conversion.

OK, any solution?

gaszu commented 2 years ago

BTW - here is my lovelace with eight DS and other sensors from Bosch (productivity env.) image

And from oher location:

image

And lovelace from my backup server:

image

And this is my environment: IMG_20220412_104554

And temporary development working place: IMG_20220412_110704

MichaelDvP commented 2 years ago

Nice but useless pictures, my questions about settings and resistance value are still not answered. There no need to change the pull-up if parasite mode is activated. I don't have parasite sensors, can't test, but the mode is tested here and fixed here.

gaszu commented 2 years ago

4,7kOhm in parallel with default - finnaly, as usual.

gaszu commented 2 years ago

IMG_20220412_115856

This is the 8 sens. connected from ems-esp to arduino with his harness in parasite power. Works nice.

gaszu commented 2 years ago

Any questions?? I know , what i do. Maybe my english is bad, but! 25 years of ekectronics development.... I know, what i do. You work with ems-esp is for me a big thing - dont discuss it!! Keep doing IT well!!!! Im still wainting for final software wersion. You doing great job!!! BTW im software eng...

proddy commented 2 years ago

I still think its a wiring issue !

glitter-ball commented 2 years ago

@gaszu - do you have any issues with frequent restarts or RX errors on the EMS bus? I am still getting DS18B20 errors, but have an ongoing intermittent issue with the power supply. This shows up as excessive restarts and RX Incomplete errors. I suspect it may also be causing the DS18B20 errors. Hence my interest in whether you are seeing these too.

gaszu commented 2 years ago

@gaszu - do you have any issues with frequent restarts or RX errors on the EMS bus? I am still getting DS18B20 errors, but have an ongoing intermittent issue with the power supply. This shows up as excessive restarts and RX Incomplete errors. I suspect it may also be causing the DS18B20 errors. Hence my interest in whether you are seeing these too.

NO, i don't have any RX errors.

gaszu commented 2 years ago

I still think its a wiring issue !

No. I've found a solution. I've changed mqtt publish intervals to "0" - meens auto. No glitches.

proddy commented 2 years ago

That's interesting, so all intervals or just the one for "Temperature Sensors"?

gaszu commented 2 years ago

That's interesting, so all intervals or just the one for "Temperature Sensors"?

All

gaszu commented 2 years ago

ems-esp

proddy commented 2 years ago

and there were all set to 10 seconds before? Can you put them all back to 10 except Temperature Sensor and see if that works without errors? It'll help pinpoint where the actual bug is.

gaszu commented 2 years ago

ok, i've changed. We have to wait 1-2 days ok?

proddy commented 2 years ago

Perfect. Thanks

glitter-ball commented 2 years ago

Still watching this from the sidelines because I'm still seeing some issues... image

Initially the DS sensor was flawless but, at some stage, duff readings started to appear. I've had all the relevant MQTT publish intervals set to zero for months.

All the stuff I'm seeing could be a red herring. Not convinced I've ironed out power issues. I've got 88/495,000 Rx fails but a 50-line system log full of incomplete RXs since lunchtime today! But... importantly, 3.4.1 is massively more stable for me. EMS-ESP32 has been up for 5d20h which is a big improvement. So, I've probblay got other stuff going on, but I'll keep watching this one.

glitter-ball commented 2 years ago

I've taken the coward's way out of this for now and added some bad code to my sensor.yaml...

- platform: filter
  name: "Filtered return temp"
  entity_id: sensor.temperature_sensor_28_be2a_7791_0402
  filters:
        - filter: outlier
          window_size: 4
          radius: 10.0

I may need to tweak the settings but this should will replace any outlier spikes with the median of the four previous samples, whilst hopefully allowing valid data through. I had no idea this could be implemented that easily in HA with the filter integration. I will continue to monitor the raw data but it will, at least, tidy up my dashboard graphs for now.

gaszu commented 2 years ago

Perfect. Thanks

With this setup i have 1, 2 glitches per day. IT is acceptable. But with 3.4.1b2 is another problem. After restart no automatic mqtt conn. I have to go to mqtt settings tab, click save, than mqtt conecrs to my ha server. On previous versions i hadn't any problem.

proddy commented 2 years ago

Ok so somehow the wifi connectivity with MQTT is interfering with the Dallas sensors. EMS-ESP sends a lot of data out very frequently. The way to solve this is for me or Michael to recreate a similar scenario by stringing together some sensors and load testing it.

For the MQTT reconnect, I haven't seen this behaviour. Can you log a new GH issue for that?

gaszu commented 2 years ago

I've disabled wifi long time ago. Now I've only Ethernet connected (100/1000).

proddy commented 2 years ago

ah ok. still, we need to simulate this somehow as myself, Michael and Kees are not experiencing the same issue. It looks like MQTT is interfering with the Dallas reads