Firebase Integrate With ESP8266

87,057

21

35

Introduction: Firebase Integrate With ESP8266

About: Embedded lover.

Make such
application in which LED can be control from mobile or website from any remote location where internet connectivity is available.

Requirement:

1 ) ESP8266-E12 WiFi module as shown in picture. You can get start and setup it with help of this post.

2) Download and install firebase-arduino-master library in Arduino IDE.

3) Need gmail account for create Firebase project.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Create Project on Firebase.

Go to firebase console and create new project

https://console.firebase.google.com/?pli=1

Step 2: Add Host Name to Arduino Sketch

Click on Database now you will see the host name show in image

Copy that host name and past in Arduino code given below at line
#define FIREBASE_HOST "fir-app-example.firebaseio.com"

Step 3: Add Database Secrete Key to Arduino Sketch

Go to Setting>Project Setting>SERVICE ACCOUNTS>DATABASE Secretes.
Copy "Database Secrets" Shown in above image.

Copy and paste Database Secrets at the line in code
#define FIREBASE_AUTH "examplesd2asdasdasdasd2asd3asd2asd2as32das3d2as2da3"

Step 4: Add Router Name and Password

Change line with your WiFi router name and password

#define WIFI_SSID "Wifi Router Name"
#define WIFI_PASSWORD "Router Password"

Step 5: Download Following Code in Arduino

#include
#include

// Set these to run example.

#define FIREBASE_HOST "fir-app-example.firebaseio.com"

#define FIREBASE_AUTH "examplesd2asdasdasdasd2asd3asd2asd2as32das3d2as2da3"

#define WIFI_SSID "Wifi Router Name"

#define WIFI_PASSWORD "Router Password"

#define LED 2

void setup() {

pinMode(LED,OUTPUT);

digitalWrite(LED,0);

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",0);

}

void loop() {

if(Firebase.getInt("LEDStatus"))

{

digitalWrite(LED,HIGH);

}

else

{

digitalWrite(LED,LOW);

}

if (Firebase.failed()) // Check for errors {

Serial.print("setting /number failed:");

Serial.println(Firebase.error());

return;

}

delay(1000);

}

Step 6: Restart ESP8266

After reseting ESP8266check serial terminal whether the ESP is get connected with your router and got IP adress.
Goto https://console.firebase.google.com/project/fir-app-9adb8/database/data you can now see the new variable created in database.

Step 7: Change Value of LEDStatus From Database

Double click "LEDStatus" and edit it to 1. instantly (its depends on your internet connection) LED on ESP 8266 module get Turn off.

Step 8: You Can Create Your Own App for Android

If you have knowledge of Android you can create App for control LED from mobile. You need to read Firebase documentation and integration methods.

I created my android app for controlling LED from mobile. As Firebase can be assess from world wide so you have end to end IoT application.

Be the First to Share

    Recommendations

    • LED Strip Speed Challenge

      LED Strip Speed Challenge
    • Sculpting Challenge

      Sculpting Challenge
    • Clocks Contest

      Clocks Contest

    35 Discussions

    0
    othmanmirizi3
    othmanmirizi3

    23 days ago

    sir if made my ESP8266 as an accesspoint how can i intergrated it with firebase?

    0
    FaizanM5
    FaizanM5

    Question 24 days ago on Step 3

    Hi ,Isnt the secret method deprecated as pointed out by firebase console ....is there any alternative to it as of now ?

    0
    Antutu
    Antutu

    9 months ago

    PROBLEM SOLVED!

    Firebase fingerprint has changed. Actual is B6 F5 80 C8 B1 DA 61 C1 07 9D 80 42 D8 A9 1F AF 9F C8 96 7D (updated to apr-2019). You have to edit the FirebaseHTTPClient.h file and include it in the sketch. Also include FirebaseObject.h and Arduino_JSON.h

    Cheers <3

    0
    ironman43
    ironman43

    Reply 2 months ago

    Angels Do exist !
    Thanks Bro

    0
    paynedeath
    paynedeath

    Reply 4 months ago

    You, sir, are a lifesaver

    0
    wilzzonb
    wilzzonb

    Reply 7 months ago

    it works thanks friend
    0
    Antutu
    Antutu

    Reply 9 months ago

    I have a Wemos D1 mini and this library is not compatible. Still having the same isue

    1
    MohanK117
    MohanK117

    Question 1 year ago

    This is not working... just check once and tell me plz... Arduino code is not connecting to Firebase

    1
    ismayilov1995
    ismayilov1995

    Question 1 year ago

    when I used

    #include <FirebaseArduino.h>

    this library I got this error:

    Error compiling for board NodeMCU 1.0 (ESP-12E Module).

    0
    MohammedA575
    MohammedA575

    Answer 1 year ago

    Remove current firebase library and install new one

    1
    mearyc
    mearyc

    Question 1 year ago on Step 5

    sorry i don't understand #include what??
    the two #include is empty
    and can i use esp8266-01 in this example ??

    0
    XiaomyR
    XiaomyR

    1 year ago

    I am using eps-01 that use SoftwareSerial
    how to change that code

    1
    parman josan
    parman josan

    2 years ago

    Hi,

    When I add #include <FirebaseArduino.h> lib then error comes

    Error compiling for board NodeMCU 1.0 (ESP-12E Module).

    I follow all above steps.

    0
    MohammedA575
    MohammedA575

    Reply 1 year ago

    Remove current firebase library and install new one

    0
    ismayilov1995
    ismayilov1995

    Reply 1 year ago

    I have same problem.

    0
    D.SUNDEEP
    D.SUNDEEP

    Reply 1 year ago

    yeah bro! same problem fa me ... say me the solution if u found

    0
    TamilT3
    TamilT3

    2 years ago on Step 5

    It shows constructor error

    0
    MohammedA575
    MohammedA575

    Reply 1 year ago

    problem because this line:
    if (Firebase.failed()) // Check for errors {
    the correct:
    if (Firebase.failed()) // Check for errors
    {
    or:
    if (Firebase.failed())
    {