[SOLVED] Too frequent updates form DHT
-
@mfalkvidd said in Too frequent updates form DHT:
wait
That was easier than expected, thanks for your advice, seems to do the trick. Will apply this to all my nodes now and test.
Thanks for your fast replays.
-
@mfalkvidd said in Too frequent updates form DHT:
wait
That was easier than expected, thanks for your advice, seems to do the trick. Will apply this to all my nodes now and test.
Thanks for your fast replays.
-
@mfalkvidd
Hi again.
I got small problem that emerged after this change. When I try to use my wall switches nothing happens, I still can turn on/off all lights from controller without problems, only localy attached switches do not work and that is not an option.so the problem lies in this line, if I understand correctly
// Sleep for a while to save energy sleep(UPDATE_INTERVAL);if I change sleep to wait, so I'm back to the beginning now. Is there any way to fix this?
-
@mfalkvidd
Hi again.
I got small problem that emerged after this change. When I try to use my wall switches nothing happens, I still can turn on/off all lights from controller without problems, only localy attached switches do not work and that is not an option.so the problem lies in this line, if I understand correctly
// Sleep for a while to save energy sleep(UPDATE_INTERVAL);if I change sleep to wait, so I'm back to the beginning now. Is there any way to fix this?
@archiijs I would remove the wait/sleep and change
else if (temperature != lastTemp || nNoUpdatesTemp == FORCE_UPDATE_N_READS)to
else if (temperature != lastTemp)That will cause the temperature to be sent whenever it has changed.
There are several other ways to get a similar result. What is best depends on how you want the node to behave.
-
@mfalkvidd Thanks again for your response.
I just changed else if functions as you suggested and uncommented wait/sleep(update_interval);
Actually, I think that I had code like this couple days before...The result is kind of what is needed, I get new values as they change, BUT they change all the time. Like my temperature just changes true 21.7 to 21.6 to 21.7 to 21.8 an ower and ower again nonstop, same with humidity.
EDIT: Just switched out DHT sensor for anorther and nothing has changed.
-
@mfalkvidd Thanks again for your response.
I just changed else if functions as you suggested and uncommented wait/sleep(update_interval);
Actually, I think that I had code like this couple days before...The result is kind of what is needed, I get new values as they change, BUT they change all the time. Like my temperature just changes true 21.7 to 21.6 to 21.7 to 21.8 an ower and ower again nonstop, same with humidity.
EDIT: Just switched out DHT sensor for anorther and nothing has changed.
-
@mfalkvidd That sounds about right. But sadly I can not find any examples of such sensors and I'm not sure if I could figure this out by myself :/
-
@mfalkvidd That sounds about right. But sadly I can not find any examples of such sensors and I'm not sure if I could figure this out by myself :/
Hysteresis: https://forum.mysensors.org/post/66870
Timer: https://forum.mysensors.org/post/70243 -
@mfalkvidd Superb, I will study your suggestions and report back. Thanks again for your patience with me.
-
Hi @mfalkvidd and others.
Yesterday after work I tried to get my head around code suggestions but somehow I cold not make them work so I did some google search and after some time I find something that I implemented in my nodes for testing.
Interestingly it works as expected for two of my nodes, but one still keeps jumping around, not that often, but that's still strange, I will compare code to other two to see what I've done wrong there.
So I used Hysteresis approach by doing this.#define HYSTERISIS 0.5 // Hysteresis for sensor ... float temperature = dht.getTemperature(); if (isnan(temperature)) { Serial.println("Failed reading temperature from DHT!"); } else if (abs(temperature - lastTemp ) > HYSTERISIS) { // Only send temperature if it changed since the last measurement or if we didn't send an update for n times lastTemp = temperature; if (!metric) { temperature = dht.toFahrenheit(temperature); }And the same for humidity.
Still not sure that this will work as expected in long run, but will see.
But now it is way better than before. Thanks.