Esp8266无法与Firebase连接-错误[设置/编号失败]

时间:2018-12-28 15:25:18

标签: firebase firebase-realtime-database iot esp8266 arduino-esp8266

我想通过esp8266卡连接到我的Firebase数据库。我尝试使用为Arduino提供firebase库的演示代码,但无法正常工作。我正确输入了wi-fi数据并可以建立连接,但是当我尝试连接到Arduino控制台的数据库时,出现以下错误:设置/编号失败:

enter image description here 代码:

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

// Set these to run example.
#define FIREBASE_HOST "-.firebaseio.com"
#define FIREBASE_AUTH "----"
#define WIFI_SSID "----"
#define WIFI_PASSWORD "----"

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

  // 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(FIREBASE_HOST, FIREBASE_AUTH);
}

int n = 0;

void loop() {
  // set value
  Firebase.setFloat("number", 42.0);
  // handle error
  if (Firebase.failed()) {
      Serial.print("setting /number failed:");
      Serial.println(Firebase.error());  
      return;
  }
  delay(1000);

  // update value
  Firebase.setFloat("number", 43.0);
  // handle error
  if (Firebase.failed()) {
      Serial.print("setting /number failed:");
      Serial.println(Firebase.error());  
      return;
  }
  delay(1000);

  // get value 
  Serial.print("number: ");
  Serial.println(Firebase.getFloat("number"));
  delay(1000);

  // remove value
  Firebase.remove("number");
  delay(1000);

  // set string value
  Firebase.setString("message", "hello world");
  // handle error
  if (Firebase.failed()) {
      Serial.print("setting /message failed:");
      Serial.println(Firebase.error());  
      return;
  }
  delay(1000);

  // set bool value
  Firebase.setBool("truth", false);
  // handle error
  if (Firebase.failed()) {
      Serial.print("setting /truth failed:");
      Serial.println(Firebase.error());  
      return;
  }
  delay(1000);

  // append a new value to /logs
  String name = Firebase.pushInt("logs", n++);
  // handle error
  if (Firebase.failed()) {
      Serial.print("pushing /logs failed:");
      Serial.println(Firebase.error());  
      return;
  }
  Serial.print("pushed: /logs/");
  Serial.println(name);
  delay(1000);
}

我想与我的Firebase数据库建立连接。

1 个答案:

答案 0 :(得分:0)

如果FirebaseArduino版本的指纹过时,则会发生这种情况。

检查已安装的FirebaseHttpClient.h中的指纹是否与当前指纹相对应。

请参见https://stackoverflow.com/a/54552554/1373856