1

I would like to connect via the esp8266 card to my firebase database. I tried to use the demo code that provides the firebase library for Arduino, but it does not work. I correctly enter my wi-fi data and I can establish a connection, but when I try to connect to the database the Arduino console I get the following error: setting/number failed:

enter image description here Code:

#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);
}

I would like to establish a connection with my firebase database.

6
  • Most likely you don't have permission to write to the database. By default on new databases only administrators can write. To change this, see stackoverflow.com/questions/37403747/firebase-permission-denied Commented Dec 28, 2018 at 15:41
  • @FrankvanPuffelen I've enabled both writing and reading the database: { "rules": { ".read": true, ".write": true } } Commented Dec 28, 2018 at 15:47
  • @FrankvanPuffelen the error persists the same, it is as if esp8266 can not connect to the db, but I have entered the data correctly several times even by modifying the database. I can not understand what the problem is. Commented Dec 28, 2018 at 15:49
  • Surely there's some way to check the connection status, maybe a return value for the connect method? Trying to write with no other checks means you'll have no idea what specifically is wrong if it doesn't work. The fact that your code is a sample shipped with the library doesn't change the fact that it's poorly thought through Commented Dec 29, 2018 at 18:26
  • ou could see if the const String &error()const method gives you anything interesting, allegedly it will give you an error message. But it's also possible that it does not, in which case the library is as bad as its example. Commented Dec 29, 2018 at 18:30

1 Answer 1

1

This can occur if the version of FirebaseArduino has an outdated fingerprint.

Check that the fingerprint in your installed FirebaseHttpClient.h corresponds to the current fingerprint.

See https://stackoverflow.com/a/54552554/1373856

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.