• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

Streaming Database Listening for Changes issue

Q&A Forum › Category: ESP32 › Streaming Database Listening for Changes issue
0 Vote Up Vote Down
KuoFeng Lin asked 4 years ago

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?

10 Answers
0 Vote Up Vote Down
Prakash answered 4 years ago

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. 

0 Vote Up Vote Down
Sara Santos Staff answered 4 years ago

Hi.
Can you share your complete code?
Share it using github, pastebin, google drive or other.
Regards,
Sara
 

0 Vote Up Vote Down
KuoFeng Lin answered 4 years ago

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

0 Vote Up Vote Down
Sara Santos Staff answered 4 years ago

Hi.
If you remove that delay(2000) from the loop() what happens?
Regards,
Sara

0 Vote Up Vote Down
KuoFeng Lin answered 4 years ago

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?

0 Vote Up Vote Down
Sara Santos Staff answered 4 years ago

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
 

0 Vote Up Vote Down
KuoFeng Lin answered 4 years ago

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,

0 Vote Up Vote Down
Sara Santos Staff answered 4 years ago

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

0 Vote Up Vote Down
KuoFeng Lin answered 4 years ago

Hi Sara,
 I got it, and I really appreciated your response.
Maybe I can change other sensor to fix this problem.
Best Regards,

0 Vote Up Vote Down
Sara Santos Staff answered 4 years ago

Ok.
Then, tell me if you succeed with a different sensor.
Regards,
Sara

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [eBook Updated] Learn Raspberry Pi Pico/Pico W with MicroPython eBook – Version 1.2 May 26, 2025
  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.