Dear author,
I read you books “Firebase Web App ESP32”. In the section 3.3 – Send Data to the Database, I used the DHT11 sensor data to update Firebase Realtime Database. It was workable.
But I used section 3.4 code, the data can’t be update in Realtime Database. I found that caused by below code line:
// Assign a calback function to run when it detects changes on the database
Firebase.RTDB.setStreamCallback(&stream, streamCallback, streamTimeoutCallback);
my voide loop() section was shown as below:
void loop(){
// Send new readings to database
if (Firebase.ready() && (millis() – sendDataPrevMillis > timerDelay || sendDataPrevMillis == 0)){
sendDataPrevMillis = millis();
// Get latest sensor readings
temperature = dht.readTemperature();
humidity = dht.readHumidity();
pressure = dht.readTemperature(true);
if (isnan(temperature) || isnan(humidity) || isnan(pressure)) {
Serial.println(F(“Failed to read from DHT sensor!”));
return;
}
// Send readings to database:
sendFloat(tempPath, temperature);
sendFloat(humPath, humidity);
sendFloat(presPath, pressure);
}
}
If I add code line in the void setup() “Firebase.RTDB.setStreamCallback(&stream, streamCallback, streamTimeoutCallback);” , I always got “Failed to read from DHT sensor!” in the monitor.
Do you have any suggestion for this?
Same. I was also using DHT11 it was working and then this update stopped working. Unfortunately I brunt one ESP32 😢 while trying to give the Separate power to DHT11.
Hi.
Can you share your complete code?
Share it using github, pastebin, google drive or other.
Regards,
Sara
Hi Sara,
I update the file in the google drive as below
https://drive.google.com/file/d/1DqYVEP_SYhnLlNJznorGKZgyD4ZR3-bl/view?usp=sharing
Thanks for your response
Hi Sara,
I still get the same problem, and the only way can be solved that I comment below code line in void setup()
“Firebase.RTDB.setStreamCallback(&stream, streamCallback, streamTimeoutCallback);”
While that will cause other problem, right?
Hi.
If you comment that line, the ESP won’t be able to detect database changes.
Can you try using another GPIO to connect the sensor?
How are you powering your circuit?
Regards,
Sara
Hi,
Unfortunately, I have used other GPIO and it was not work.
My circuit was show as picture.
https://atceiling.blogspot.com/2019/12/micropython05esp32micropython.html
Best Regards,
Hi.
I just tried our example with the DHT sensor and I also couldn’t make it work.
I faced the same problem as you.
I’m not sure, but maybe there is some incompatibility between the Firebase library and the DHT sensor.
I’m sorry that I can’t help much.
Meanwhile, if you find something, please share it.
Regards,
Sara
Hi Sara,
I got it, and I really appreciated your response.
Maybe I can change other sensor to fix this problem.
Best Regards,