bruhautomation / ESP-MQTT-JSON-Multisensor

(OBSOLETE) ESP MQTT JSON Multisensor for Home Assistant. Supported sensors include the TEMT6000 light, AM312 PIR, DHT22 temperature/humidity sensors. RGB led supports flash, fade, and transition. Over-The-Air (OTA) uploading, too!
https://youtu.be/jpjfVc-9IrQ
Apache License 2.0
340 stars 152 forks source link

temperature and heatIndex values on first boot up #36

Open ericstewart22 opened 6 years ago

ericstewart22 commented 6 years ago

Hello,

Whenever I unplug my sensor or it loses power, the temperature and heatIndex values default to 0 and get sent to my MQTT broker which then makes its way into Home Assistant and results in a spike in the charts.

Here's an example of what it looks like: image

I tried adjusting the calibrationTime variable but that didn't work. What would be the recommended way to fix this? Is it as simple as using a counter to disregard the first few MQTT values? If it is then maybe I can try and fix it myself, but I thought there might be a better way.

VegasIOT commented 6 years ago

I added this to the SendState void function. I basically doesn't send if its below 1. I'm sure something more elegant like just sending a NULL would be better but this works for me

if (tempValue<1) { Serial.println("less than 1"); } else { Serial.println(buffer); client.publish(light_state_topic, buffer, true);

kwinck commented 6 years ago

My take on that issue is to have a timer, that ensures that it doesn't send any values the first 30 sec. or so, ie. until the calibration period is done.

ericstewart22 commented 6 years ago

Thanks for the input, After some testing I'm going to use humValue < 1 for now since it seems to be the last thing to calibrate. I'll try my hand at using a timer when I have more time.

lassivv commented 6 years ago

Same problem and try add capacitor on power line and better 5volt supply power, nothing help not know why sensor restart/softstart every day random couple times.

After that i add this code in first rows sendstate function and everything works perfectly after that. T


byte countSentStates = 0;

  if(countSentStates <= 2)
  {
    countSentStates++;
    return;
  }

Code just ignore 3first mqtt sends and after that sends every mqtt messages normally.

mr-sneezy commented 6 years ago

lassivv, I get these dropouts also, on two sensornodes. It seems to be a random reset from something unknown. It's not power related as I've covered that through elimination and also adding large fiters caps (1800uF) to the 5V input of the NodeMCU's just in case. My graphs of 24 hour data look very like yours with data dropouts to below zero on temp and humidity when these events occur. When it does this the RGB LED also goes to blue and stays that way till I send a "White' colour to it and then 'Off' via HA Light component GUI. PS. I wonder a bit if it's something to do with a bad choice of ESP8266 NodeMCU settings in the Arduino IDE when compiling and flashing...

Update: I've compiled DanielXYZ2000's master branch and it has resolved the random crap HA data value spikes (after random MCU resets) and also the blue led 'mind of it's own' issue. Why wouldn't these fixes get pulled in to master ?