Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Bug in temperature readings of DS18b20 #466

Closed
gaszu opened this issue Apr 11, 2022 · 32 comments
Closed

Bug in temperature readings of DS18b20 #466

gaszu opened this issue Apr 11, 2022 · 32 comments
Labels
help wanted Extra attention is needed

Comments

@gaszu
Copy link

gaszu commented Apr 11, 2022

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)

@gaszu gaszu added the bug Something isn't working label Apr 11, 2022
@harvey637
Copy link

harvey637 commented Apr 11, 2022

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:

  • other cables
  • other pullup resistor
  • only fewer sensors but than on more than one output pin (dont forget pullup resistor on each output line)

good luck
Harvey

@gaszu
Copy link
Author

gaszu commented Apr 11, 2022

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
Copy link
Contributor

proddy commented Apr 11, 2022

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

@MichaelDvP
Copy link
Contributor

MichaelDvP commented Apr 11, 2022

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
Copy link
Contributor

bbqkees commented Apr 12, 2022

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
Copy link
Author

gaszu commented Apr 12, 2022

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
Copy link
Author

gaszu commented Apr 12, 2022

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
Copy link
Contributor

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
Copy link
Author

gaszu commented Apr 12, 2022

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
Copy link
Contributor

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
Copy link
Author

gaszu commented Apr 12, 2022

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
Copy link
Author

gaszu commented Apr 12, 2022

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
Copy link
Contributor

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
Copy link
Author

gaszu commented Apr 12, 2022

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

@gaszu
Copy link
Author

gaszu commented Apr 12, 2022

IMG_20220412_115856

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

@gaszu
Copy link
Author

gaszu commented Apr 12, 2022

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
Copy link
Contributor

proddy commented Apr 14, 2022

I still think its a wiring issue !

@proddy proddy added help wanted Extra attention is needed and removed bug Something isn't working labels Apr 14, 2022
@glitter-ball
Copy link

@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
Copy link
Author

gaszu commented Apr 18, 2022

@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.

@proddy proddy closed this as completed May 27, 2022
@gaszu
Copy link
Author

gaszu commented Jun 1, 2022

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
Copy link
Contributor

proddy commented Jun 3, 2022

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

@proddy proddy reopened this Jun 3, 2022
@gaszu
Copy link
Author

gaszu commented Jun 3, 2022

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

All

@gaszu gaszu closed this as completed Jun 3, 2022
@gaszu
Copy link
Author

gaszu commented Jun 3, 2022

ems-esp

@gaszu gaszu reopened this Jun 3, 2022
@proddy
Copy link
Contributor

proddy commented Jun 4, 2022

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
Copy link
Author

gaszu commented Jun 4, 2022

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

@proddy
Copy link
Contributor

proddy commented Jun 4, 2022

Perfect. Thanks

@glitter-ball
Copy link

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
Copy link

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
Copy link
Author

gaszu commented Jun 6, 2022

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
Copy link
Contributor

proddy commented Jun 6, 2022

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
Copy link
Author

gaszu commented Jun 6, 2022

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

@proddy
Copy link
Contributor

proddy commented Jun 6, 2022

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

@proddy proddy closed this as completed Nov 11, 2022
@proddy proddy reopened this Feb 13, 2023
@emsesp emsesp locked and limited conversation to collaborators Feb 13, 2023
@proddy proddy converted this issue into discussion #1005 Feb 13, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

6 participants