Skip to content
This repository was archived by the owner on Mar 17, 2025. It is now read-only.
This repository was archived by the owner on Mar 17, 2025. It is now read-only.

Firebase.readEvent() returns "type" instead "put" while getting data from Firebase #364

Closed
@navneetmaurya

Description

@navneetmaurya

Hi,

I am new in Arduino coding and trying to learn how to control Node MCU 1.0 ESP12E using Firebase DB data.
I am not able to get the "put" event type, from Firebase.readEvent(), using Deprecated DB Secret.
I am able to get the "Streaming Success" message.

Please let me know if I have to change anything, in below code.

below is my code:

#include <ESP8266HTTPClient.h>
#include <FirebaseArduino.h>
#include <ESP8266WiFi.h>

// Set these to run example.
#define WIFI_SSID "SSID"
#define WIFI_PASSWORD "Password"

void setup() {
Serial.begin(115200);

// connect to wifi.
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
Serial.print("connecting");
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(500);
}
Serial.println();
Serial.print("connected: ");
Serial.println(WiFi.localIP());

Firebase.begin("xxxxxxxx.firebaseio.com", "xxxxxxxxxx");
Firebase.stream("/automation");
if (Firebase.success()) {
Serial.println("Streaming success"); //I am able to get the Success
}
}
void loop() {
if (Firebase.failed()) {
Serial.println("streaming error");
Serial.println(Firebase.error());
}

if (Firebase.available()) {
FirebaseObject event = Firebase.readEvent();
String eventType = event.getString("type");
eventType.toLowerCase();

 Serial.print("event: ");
 Serial.println(eventType);   // this return "type" instead of "put"
 if (eventType == "put") {     //If I write "type" instead" "put" then path is "/" and No data was returned.
   Serial.print("data: ");
   Serial.println(event.getString("data"));
   String path = event.getString("path");
   Serial.println(path);
   String data = event.getString("data");       
 }

}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions