Hi Guys I really need your help.
I make an app for monitoring purposes using ESP32 to get the data and send to firebase.
When ESP32 is not connect to internet (via WiFi), then data stored in firebase is the last value.
How to make a text of connection status in my app to notify user that device (ESP32) is offline.
I am very open if there is another strategy to notify the user if the device is offline.
As you want your application be able to know about the status of Arduino Wi-Fi module is connected to internet or not that if it is offline then the application must be having some kind of notification or that Wi-Fi module is offline.
You can have a another variable in your firebase database whenever the Wi-Fi module is not connected or Wi-Fi module is offline you can send it flag variable to firebase with the help of If Condition in your sketch and that variable/db column can be read from the app inventor application.
I mean to say,
If (WiFi.status() != WL_CONNECTED) send this status to firebase database, and read this value in app in some intervals to know about the status of ESP32 status.
Hello, whether it is not connected that it's not having Wi-Fi signal or it is not having power supply, in both cases it won't be able to to communicate. Please check with if-else logic, probably will work.
You can continuously on some specific interval send a Flag - wifi module live status to firebase, and due to any unforeseen events the module is down then firebase won't be able receive that status single, that you can check/utilise programmatically in your application.
I have generate the random value from ESP32 and send it to Firebase. When ESP32 is connect to internet, it will continuously generate random value. Otherwise. If ESP32 is not connect to internet, the random value will stop.
What I want to do is to use the random value as a ESP32 connection check.
Currently, I have not any idea with my block to set a text in my design to check the connection.
Need your help @RamNaresh
Instead of sending random numbers from board to firebase, it will be good to have a Flag, having timestamp, because if you are sending the random number to firebase and retrieving it from blocks, than with what reference value you will compare with. Since in case of no connection, than also you firebase column will also be holding some number.
It will make sense to have timestamp which is comparable at the application side to have some logical decision.
If the timestamp is older than the current time than defiantly the firebase data column is not updated with the new time-stamp which in turn can deciding facture that board is not connected.
So you need to have some corrective measures in your program.
Hi @RamNaresh thanks for your respon.
If you don't mind, I'd like to ask for a sample block regarding your analysis above. Because I'm new to MIT and don't really understand many functions.
Hello, Are you able to send the time stamp to firebase, you might have been using time Unix Time from your devise, that you can retrieve in app, once you get that you can convert to compare with the current time. That's my understanding.
and for the app inventor program How to do, please do some search for the existing similar problems might be it have been addressed already.
Seems to me you are complicating the behaviour of your system. If your embedded board sends a data record every N seconds (suppose N=3) your app reading the DB may check the time of the last data written if the difference between actual time and last data written time is higher than N means that the embedded board is offline. But in your case I would set the system in a different way. First of all I would set the system working offline and storing the data locally, then I would extend the system to publish the data online (and erasing some data locally to recover memory space) so that you will not loose any data, at worst the DB will be updated lately. The important thing is that the embedded board knows if it is online or not because it has to write the data and which data it has to write in the DB.