FirebaseExtended / firebase-arduino

Arduino samples for Firebase.
Apache License 2.0
945 stars 494 forks source link

ESP8266 not connecting to firebase #416

Closed Asif54321 closed 4 years ago

Asif54321 commented 5 years ago

I've a problem connecting the ESP8266 board to Firebase (sketch is correct), but the board connects to the wi-fi, I've already updated the Arduino Json Library and i reinstalled the Firebase library, but nothing (2 months ago I had no problems with the connection).

Electric-90 commented 5 years ago

Are you using the latest Firebase library (i.e. the one with updated fingerprint) and also the ArduinoJson library (Release: 5.13.5), version 6 is not yet compatible.

Rommy157 commented 5 years ago

I do not update any version and it does not let me connect to the server or upload the data

henriQLima commented 5 years ago

Hi everyone, I had this same issue with my application a couple days ago and i figured out a way to solve it. Basically if we host this fingerprint somewhere else than in the hardware it will make things easier to change next time we had a fingerprint change. I am sending below my FirebaseHttpClient_Esp8266.cpp code where I've changed the FirebaseHttpClientEsp8266 class, I added some Serial.println to check the get request and also some string manipulation(because my-json-server.typicode adds some spaces and characters to the getString.

class FirebaseHttpClientEsp8266 : public FirebaseHttpClient {

public:
String fingerprint;
FirebaseHttpClientEsp8266() {
//first create a db.json in a github repo and use it at typicode.com
//this path will be pasted below in order to retrieve your fingerprint
//IT SHOULD BE HTTP, somehow http.begin does not work with HTTPS
http_.begin("https://my-json-server.typicode.com/<your-username>/<your-repo>");

int httpCode = http_.GET();
Serial.println(httpCode);
if (httpCode > 0) //== HTTP_CODE_OK)
//This code gets the fingerprint stored on an array at my-json-server.typicode.com and
//returns this array as a string, with some string manipulation we remove the array brackets and
//quotation marks ending with the fingerprint only.
Serial.println("--------------------");
fingerprint = http_.getString();
fingerprint.remove(0, 5);
fingerprint.remove(fingerprint.length() - 3);
Serial.println(fingerprint);
Serial.println("--------------------");
http_.end();
}

void setReuseConnection(bool reuse) override {
http_.setReuse(reuse);
http_.forceReuse(reuse);
}
void begin(const std::string& url) override {
http_.begin(url.c_str(), fingerprint);
}
void begin(const std::string& host, const std::string& path) override {
http_.begin(host.c_str(), kFirebasePort, path.c_str(), fingerprint);
}

Feel free to comment and add suggestions to this solution!! Cheers !@

rmaini10 commented 5 years ago

I have problem with Firebase connection. I could see it in debug level compilation with ssl+client http. it is saying connection not established or connection error(-1). See my code, it get connected to wifi but does not to the firebase. I have tried using other fingerprints also. Hasnt come up with any solution.

include

include

define WIFI_SSID "ssid"

define WIFI_PASSWORD "password"

//this firebase project was deleted //you'll need to enter your own firebase info

define FIREBASE_HOST "https://lightcontrol-7c940.firebaseio.com/"

define FIREBASE_AUTH "B03tpPBBF81hfRGhp9wyzMkL3jg7X1RcfAEihKnU"

int ledPower = 16;

void setup() { // put your setup code here, to run once: Serial.begin(9600);

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); Firebase.setInt("ledStatus",1); pinMode(ledPower, OUTPUT); }

void loop() { // put your main code here, to run repeatedly: // String status= Firebase.getString("ledStatus").toInt(); int status = Firebase.getString("ledStatus").toInt(); Serial.println(status); if(status == 1){ digitalWrite(16, HIGH); Serial.println("done"); } if(status == 0){ digitalWrite(16, LOW); Serial.println("hello"); }

// //set data: // //Firebase.set(ledStatus, "1"); }

buster95 commented 5 years ago

I have problem with Firebase connection. I could see it in debug level compilation with ssl+client http. it is saying connection not established or connection error(-1). See my code, it get connected to wifi but does not to the firebase. I have tried using other fingerprints also. Hasnt come up with any solution.

include

include

define WIFI_SSID "ssid"

define WIFI_PASSWORD "password"

//this firebase project was deleted //you'll need to enter your own firebase info

define FIREBASE_HOST "https://lightcontrol-7c940.firebaseio.com/"

define FIREBASE_AUTH "B03tpPBBF81hfRGhp9wyzMkL3jg7X1RcfAEihKnU"

int ledPower = 16;

void setup() { // put your setup code here, to run once: Serial.begin(9600);

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); Firebase.setInt("ledStatus",1); pinMode(ledPower, OUTPUT); }

void loop() { // put your main code here, to run repeatedly: // String status= Firebase.getString("ledStatus").toInt(); int status = Firebase.getString("ledStatus").toInt(); Serial.println(status); if(status == 1){ digitalWrite(16, HIGH); Serial.println("done"); } if(status == 0){ digitalWrite(16, LOW); Serial.println("hello"); }

// //set data: // //Firebase.set(ledStatus, "1"); }

I have problem with Firebase connection. I could see it in debug level compilation with ssl+client http. it is saying connection not established or connection error(-1). See my code, it get connected to wifi but does not to the firebase. I have tried using other fingerprints also. Hasnt come up with any solution.

include

include

define WIFI_SSID "ssid"

define WIFI_PASSWORD "password"

//this firebase project was deleted //you'll need to enter your own firebase info

define FIREBASE_HOST "https://lightcontrol-7c940.firebaseio.com/"

define FIREBASE_AUTH "B03tpPBBF81hfRGhp9wyzMkL3jg7X1RcfAEihKnU"

int ledPower = 16;

void setup() { // put your setup code here, to run once: Serial.begin(9600);

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); Firebase.setInt("ledStatus",1); pinMode(ledPower, OUTPUT); }

void loop() { // put your main code here, to run repeatedly: // String status= Firebase.getString("ledStatus").toInt(); int status = Firebase.getString("ledStatus").toInt(); Serial.println(status); if(status == 1){ digitalWrite(16, HIGH); Serial.println("done"); } if(status == 0){ digitalWrite(16, LOW); Serial.println("hello"); }

// //set data: // //Firebase.set(ledStatus, "1"); }

hey @rmaini10 in host only write lightcontrol-7c940.firebaseio.com without https://