HELP WANTED ! Stream started but not getting data from firebase
ayyysh04 opened this issue · 1 comments
Code:
#include <ESP8266WiFi.h>
#include <FirebaseESP8266.h>
#define FIREBASE_HOST "x-x-x"
#define FIREBASE_AUTH "x-x-x"
/*Define the WiFi credentials */
#define WIFI_SSID "WIFI_AP"
#define WIFI_PASSWORD "WIFI_PASSWORD"
FirebaseData firebaseData1;
String Path = "/Devices/Room1/Board1";
String ChildPath[2] = {"Switch1","Switch2"};
void setup()
{
Serial.begin(115200);
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
Serial.print("Connecting to Wi-Fi");
while (WiFi.status() != WL_CONNECTED)
{
Serial.print(".");
delay(300);
}
Serial.println();
Serial.print("Connected with IP: ");
Serial.println(WiFi.localIP());
Serial.println();
Firebase.begin(FIREBASE_HOST,FIREBASE_AUTH);
Firebase.reconnectWiFi(true);
if (!Firebase.beginStream(firebaseData1, Path))
{
Serial.println("Could not begin stream");
Serial.println("REASON: " + firebaseData1.errorReason());
Serial.println();
}
}
void loop()
{
if (!Firebase.readStream(firebaseData1))
{ Serial.println();
Serial.println("Can't read stream data");
Serial.println("REASON: " + firebaseData1.errorReason());
Serial.println();
}
else
Serial.println("Streaming....");
if (firebaseData1.streamTimeout())
{
Serial.println();
Serial.println("Stream timeout, resume streaming...");
Serial.println();
}
if (firebaseData1.streamAvailable())
{
if (firebaseData1.dataType() == "json")
{
FirebaseJson &json = firebaseData1.jsonObject();
for(int i=0;i<2;i++)
{
FirebaseJsonData jsondata;
json.get(jsondata,ChildPath[i]);
Serial.println(jsondata.stringValue);
}
}
}
else
Serial.println("No stream available");
}
Ca you tell why its not getting stream data??
You need to print the payload and check the type which can be any type.
Don't expect the type that you actually don't know it, you should to play with it using the console or any client to change the value and see what data type and event type received in all possible situations.
You should use the time to test for better understanding of Firebase RTDB before asking or open the issue here as you don't know what you should know as it's so easy to learning by doing.