NodeMCU ESP8266 Google’s Firebase

NodeMCU ESP8266 with Firebase

There are like a ton of third-party online server and platforms available for showcasing the data of your IOT project. But, all of these platforms like ThingSpeak,Adafruit.io, Blynk and IFTT are not that reliable and are a bit laggy. So, the best solution for this is Google’s Firebase service that is super fast and data gets updated in real-time without any lag or delay. Also, it is easy to integrate with Esp8266 based project and can be implemented with MIT App Inventor so, that you can make your own IOT App for your projects. You get an opportunity to enhance your project with Google’s Assitance, Dialog flow and others too.

Here, NodeMCU ESP8266 with Firebase is an example project of sending the data from DHT11 (which is a humidity and temperature sensor ) to Google’s firebase and that data is then fetched by our customed IOT App build on MIT App Inventor. All the steps are easy to follow. If, you are a newbie in NodeMCU then watch “NodeMCU Crash Course” and then proceed further. In the next tutorial, we will make our own home automation system over the internet along with the custom app.

Components Required :

  1. NodeMCU Esp8266 12E ( or any esp based board)
  2. DHT11 Sensor
  3. Breadboard
  4. Few jumpers

Including the Libraries :

  1. Firebase Arduino Library: Go the following link and download the Zip file from the Github.
  2. Arduino JSON Library
  3. Include the library in Arduino IDE
  4. DHT11 Library: Follow the link to download the DHT11 library and include it to Arduino IDE
  5. Follow this, if you have not included ESP8266 board package in Arduino IDE or Otherwise Skip this :

Steps to Import ESP Board Libraries:

  1. In Arduino IDE, go to File–>Preference
  2. In the preference window under the ‘Additional Boards Manager URLs” field, paste this link: http://arduino.esp8266.com/stable/package_esp8266com_index.json
  3. Click on the Ok button.
  4. Go to ‘Tools and Board’, from the drop-down menu select ‘ Board Manager’.
  5. In the ‘Board Manager’ window, navigate to esp8266 by esp8266 community and select it.
  6. When you select the ESP8266 package then a ‘Install button’ will appear, click on it.

Remember that the file is around 160mb in size and will take some time to download.

  1. After Completion, you will be able to find the different boards of ESP series in Arduino IDE and Installation is complete.


Connections :

For Reference NodeMCU Pinout

Data pin of DHT11 is connected with D5 of NodeMCU esp8266.

nodemcu esp8266 dht11 connection

Setting up Google’s firebase 

  • Go to firebase.google.com and sign up with your email-ID
  • Next go to Console
  • Create a new project : Name the project and select your country.

firebase home automation

  • A dashboard appears click on : Database . Here, you will find your host url of the database that will be used in our code and also in our MIT App that we will be making, so copy it or note it down.

firebase console

  • Click on the Rules and set it as shown in the image below:

firebase rule

  • On the left-top side click on Project overview settings icon and navigate to find your project Secret Key and copy that. We will be needing while App Building.

Code Section :

#include <FirebaseArduino.h>
#include "DHT.h"

#include  <ESP8266WiFi.h>

#define FIREBASE_HOST "Your_HOst.firebaseio.com"
#define WIFI_SSID "YOur_Wifi_name" // Change the name of your WIFI
#define WIFI_PASSWORD "YOur_wifi_password" // Change the password of your WIFI

#define DHTPIN 14    // Data Pin of DHT 11 , for NodeMCU D5 GPIO no. is 14

#define DHTTYPE DHT11   // DHT 11

void setup() {

   while (WiFi.status() != WL_CONNECTED) {
  Serial.println ("");
  Serial.println ("WiFi Connected!");

void loop() {
  float h = dht.readHumidity();
  float t = dht.readTemperature();  // Reading temperature as Celsius (the default)
  Firebase.setFloat ("Temp",t);
  Firebase.setFloat ("Humidity",h);


Link for Code and Libraries: Download

Making our IOT Thermostat App :

Hope, you have enjoyed the session of sending the data to firebase.

Now, its time makes our own Internet of Things(IoT) Custom ed app that will fetch the data from our firebase server and update the results in real time to our App.

Go to MIT App Inventor: Create your project as shown in the image below, you can also directly import the .aia project file given at the end of this tutorial.



Making IOT Home Automation System


Link of the MIT App Inventor project file: Download

NodeMCU Pinout

Show More

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button