mobizt / Firebase-ESP32

[DEPRECATED]🔥 Firebase RTDB Arduino Library for ESP32. The complete, fast, secured and reliable Firebase Arduino client library that supports CRUD (create, read, update, delete) and Stream operations.
MIT License
415 stars 118 forks source link

HELP : After 2,3 hrs of connection to firebase esp32 is going unresponsive state. #52

Closed vamsikrishnaA9 closed 4 years ago

vamsikrishnaA9 commented 4 years ago

Hi there, I've connected esp32 to firebase, after some moments there is no response from the module when I change the database values. More Info : I've created a task for checking internet for every 5 seconds on other core. I don't know what I have done worng got confused. Please give me suggestion that would be a great help for me. Thank you

mobizt commented 4 years ago

I can't hep without your test code. Please post you working code here.

mobizt commented 4 years ago

Please explain more detail. Which line get error?

vamsikrishnaA9 commented 4 years ago

Thank you for your quick response Code is working fine. For the first 1 or 2 hrs after power up the module I am getting the stream response from the database. If I kept the module in Idle state for more than 1 or 2 hrs with out changing the values in firebase, the esp32 is not responding. Every time I need to reset the esp32 to get connection from firebase and to get values. I've used stream loop example to develop my requirement. In the second core I put continuos checking of ping to display internet status. I don't think so It creates unresponsive state problem.Please find me solution if I did anything wrong , that would be a great help for me. Thank you very much. Edit : core 0 ( ping check loop) is working even after long time.

mobizt commented 4 years ago

You need to debug for free heap, memory leak and WiFi status and stream timeout checking is already available as in example.

You need more than 100k free mem for WiFi client to work.

vamsikrishnaA9 commented 4 years ago

Will work on that. Update the status to you sir. Thank you very much.

vamsikrishnaA9 commented 4 years ago

hi mobizt, Found some observations in serial monitor, Sketch uses 1018714 bytes (77%) of program storage space. Maximum is 1310720 bytes. Global variables use 46128 bytes (14%) of dynamic memory, leaving 281552 bytes for local variables. Maximum is 327680 bytes. ESP.getFreeHeap() returned max 308848 free heap memory from the void setup(). i have added ESP.getFreeHeap() in the loop also. the stack memory allocated to ping check task is 20k. after deducting that memory the free stack available is around 297k which keeps on depleting over time to 295k, 290k,285k........ so onn tto 200k and below. I think once the availabe memory depleting too low the module goes to unresponsive state or reset. This is what i have identified. I am not able to think how to proceed and resolve this memory depleting issue. any suggestions?

mobizt commented 4 years ago

I'm not mention the stack here, only memory leak was suspected. The error due to stack overflown causes device to reset.

For your case, free heap available may be too low (<100k) for mbedTLS library (used by WiFi client) to operate correctly.

You need to config ArduinoIDE to debug WiFi to track its operation.

Compare free heap between when ping task removed and not removed.

vamsikrishnaA9 commented 4 years ago

when ping task was disabled the free heap was around 211780 and is stable and module does not go unresponsive. but when ping task is enabled the free heap goes on depleting and at around 65000 the module goes unresponsive because the available 65k stack is not sufficient for Wifi client to operate. This is the problem i have identified.So now how to enable ping task without depletion of free heap and what causes my free heap to deplete? how can i solve this?

mobizt commented 4 years ago

Please try other ping libraries instead. I don't have any recommendation on this.

vamsikrishnaA9 commented 4 years ago

Thanks for your quick response and support. I will try to figure it out and post here if i find any solution.

vamsikrishnaA9 commented 4 years ago

all the ping libraries available are depleting the heap memory. so I am putting a http request to a remote server,observing the httpresponse code to check internet. now the heap memory is stabilized and no more issue.

mobizt commented 4 years ago

Geat and thanks for inform me.