How do I make a text of connection status in my app to notify user that device (ESP32) is offline?

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.

Thanks and have a nice day all

Firebase

1 Like

Welcome @Christosun_Billy_Bul,

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.

Thanks

1 Like

Hi @RamNaresh
Thanks for your advice. Really appreciate it.
I will try it and update to you

Thanks again

@RamNaresh how about if ESP32 is disconnected from power supply? Is above method can handle that situation?

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.

Thanks

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.

1 Like

Hi @RamNaresh thanks for advise.

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.
image

Currently, I have not any idea with my block to set a text in my design to check the connection.
Need your help @RamNaresh
block

Now, your question is to retrieve the values stored in firebase, you can get help from the link below

Thanks

1 Like

Please take a look at the analysis,

  1. 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.

  2. It will make sense to have timestamp which is comparable at the application side to have some logical decision.

  3. 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.

1 Like

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.

How to convert Unix Timestamp,

Thanks

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.

@RamNaresh thanks a lot
My app is work now. It can show a text of connection status using timestamp compare.

Thanks

Hi @mmanca thanks a lot..
It works. Now, I can check the connection status using time compare..
Thanks

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.