Dear Sara,
Please can you check the below and give me a hint how to resolve this??
humidity:”65.70″
temperature:”24.40″
timestamp:”1666204515″
-NElWqWZoeBKIKId_Gvk
humidity:”nan”
temperature:”nan”
timestamp:”1666204525″
-NElWrl43YqUK5C39EEI
humidity:”66.90″
temperature:”24.40″
timestamp:”1666204531″
-NElWtH4KEt9QP3GzQ-M
humidity:”nan”
temperature:”nan”
timestamp:”1666204537″
As you can see humidity and temperature measurements sometimes passthrough and sometimes not.
Also at the serial monitor everything looks ok.
Pretty printed JSON data:
{
“pwm”: {
“12”: 25,
“14”: 20
}
}
Iterate JSON data:
0, Type: object, Name: pwm, Value: {“12″:25,”14”:20}
1, Type: object, Name: 12, Value: 25
2, Type: object, Name: 14, Value: 20
Received stream payload size: 64 (Max. 64)
time: 1666204525
Set json… ok
time: 1666204531
Set json… ok
time: 1666204537
Set json… ok
Please help as it is driving me crazy.
P.S. Used your code provided from the ebook. The only thing changed is the sensor. Used DHT22 instead BME280
Thank you.
Best regards,
Chris.
Hi.
What’s the delay time between each reding?
The set json ok message doesn’t mean the sensor is reading right values. It just meands the data was succesfully submited to the database, whether that’s nan or a number.
You need to add some if statement to your code that checks the readings. If naan, wait some time and try again to get the redings.
Did you check the DHT sensor tutorial?
https://randomnerdtutorials.com/esp32-dht11-dht22-temperature-humidity-sensor-arduino-ide/
In that tutorial, check the following section of code:
// Check if any reads failed and exit early (to try again).
if (isnan(h) || isnan(t) || isnan(f)) {
Serial.println(F("Failed to read from DHT sensor!"));
return;
}
Adapt that snippet to your case scenario, this is what you want to do when you get the nan value (wait and try to get new readings). You can also add a while statement instead, so that it doesn’t proceed while it doesn’t get a value reading.
I hope this helps.
Regard,
Sara
Dear Sara,
Thanks a lot for your propt reply.
Have tried delay between readings from 3 minutes down to 10 seconds, nothing works.
When the function void streamCallback(FirebaseStream data) comes into play
it messes up the readings, without this function everything works perfectly (but you cannot have slider function without streamCallback)
I will try the approach you sugested and I will keep you posted.
Kind regards,
Christos
Ok, then let me know.
It only came to my mind now, that some time ago I had other readers complaining about issues with the DHT and the firebase projects.
I’m not sure if there’s possibly some kind of incompatibility between the DHT library functions and the Firebase library functions…
Regards,
Sara