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

firebase with ESP8266 #310

Closed
ghost opened this issue Jan 2, 2018 · 38 comments
Closed

firebase with ESP8266 #310

ghost opened this issue Jan 2, 2018 · 38 comments
Labels

Comments

@ghost
Copy link

ghost commented Jan 2, 2018

Failed to read/write data to firebase.
``#include <ESP8266WiFi.h>
#include <FirebaseArduino.h>

// Set these to run example.
#define FIREBASE_HOST "esp8266-fbd9c.firebaseio.com/"
#define FIREBASE_AUTH "serect_key"
#define WIFI_SSID "SSID_name"
#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(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);
}``

Am using Arduino IDE 1.8.5
ESP8266MOD

@ghost ghost closed this as completed Jan 2, 2018
@ghost ghost reopened this Jan 2, 2018
@ghost ghost closed this as completed Jan 2, 2018
@ghost ghost reopened this Jan 2, 2018
@JuanPTM
Copy link

JuanPTM commented Jan 2, 2018

// Set these to run example.
#define FIREBASE_HOST "esp8266-fbd9c.firebaseio.com/"
#define FIREBASE_AUTH "serect_key"
#define WIFI_SSID "SSID_name"
#define WIFI_PASSWORD "password"

The firebase Host is wrong the correct way would be (w/o final slash):

#define FIREBASE_HOST "esp8266-fbd9c.firebaseio.com"

@ghost
Copy link
Author

ghost commented Jan 3, 2018

@JuanPTM
Even after removing final slash it failed.

@ghost
Copy link
Author

ghost commented Jan 3, 2018

how to create a firebase parent node?

@JuanPTM
Copy link

JuanPTM commented Jan 3, 2018

I think, your problem is still about configuration, because that is the example code.
It may be you are using the wrong secret for the connection.
You can check your secret following the next step:

  • Click on "Project Settings" of your firebase project.
  • Click on the Service Accounts tab
  • Click on Database Secrets
  • Hover over the non-displayed secret and click Show

As I said before, the example code is working on the ESP8266, at least until a week ago or so (I dont have an ESP8266 to prove it right now).

@proppy
Copy link
Contributor

proppy commented Jan 31, 2018

@JuanPTM Thanks for answering this question :) @ghost do you still have issue with the library?

@MandelbrotMan
Copy link

Im having the same issue as well. I found the secret key for the database but it says that its been deprecated and that the code needs to be updated with the firebase admin sdk. However the most obvious ways are only for android, ios, and web applications....

@bryan0805
Copy link

Does anyone show this error below and how to fix it

/Users/huifengchen/Documents/Arduino/libraries/firebase-arduino-master/src/FirebaseHttpClient_Esp8266.cpp: In member function 'virtual std::string FirebaseHttpClientEsp8266::errorToString(int)':
/Users/huifengchen/Documents/Arduino/libraries/firebase-arduino-master/src/FirebaseHttpClient_Esp8266.cpp:83:11: error: 'errorToString' is not a member of 'HTTPClient'
return HTTPClient::errorToString(error_code).c_str();

@Jackfr0zt
Copy link

Jackfr0zt commented Feb 12, 2018

@JuanPTM sir there is possible that there is a problem on circuit that's why it failed? can you help me? i have the same problem above.. im using arduino uno and esp-07.. i connect it to 3.3v in arduino pin to my esp.

@JuanPTM
Copy link

JuanPTM commented Feb 13, 2018

@Jackfr0zt sorry but i can't help you, I've never use an ESP with and Arduino UNO, just used a NodeMCU or WEMOS.

@johnandersen777
Copy link

Looks like Database Secrets is deprecated. Anyone know what is takes to use a non-deprecated method?
image

@trovaolerdo
Copy link

any updates on the firebase-arduino?

@heriveltogabriel
Copy link

I'm having the same problem, I downloaded it again, updated but it does not work.
Someone?

@MandelbrotMan
Copy link

