无法使用 esp32 从 firebase 获取正确的数据。每次我使用 get 函数时,串行监视器中的输出都是 0

Cannot get the correct data from firebase using esp32. Everytime I use get function, the output is 0 in serial monitor

Firebase

下面是代码。我应该得到输出为 1,但得到 0。我确信我的 firebase 详细信息是正确的,例如主机和身份验证,因为演示示例运行完美。

我正在将 esp32 与 Arduino IDE 1.8.12 一起使用。阿杜诺 Json 5.13.5

#include <IOXhop_FirebaseESP32.h>
#include <IOXhop_FirebaseESP32.h>

#include <WiFi.h>

#define FIREBASE_HOST "lab.firebaseio.com" // include the link of your firebase project
#define FIREBASE_AUTH "QWTbVwv"  // Include the authentication of your firebase project
#define WIFI_SSID "TAIM5_2.4Ghz"  // the name of the WiFi connection of your home or office
#define WIFI_PASSWORD "abc"  // password of the WiFi connection of your home or office 

int a;

void setup()
{
    Serial.begin(9600);
    delay(1000);

    WiFi.begin(WIFI_SSID, WIFI_PASSWORD); //try to connect with wifi

    Serial.print("Connecting to ");
    Serial.print(WIFI_SSID);

    while (WiFi.status() != WL_CONNECTED) {

        Serial.print(".");
        delay(500);
    }

    Serial.println();
    Serial.print("Connected to ");
    Serial.println(WIFI_SSID);
    Serial.print("IP Address is : ");
    Serial.println(WiFi.localIP()); //print local IP address

    Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH); // connect to firebase
}

void loop()
{
    a = (Firebase.getInt("fan/Fan"));

    if (Firebase.failed()) {
        Serial.println(Firebase.error());
    }
    else {
        Serial.println(a);
    }

    delay(1000);
}

我也尝试访问其他节点,但仍然得到 0。可能是什么问题?

I have tried to access other nodes also and still getting 0. What can be the problem?

难道你所有的值都是string而不是int

你试过了吗:

String str = Firebase.getString("fan/Fan");
//...
Serial.println(str);