LinkedRom
LinkedRom

Reputation: 175

How to know if ESP8266 is connected/disconnected in the Firebase in Android Application?

I have successfully connected my ESP8266 to Firebase and my Android Application in the Firebase as well. However, I want only to use the Android Application only if the ESP8266 is connected as well.

What happens is when only the Android App is connected in the Firebase, I can edit those values in the Firebase but it won't affect the ESP8266 since it isn't connected. I want a way to use only the Android App if the ESP8266 is connected in the Firebase so I'll know the data is delivered when the device is connected.

Upvotes: 1

Views: 428

Answers (1)

Pradeep
Pradeep

Reputation: 236

One way to do this is to implement a feedback based closed loop scheme. Once you edit a field in firebase, ESP8266 if reads the data successfully it has to update another field in DB as status, the change in status updates the app back which ensures the path is through. You can make this more efficient by updating the actual device status eg. If you are using a relay to power up a lamp, once the ON command is written to the firebase, NodMcu will read and switch on the output relay. An aux contact of relay to be connected back to NodMcu digital input so that it will become HIGH once the relay is picked up. This HIGH status can be updated to firebase as STATUS_ON which updates the app too.

Upvotes: 2

Related Questions