MandelbrotMan commented Mar 14, 2018 via email

@nithin4541
Copy link

Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseHttpClient_Esp8266.cpp:83:11: error: 'errorToString' is not a member of 'HTTPClient'

return HTTPClient::errorToString(error_code).c_str();

this is error can u please help me with this

@SharanIoT
Copy link

SharanIoT commented Apr 17, 2018

@JuanPTM
I'm struggling to make the firebase example running on my Wemos D1 mini(esp8266). I always get setting read/write error. I tried everything that's available on the online forums with no luck. Are you sure that Google still allows to use the deprecated secret_key inside Database Secrets?

Any help would be a great help.

Thanks,
Sharan

@vivekaris
Copy link

I have successfully tested on Node MCU
I love to help anybody.

@kulwant96
Copy link

Just try to download your library again and upgrade your ide. Hope that ll work

@SharanIoT
Copy link

SharanIoT commented Apr 18, 2018

@vivekaris You tested recently? If yes, then Wemos D1 has problem with firebase?

@SharanIoT
Copy link

@kulwant96 I tried that many. Didn't help. I started doubting my Wemos board ability to support firebase.

@vivekaris
Copy link

As per my research most of 8266 code not compatible with wemos D1. Try is on node MCU .I will try to help.

@SharanIoT
Copy link

Folks,
FYI, finally I'm able to run the firebase samples successfully on Wemos D1 Mini. I think firebase library has a dependancy on arduinojson library. Once I included it, everything went smooth.

Thanks for your inputs.

@kotl
Copy link
Collaborator

kotl commented Apr 19, 2018

Never had any problems with D1 Mini, in fact it is the most used controller for me.

And FYI, this is in the main readme:

Dependencies
FirebaseArduino now depends on ArduinoJson library instead of containing it's own version of it. Please either use Library Manager or download specific version of the library from github.

@proppy
Copy link
Contributor

proppy commented Jun 15, 2018

Filed #349 to improve error messaging, I hope it can clear some of the issues reported here.

@proppy proppy closed this as completed Jun 15, 2018
@abodedaniel
Copy link

Failed to set data to firebase database, I am using Wemos Mini, and I have include ArduinoJson Library but it is still not working

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

// Set these to run example.
#define FIREBASE_HOST "waterlevel-ff5c0.firebaseio.com"
#define FIREBASE_AUTH "vnpv6YNyX3qOZWalKh5dgAHe69yZKrC1BAXXtkA4"
#define WIFI_SSID "Dan"
#define WIFI_PASSWORD "Danick007@ROSS"

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("MaxWaterLevel", 42.0);
// handle error
if (Firebase.failed()) {
Serial.print("setting /number failed:");
Serial.println(Firebase.error());
return;
}
delay(1000);
}

@herbeytech
Copy link

Please am having the same issue on my nodeMCU, any solution??

@ramakrishna5a1
Copy link

i am having the same problem any solution -thanks

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

// Set these to run example.
#define FIREBASE_HOST "xxxxxxxx.firebaseio.com"
#define FIREBASE_AUTH "5OJ4r2dGMESZP0juJDKPf4Ky51QDa39TzV8snS9K"

char* WIFI_SSID = "RK";
char* WIFI_PASSWORD = "m2tusu4fpyrk";

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

void loop()
{
// set value
Firebase.getInt("fir-demo-b1a3e/ram");

// handle error
if (Firebase.failed())
{
Serial.print("setting /number failed:");
Serial.println(Firebase.error());
return;
}
}

output:
setting /number failed:
setting /number failed:
setting /number failed:
setting /number failed:
setting /number failed:
setting /number failed:
setting /number failed:

@Kanagachidambaresan
Copy link

remove / from **.firebaseio.com/**. IT worked for me now

@ramakrishna5a1
Copy link

ramakrishna5a1 commented Nov 9, 2018

i am using Nodemcu and
I am still searching for solution but didn't get any.....
Please Post your code that will helpful to me.
Thanks.

@ramakrishna5a1
Copy link

I have successfully tested on Node MCU
I love to help anybody.

I am searching for solution till now but don't get any.....
Please Post your code that will helpful to me.
Thanks.

@stackblogger
Copy link

Its fixed!!!

go to C:/Users/{username}/My Documents/Arduino/libraries/firebase-arduino-master/src

open FirebaseHttpClient.h file, and paste following fingerprint =>

6F D0 9A 52 C0 E9 E4 CD A0 D3 02 A4 B7 A1 92 38 2D CA 2F 26

Now build and upload the sketch to NodeMCU using Arduino IDE

@ramakrishna5a1
Copy link

Its fixed!!!

go to C:/Users/{username}/My Documents/Arduino/libraries/firebase-arduino-master/src

open FirebaseHttpClient.h file, and paste following fingerprint =>

6F D0 9A 52 C0 E9 E4 CD A0 D3 02 A4 B7 A1 92 38 2D CA 2F 26

Now build and upload the sketch to NodeMCU using Arduino IDE

still the same situation repeating
can you please provide your code...
thanks

@stackblogger
Copy link

Its fixed!!!
go to C:/Users/{username}/My Documents/Arduino/libraries/firebase-arduino-master/src
open FirebaseHttpClient.h file, and paste following fingerprint =>
6F D0 9A 52 C0 E9 E4 CD A0 D3 02 A4 B7 A1 92 38 2D CA 2F 26
Now build and upload the sketch to NodeMCU using Arduino IDE

still the same situation repeating
can you please provide your code...
thanks

here is the code I am using-

#include <ESP8266WiFi.h>
#include<FirebaseArduino.h>
#define FIREBASE_HOST "test.firebaseio.com" //Your Firebase Project URL goes here without "http:" , "" and "/"
#define FIREBASE_AUTH "firebase_secret_key" //Your Firebase Database Secret goes here
#define WIFI_SSID "wifi_name" //your WiFi SSID for which yout NodeMCU connects
#define WIFI_PASSWORD "wifi_password"//Password of your wifi network

#define DEVICE1 D1
#define DEVICE2 D2
#define DEVICE3 D3
#define DEVICE4 D4
#define Device1Text "Device1"
#define Device2Text "Device2"
#define Device3Text "Device3"
#define Device4Text "Device4"

void setup() {
// put your setup code here, to run once:
Serial.begin(115200); //baud rate ,if you want to see the process in the serial monitor ,same baud rate should be set.
pinMode(DEVICE1,OUTPUT);
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);

if (Firebase.failed()) {
Serial.print("setting number failed:");
Serial.println(Firebase.error());
firebasereconnect();
return;
}
}
void firebasereconnect()
{
Serial.println("Trying to reconnect");
Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
}
int signal1;
int signal2;
int signal3;
int signal4;

void loop() {
if (Firebase.failed()) {
Serial.print("setting number failed:");
Serial.println(Firebase.error());
firebasereconnect();
return;
}
signal1=Firebase.getString(Device1Text).toInt();
if(signal1 == 1){
digitalWrite(DEVICE1,HIGH);
Serial.println("lightON");
}
else if(signal1 == 0){
digitalWrite(DEVICE1,LOW);
Serial.println("lightOFF");
}

signal2=Firebase.getString(Device2Text).toInt();
if(signal2 == 1){
digitalWrite(DEVICE2,HIGH);
Serial.println("lightON");
}
else if(signal2 == 0){
digitalWrite(DEVICE2,LOW);
Serial.println("lightOFF");
}

signal3=Firebase.getString(Device3Text).toInt();
if(signal3 == 1){
digitalWrite(DEVICE3,HIGH);
Serial.println("lightON");
}
else if(signal3 == 0){
digitalWrite(DEVICE3,LOW);
Serial.println("lightOFF");
}

signal4=Firebase.getString(Device4Text).toInt();
if(signal4 == 1){
digitalWrite(DEVICE4,HIGH);
Serial.println("lightON");
}
else if(signal4 == 0){
digitalWrite(DEVICE4,LOW);
Serial.println("lightOFF");
}
}

I am using 4 devices to control using Relay. And using NodeMCU 12E
Everything is working smoothly.

@vk1996
Copy link

vk1996 commented Dec 11, 2018

Its fixed!!!
go to C:/Users/{username}/My Documents/Arduino/libraries/firebase-arduino-master/src
open FirebaseHttpClient.h file, and paste following fingerprint =>
6F D0 9A 52 C0 E9 E4 CD A0 D3 02 A4 B7 A1 92 38 2D CA 2F 26
Now build and upload the sketch to NodeMCU using Arduino IDE

still the same situation repeating
can you please provide your code...
thanks

Add the below header files to your code
#include <FirebaseArduino.h>
#include <Firebase.h>
#include <FirebaseCloudMessaging.h>
#include <FirebaseError.h>
#include <FirebaseHttpClient.h>
#include <FirebaseObject.h>
#include <ESP8266WiFi.h>
followed by
go to C:/Users/{username}/My Documents/Arduino/libraries/firebase-arduino-master/src
open FirebaseHttpClient.h file, and paste following fingerprint =>
6F D0 9A 52 C0 E9 E4 CD A0 D3 02 A4 B7 A1 92 38 2D CA 2F 26
Now build and upload the sketch to NodeMCU or ESP01 using Arduino IDE.

This procedure works guaranteed with ESP01.

@ramakrishna5a1
Copy link

Its fixed!!!
go to C:/Users/{username}/My Documents/Arduino/libraries/firebase-arduino-master/src
open FirebaseHttpClient.h file, and paste following fingerprint =>
6F D0 9A 52 C0 E9 E4 CD A0 D3 02 A4 B7 A1 92 38 2D CA 2F 26
Now build and upload the sketch to NodeMCU using Arduino IDE

still the same situation repeating
can you please provide your code...
thanks

here is the code I am using-

#include <ESP8266WiFi.h>
#include<FirebaseArduino.h>
#define FIREBASE_HOST "test.firebaseio.com" //Your Firebase Project URL goes here without "http:" , "" and "/"
#define FIREBASE_AUTH "firebase_secret_key" //Your Firebase Database Secret goes here
#define WIFI_SSID "wifi_name" //your WiFi SSID for which yout NodeMCU connects
#define WIFI_PASSWORD "wifi_password"//Password of your wifi network

#define DEVICE1 D1
#define DEVICE2 D2
#define DEVICE3 D3
#define DEVICE4 D4
#define Device1Text "Device1"
#define Device2Text "Device2"
#define Device3Text "Device3"
#define Device4Text "Device4"

void setup() {
// put your setup code here, to run once:
Serial.begin(115200); //baud rate ,if you want to see the process in the serial monitor ,same baud rate should be set.
pinMode(DEVICE1,OUTPUT);
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);

if (Firebase.failed()) {
Serial.print("setting number failed:");
Serial.println(Firebase.error());
firebasereconnect();
return;
}
}
void firebasereconnect()
{
Serial.println("Trying to reconnect");
Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
}
int signal1;
int signal2;
int signal3;
int signal4;

void loop() {
if (Firebase.failed()) {
Serial.print("setting number failed:");
Serial.println(Firebase.error());
firebasereconnect();
return;
}
signal1=Firebase.getString(Device1Text).toInt();
if(signal1 == 1){
digitalWrite(DEVICE1,HIGH);
Serial.println("lightON");
}
else if(signal1 == 0){
digitalWrite(DEVICE1,LOW);
Serial.println("lightOFF");
}

signal2=Firebase.getString(Device2Text).toInt();
if(signal2 == 1){
digitalWrite(DEVICE2,HIGH);
Serial.println("lightON");
}
else if(signal2 == 0){
digitalWrite(DEVICE2,LOW);
Serial.println("lightOFF");
}

signal3=Firebase.getString(Device3Text).toInt();
if(signal3 == 1){
digitalWrite(DEVICE3,HIGH);
Serial.println("lightON");
}
else if(signal3 == 0){
digitalWrite(DEVICE3,LOW);
Serial.println("lightOFF");
}

signal4=Firebase.getString(Device4Text).toInt();
if(signal4 == 1){
digitalWrite(DEVICE4,HIGH);
Serial.println("lightON");
}
else if(signal4 == 0){
digitalWrite(DEVICE4,LOW);
Serial.println("lightOFF");
}
}

I am using 4 devices to control using Relay. And using NodeMCU 12E
Everything is working smoothly.

Thank you very much bro your code is very very very helpful to me......

@lakindu93
Copy link

Does anyone show this error below and how to fix it

/Users/huifengchen/Documents/Arduino/libraries/firebase-arduino-master/src/FirebaseHttpClient_Esp8266.cpp: In member function 'virtual std::string FirebaseHttpClientEsp8266::errorToString(int)':
/Users/huifengchen/Documents/Arduino/libraries/firebase-arduino-master/src/FirebaseHttpClient_Esp8266.cpp:83:11: error: 'errorToString' is not a member of 'HTTPClient'
return HTTPClient::errorToString(error_code).c_str();

Is anyone got a solution for this yet?

@khadeejaSalem
Copy link

Its fixed!!!
go to C:/Users/{username}/My Documents/Arduino/libraries/firebase-arduino-master/src
open FirebaseHttpClient.h file, and paste following fingerprint =>
6F D0 9A 52 C0 E9 E4 CD A0 D3 02 A4 B7 A1 92 38 2D CA 2F 26
Now build and upload the sketch to NodeMCU using Arduino IDE

still the same situation repeating
can you please provide your code...
thanks

Add the below header files to your code
#include <FirebaseArduino.h>
#include <Firebase.h>
#include <FirebaseCloudMessaging.h>
#include <FirebaseError.h>
#include <FirebaseHttpClient.h>
#include <FirebaseObject.h>
#include <ESP8266WiFi.h>
followed by
go to C:/Users/{username}/My Documents/Arduino/libraries/firebase-arduino-master/src
open FirebaseHttpClient.h file, and paste following fingerprint =>
6F D0 9A 52 C0 E9 E4 CD A0 D3 02 A4 B7 A1 92 38 2D CA 2F 26
Now build and upload the sketch to NodeMCU or ESP01 using Arduino IDE.

This procedure works guaranteed with ESP01.

#ifndef FIREBASE_HTTP_CLIENT_H
#define FIREBASE_HTTP_CLIENT_H

#include

#include "Arduino.h"
#include "Stream.h"

struct HttpStatus {
static const int TEMPORARY_REDIRECT = 307;
};

class FirebaseHttpClient {
public:
static FirebaseHttpClient* create();

virtual void setReuseConnection(bool reuse) = 0;
virtual void begin(const std::string& url) = 0;
virtual void begin(const std::string& host, const std::string& path) = 0;

virtual void end() = 0;

virtual void addHeader(const std::string& name, const std::string& value) = 0;
virtual void collectHeaders(const char* header_keys[],
const int header_key_count) = 0;
virtual std::string header(const std::string& name) = 0;

virtual int sendRequest(const std::string& method, const std::string& data) = 0;

virtual std::string getString() = 0;

virtual Stream* getStreamPtr() = 0;

virtual std::string errorToString(int error_code) = 0;

virtual bool connected() = 0;

protected:
static const uint16_t kFirebasePort = 443;
};

static const char kFirebaseFingerprint[] =
"6F D0 9A 52 C0 E9 E4 CD A0 D3 02 A4 B7 A1 92 38 2D CA 2F 26"; // 2019-04

#endif // FIREBASE_HTTP_CLIENT_H

I had replaced this row :
static const char kFirebaseFingerprint[] =
"B6 F5 80 C8 B1 DA 61 C1 07 9D 80 42 D8 A9 1F AF 9F C8 96 7D"; // 2019-04

with :
static const char kFirebaseFingerprint[] =
"6F D0 9A 52 C0 E9 E4 CD A0 D3 02 A4 B7 A1 92 38 2D CA 2F 26"; // 2019-04

is that what you mean ?

@khadeejaSalem
Copy link

Its fixed!!!
go to C:/Users/{username}/My Documents/Arduino/libraries/firebase-arduino-master/src
open FirebaseHttpClient.h file, and paste following fingerprint =>
6F D0 9A 52 C0 E9 E4 CD A0 D3 02 A4 B7 A1 92 38 2D CA 2F 26
Now build and upload the sketch to NodeMCU using Arduino IDE

still the same situation repeating
can you please provide your code...
thanks

here is the code I am using-
#include <ESP8266WiFi.h>
#include<FirebaseArduino.h>
#define FIREBASE_HOST "test.firebaseio.com" //Your Firebase Project URL goes here without "http:" , "" and "/"
#define FIREBASE_AUTH "firebase_secret_key" //Your Firebase Database Secret goes here
#define WIFI_SSID "wifi_name" //your WiFi SSID for which yout NodeMCU connects
#define WIFI_PASSWORD "wifi_password"//Password of your wifi network
#define DEVICE1 D1
#define DEVICE2 D2
#define DEVICE3 D3
#define DEVICE4 D4
#define Device1Text "Device1"
#define Device2Text "Device2"
#define Device3Text "Device3"
#define Device4Text "Device4"
void setup() {
// put your setup code here, to run once:
Serial.begin(115200); //baud rate ,if you want to see the process in the serial monitor ,same baud rate should be set.
pinMode(DEVICE1,OUTPUT);
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);
if (Firebase.failed()) {
Serial.print("setting number failed:");
Serial.println(Firebase.error());
firebasereconnect();
return;
}
}
void firebasereconnect()
{
Serial.println("Trying to reconnect");
Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
}
int signal1;
int signal2;
int signal3;
int signal4;
void loop() {
if (Firebase.failed()) {
Serial.print("setting number failed:");
Serial.println(Firebase.error());
firebasereconnect();
return;
}
signal1=Firebase.getString(Device1Text).toInt();
if(signal1 == 1){
digitalWrite(DEVICE1,HIGH);
Serial.println("lightON");
}
else if(signal1 == 0){
digitalWrite(DEVICE1,LOW);
Serial.println("lightOFF");
}
signal2=Firebase.getString(Device2Text).toInt();
if(signal2 == 1){
digitalWrite(DEVICE2,HIGH);
Serial.println("lightON");
}
else if(signal2 == 0){
digitalWrite(DEVICE2,LOW);
Serial.println("lightOFF");
}
signal3=Firebase.getString(Device3Text).toInt();
if(signal3 == 1){
digitalWrite(DEVICE3,HIGH);
Serial.println("lightON");
}
else if(signal3 == 0){
digitalWrite(DEVICE3,LOW);
Serial.println("lightOFF");
}
signal4=Firebase.getString(Device4Text).toInt();
if(signal4 == 1){
digitalWrite(DEVICE4,HIGH);
Serial.println("lightON");
}
else if(signal4 == 0){
digitalWrite(DEVICE4,LOW);
Serial.println("lightOFF");
}
}
I am using 4 devices to control using Relay. And using NodeMCU 12E
Everything is working smoothly.

Thank you very much bro your code is very very very helpful to me......

could you please til us what was the solution for the problem?

@ramakrishna5a1
Copy link

Change your firebase url in your source

Don't include http: in your source file of firebase url statement

Example:

#define FIREBASE_HOST "myfirebase-url.firebase.com";

Don't include http in url
Hope this helps

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests