You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 17, 2025. It is now read-only.
#include
#include
// Set these to run example.
#define FIREBASE_HOST "**"
#define FIREBASE_AUTH "***"
#define WIFI_SSID "***"
#define WIFI_PASSWORD "****"
#define UID "abc"
#define url "/users/abc/devices"
FirebaseArduino FirebaseStream;
void setup() {
Serial.begin(9600);
// connect to wifi.
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
Serial.print("Connecting to wifi");
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(500);
}
Serial.println();
Serial.print("connected: ");
Serial.println(WiFi.localIP());
FirebaseStream.begin(FIREBASE_HOST, FIREBASE_AUTH);
Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
FirebaseStream.stream(url);
}
int n;
void loop() {
Serial.println("loop");
Firebase.setInt("data", n++);
if (FirebaseStream.failed()) {
Serial.println("streaming error");
Serial.println(FirebaseStream.error());
}
if (FirebaseStream.available()) {
FirebaseObject event = FirebaseStream.readEvent();
String eventType = event.getString("type");
eventType.toLowerCase();
if (eventType == "put") {
// message = state ? "Device now is On": "Devive now is off";
JsonVariant json = event.getJsonVariant();
String path = json["path"].asString();
if (path != "/"){
// first loading seem it load all the devices. So we dont need it
Serial.println("");
json.printTo(Serial);
// if data: TRUE this mean device status change in this case we only take care when device status change.
Serial.println(event.getBool("data"));
String message = event.getBool("data") ? "Device is on now" : "Devive is off now";
Serial.println("Sending message to server.");
//Firebase.setString("message", "hello world");
delay(1000);
// If data: Null this mean device just deleted see screenshot: http://cloud.tabvn.com/rax3i8.png
// Else String or object (this could be adding new item or update device title ....
}
}
}
}
programe.txt

The text was updated successfully, but these errors were encountered: