Weird readings from DS18B20

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Misiu
Normal user
Posts: 26
Joined: 27 May 2019, 11:18

Weird readings from DS18B20

#1 Post by Misiu » 07 Oct 2020, 10:09

I have Wemos D1 with two genuine DS18B20 sensors.
Board is placed inside a wall, and sensors are one for each room (two rooms share the same wall).
The sensors in a way similar to this:
Image
Before sending the value via MQTT I'm calculating the average from 10 readings like so:

Code: Select all

On Kitchen#Temperature Do
 Let,10,[VAR#9]
 Let,9,[VAR#8]
 Let,8,[VAR#7]
 Let,7,[VAR#6]
 Let,6,[VAR#5]
 Let,5,[VAR#4]
 Let,4,[VAR#3]
 Let,3,[VAR#2]
 Let,2,[VAR#1]
 Let,1,[Kitchen#Temperature]
 TaskValueSet,3,1,([VAR#1]+[VAR#2]+[VAR#3]+[VAR#4]+[VAR#5]+[VAR#6]+[VAR#7]+[VAR#8]+[VAR#9]+[VAR#10])/10
EndOn
https://github.com/letscontrolit/ESPEas ... -550049981

The communication works, but after looking at the reading I've noticed weird behavior:
Image
Image

When we leave the house there are -2 degrees readings and when we return there are +2 readings.
I've replaced the sensors with new ones (also genuine) and I have the same behavior.

I have no idea what can be the cause of this. No one isn't touching the sensors or blowing hot air at them. When the light are turn on or off I have the same readings, so the electrical switch can't be the cause.

I know DS18B20 are very accured, but I'm sure they can't detect person leaving or entering the house :D

Not sure what can be the cause of this "issue".
Any advice is more than welcome.

TD-er
Core team member
Posts: 8746
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Weird readings from DS18B20

#2 Post by TD-er » 07 Oct 2020, 10:28

Well as a person you do put in 100 Watt per person in heat in the room.
As soon as you open the door, there is quite some heat exchange and I assume you have the light switch next to the door.

So depending on the size of the room, I can imagine the presence of a person can increase the temperature in the room.
It also depends on the pressure difference in the rooms whether you move the warmer air to the door or receive colder air from outside of the room.
For example a mechanical ventilation can cause some pressure difference between rooms.

In short, I am not sure the placement of your sensor is the most practical, next to the door.

What you can do, is try to place something consuming 100Watt of energy (or a known amount) when you left the room, to see if it matches the behavior you now observed.

Misiu
Normal user
Posts: 26
Joined: 27 May 2019, 11:18

Re: Weird readings from DS18B20

#3 Post by Misiu » 07 Oct 2020, 14:21

@TD-ed thanks for the reply.
I'll give this a try and report back with the results.

From your experience, what would be the best place for sensors?

I have 5 sections in house. two ensors are based on ESPEasy+Wemos D1+MQTT and three are directly connected to Raspberry Pi.
I've used ESP Easy in the bast and I had zero problems with it (to be clear on that ;) )

I think that I'll crate a temporary sensor and put it somewhere else in the room to see the results (I'll wait for your recommendation of the place)

Below are two sensors, one from living room and second from hallway (the stable one)

Image
prywatny hosting zdjęć

TD-er
Core team member
Posts: 8746
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Weird readings from DS18B20

#4 Post by TD-er » 07 Oct 2020, 14:48

Well it really depends on what you want to do with the measured values.

If it is to detect a draft, then it may be the best place :)

If you want to measure the temperature near where you are in the room (e.g. your desk), then I think placing it on the desk is a good place.
Just make sure you're not placing a temperature sensor at a spot where it may receive direct sunlight or heat from devices like a monitor or PC.

But judging your charts, I think the temperature of the entire room will drop when you're not in the room.

If you don't want the temperature measurement to act quickly on changes, you can literally add some mass to it.
For example a lump of metal which does have some heat capacity, so it takes a while for it to change temperature.
Or to be more exact, it needs more energy transfer to change the temperature.
The energy transfer speed depends mainly on 3 factors:

- Surface area of the object
- Temperature difference (larger difference is faster heat exchange)
- Heat Transfer Coefficient (depending on material and how the heat is exchanged)

Misiu
Normal user
Posts: 26
Joined: 27 May 2019, 11:18

Re: Weird readings from DS18B20

#5 Post by Misiu » 07 Oct 2020, 15:19

I want to measure the temperature in the room to control the floor heating in the same room ;)
This basically works. I get reading from DS18B20 via MQTT to Home Assistant and depending on the temperature I'm opening or closing a valve.
Everything works great except those reading that drop when no one is at home.

I have two other sensors in the same room, 20 cm to my custom sensors and they don't have that drop.

I'll try to send raw values from the sensor and do the average on the Home Assistant side. I don't think this will help, but at least I'll remove one potential cause - my code :)

TD-er
Core team member
Posts: 8746
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Weird readings from DS18B20

#6 Post by TD-er » 07 Oct 2020, 16:22

Ah that's why you just commented on the issue for a filter plugin :)

Misiu
Normal user
Posts: 26
Joined: 27 May 2019, 11:18

Re: Weird readings from DS18B20

#7 Post by Misiu » 07 Oct 2020, 16:27

TD-er wrote: 07 Oct 2020, 16:22 Ah that's why you just commented on the issue for a filter plugin :)
You got me :D
I'm aware the isn't one perfect filter and it all depends on the application, but I think that a "filter device" would be very useful.
I know that there are tons of feature requests, but this for me this one would be super useful.

As I wrote before I try to send raw values and do the filtering in Home Assistant. That's one of the options on my list.

TD-er
Core team member
Posts: 8746
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Weird readings from DS18B20

#8 Post by TD-er » 07 Oct 2020, 23:23

Would a very simple IIR filter as "standard conversion" already help here?

For example %c_iir_pnf%(prev,next,factor)

The resulting value is then something like:
res = prev + ((next - prev) / factor)

Misiu
Normal user
Posts: 26
Joined: 27 May 2019, 11:18

Re: Weird readings from DS18B20

#9 Post by Misiu » 08 Oct 2020, 11:30

@TD-ed to be honest I don't know :)
I'll try to do the processing in Home Assistant and this should show what filter works best, but I'm almost 100% sure that won't help with the 2 degrees drop.

I've searched a bit, and for example, ESPHome is doing this in a bit different way. Please take a look: https://esphome.io/components/sensor/in ... or-filters
You only define the filter, you don't have to store previous value(s) in variables.

Ideally, there should be a new device type, in which you would be able to select the filter and the output could be sent to a controller. This way the end-user won't have to know how to write rules.
When needed he will edit the device and change the filter type or adjust filter properties.

I'm writing this from the user perspective, not the developer perspective because such a device is probably a massive work to do :|

TD-er
Core team member
Posts: 8746
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Weird readings from DS18B20

#10 Post by TD-er » 08 Oct 2020, 12:27

Well I'm not sure yet how massive it will be as I simply don't know where to logically place it.

To clarify this, let me explain it from a block view perspective on the ESPEasy "components".

We have:
- Plugin interacting with hardware
- Task, an instance of a plugin able to output data.
- Controller, linked to a task and receiving data from the task, sending it to some end point.
- Rules: messing around and poking everywhere :)

There are several ways where a filter could be useful:
- As an extra or alternative to the current formula (that's where my earlier suggestion could go) in a task
- Somewhere between a task and a controller (makes it impossible to use it in a rule)
- As a new type of dummy plugin. This seems flexible but makes it rather complex for newcomers as you cannot easily send data from one plugin to another. (need to use rules)
- As a new type of "variable", so need to be fed via rules, but can be queried from just about anywhere
- As an input for a controller. This is the least practical way I guess.

Also there are always side effects to filtering, of which the most important and maybe also least intuitive one is the delay it causes.
The delay is almost always a function of the number of samples fed, but I can imagine it would be very useful to have a filter based on time since last sample.

This all makes it quite complex and hard to make it "easy" to use.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 37 guests