Today i will share you how to get started with your ESP8266 or esp-01 module & google firebase. We will do a simple demo to connect and set ESP-01 connection with firebase and we will also push values in firebase database using our ESP8266-01 module. Without having
 more say let’s get started: –

First let’s talk about the hardware requirement’s of course we will need an ESP8266 module and we will require some Jumper wires, USB to TTL, we will use a led just to have an indication of power supply.

Hardware Requirement:
=> ESP8266-01 Module
=>Jumper Wires
=>USB to Serial
=>L.E.D
 Connection Diagram:

ESP8266-01 Firebase Connection Diagram


Talking about the connections we will connect the CHPD and 3.3 V of the module to the 3.3 V of the USB to serial module then the RX pin of one device is connected to TX pin of other and TX pin of one is connected to RX of other and most importantly GPIO 01 of the esp module is connected to ground GND this is done because we need to burn programs for that it must be in programming mode. By default our esp module comes with AT firmware which breaks down
when we burn  program in esp module to upload A.T. firmware again i will share knowledge later.

Once you are done with your circuit connections you need to setup your arduino IDE. I already have an firebase account if you need help to set up an account you can see my previous Post Without wasting much of your time let me show you the values that are pushed in the firebase . Go to Firebase Demo here you will see software setup and configuration using this we will pump arbitrary values in our firebase use 1.6.9 library that has to be installed. Once this installation is done let me show you the code.
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);                       // wait for a second
  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);                       // wait for a second
}
You can see it is simple program of led blink for this i must have the led connected to GPIO 01 connected to GND of USB to serial so let’s just burn this code and if led blinks fine then our esp-01 is working fine. Go to the tools and be sure you are connected to the correct port and click on the upload button it may take a little time in compilation it will burn there after showing percentage of completion.


Let’s talk about how are the values pushed to firebase. Since we have installed the libraries of firebase you will see Firebase Arduino in the example dropdown in this you will click on -> Firebase demo:



























































































#include <ESP8266WiFi.h>
#include <FirebaseArduino.h>
// Set these to run example.
#define FIREBASE_HOST "example.firebaseio.com"
#define FIREBASE_AUTH "token_or_secret"
#define WIFI_SSID "SSID"
#define WIFI_PASSWORD "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);
}

and you will just to replace the firebase AUTH you will find these details in firebase itself in the project setting and firebase secrets now check the port from the Tools drop-down and click upload button, so this will burn our program. you may get a memory error which is very irritating you to resolve this I must tell you have to reset ESP using reset pin and attach it to ground or short them with another ground wire this will wash it off and you will burn the again now it will be successful. Now you can check logs in firebase database it will feature in yellow colour so that’s it for you learn if you face any issue you can get back to me and have look at the video

for details.

Categorized in: