Close Menu
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
Facebook X (Twitter) Instagram
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us
Facebook X (Twitter) Instagram Pinterest YouTube LinkedIn
How To Electronics
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
How To Electronics
Home » Home Automation using Google Firebase & NodeMCU ESP8266
ESP8266 Projects IoT Projects

Home Automation using Google Firebase & NodeMCU ESP8266

Mamtaz AlamBy Mamtaz AlamUpdated:May 29, 202312 Comments6 Mins Read
Share Facebook Twitter LinkedIn Telegram Reddit WhatsApp
Home Automation Google Firebase
Share
Facebook Twitter LinkedIn Pinterest Email Reddit Telegram WhatsApp

Overview: Home Automation using Google Firebase & ESP8266

In this project, we will learn how to make IoT Based Home Automation Project using Google Firebase & NodeMCU ESP8266. One of the most common & popular hobby projects you will come across the internet is Home Automation Project. By Home Automation we mean controlling home appliances without a manual switch. When connected with the Internet, home devices are an important constituent of the Internet of Things (“IoT”) Application.

Earlier we learned about Home automation using Blynk Application, WebServer, Amazon Alexa & Arduino IoT cloud and also AWS IoT Core. But in this project we will use Google Firebase. Google Firebase is a Google-backed application development software used for creating, managing,and modifying data generated from any android/IOS application, web services, IoT sensors & Hardware. To learn more about the Google Firebase Console, you can read the official Google Firebase Documentation from Google Firebase

We will design a Home Automation Android Application using MIT APP Inventor. Using the Firebase Host & Authentication Key, we will connect the Android Application with Google Firebase. We will then send the ON/OFF command as 1/0 from App. The data from the App is sent to Google Firebase. Now the Google Firebase data is updated to NodeMCU Board via Internet Connection. Thus the digital GPIO Pins becomes high & low turning ON/OFF the appliances connected to Relay.




Bill of Materials

Following are the components required for making this project. All the components can be easily purchased from Amazon. The component purchase link is given below.

S.N.Components NameQuantityPurchase Links
1NodeMCU ESP82661Amazon | AliExpress
2Relay 5V4Amazon | AliExpress
37805 Voltage Regulator IC1Amazon | AliExpress
4Female DC Power Jack DCJ02021Amazon | AliExpress
5Diode 1N40074Amazon | AliExpress
6Resistor 330-ohm5Amazon | AliExpress
7NPN Transistor BC5474Amazon | AliExpress
8Terminal Block4Amazon | AliExpress
9LED 5mm Any Color1Amazon | AliExpress
10Female Header2 SetAmazon | AliExpress

Circuit Diagram & Connection

The circuit diagram for Google Firebase Based Home Automation using ESP8266 is given below. Using this circuit diagram you can assemble the circuit on Breadboard using 4 channel Relay and NodeMCU Board.

Home Automation using Google Firebase & NodeMCU ESP8266




Home Automation PCB Gerber File & PCB Ordering Online

If you don’t want to assemble the circuit on breadboard and you want PCB for the project, then here is the PCB for you. The PCB Board for the Home Automation Project is designed using EasyEDA online Circuit Schematics & PCB designing tool. The front side and back side of the PCB is given below.

Home Automation PCB Front View
Home Automation PCB Front View
Home Automation PCB Back View
Home Automation PCB Back View

The Gerber File for the PCB is given below. You can simply download the Gerber File and order the PCB from ALLPCB at 1$ only.

Download Gerber File: Home Automation PCB

You can use this Gerber file to order high quality PCB for this project. To do that visit the ALLPCB official website by clicking here: https://www.allpcb.com/.

You can now upload the Gerber File by choosing the Quote Now option. From these options, you can choose the Material Type, Dimensions, Quantity, Thickness, Solder Mask Color and other required parameters.

After filling all details, select your country and shipping method. Finally you can place the order.


Setting up Google Firebase Console Database

Now the main thing that we need to do is Setting up Google Firebase Console Database. Once the setup is done, we can then Send Real-Time Data from Android Application to Google Firebase.

But I won’t be explaining here how you can set up the Google Firebase Console Database because I have already explained the entire process in the previous tutorial. You can check the following tutorial to learn how to do the setup.

Getting Started with Google Firebase with ESP8266

You can also follow the Video Tutorial below to follow the Setup Work. Once the setup is done you will get the following window.

You need Firebase Host & Authentication Token. These both parameters are required in Arduino Code as well as Firebase App.



Designing & Setting Up Android Application

Now we need to design an Android Application that can send data to Google Firebase. The easiest way to design an Android Application is using MIT App Inventor. The MIT APP Inventor lets you develop applications for Android phones using a web browser and either the connected phone or emulator. The App Inventor servers store your work and help you keep track of your projects.

I have simply designed an Interface for Home Automation project using Google Firebase. The App has 4 pairs on ON/OFF Switch to Send the 0 and 1 command to Google Firebase.

Similarly the block editor which contains assignment and programming information is given below.

While designing the App, you need to enter the Firebase Host & Authentication Token in the App database. Follow the Video instruction below to do so.

Build/Compile the Application and export it to your Android Phone. You can install the APK file on your phone.

The .aia file for this app is given below. You can import this file to MIT App Inventor window and modify it by changing the Host & Token to the Database.

Download: Google Firebase Home Automation .aia File


Adding Firebase & JSON Library to Arduino IDE

1. ArduinoJSON Library

So first go to the library manager and search for “JSON” & install the library as shown in the figure below.

Note: The latest JSON library might not work with the code. So you may need to downgrade the library to version v5.13.5

2. Google FirebaseExtended Library

Now you need to install Google Firebase library as well. So, download the library from below link and add it to Library folder after extraction.

Download Google FirebaseExtended Library


Source Code: Home Automation using Google Firebase & ESP8266

After adding the Library to Arduino IDE you can upload the code to the NodeMCU Board.

1
2
3
4
#define FIREBASE_HOST "**********"           // Your Firebase Project URL
#define FIREBASE_AUTH "************"         // Your Firebase Database Secret
#define WIFI_SSID "**************"           // your WiFi SSID
#define WIFI_PASSWORD "********"             // your WiFi PASSWORD

But before uploading the code make changes to the WiFi SSID, Password, Firebase Host & Authentication Token.



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#include <ESP8266WiFi.h>
#include <FirebaseArduino.h>
#define FIREBASE_HOST "**********"           // Your Firebase Project URL
#define FIREBASE_AUTH "************"         // Your Firebase Database Secret
#define WIFI_SSID "**************"           // your WiFi SSID
#define WIFI_PASSWORD "********"             // your WiFi PASSWORD
 
#define Relay1 12 //D6
int value1;
 
#define Relay2 14 //D2
int value2;
 
#define Relay3 4  //D1
int value3;
 
#define Relay4 5 //D5
int value4;
 
void setup()
{
  Serial.begin(115200);              
  pinMode(Relay1,OUTPUT);
  pinMode(Relay2,OUTPUT);
  pinMode(Relay3,OUTPUT);
  pinMode(Relay4,OUTPUT);
 
  digitalWrite(Relay1,HIGH);
  digitalWrite(Relay2,HIGH);
  digitalWrite(Relay3,HIGH);
  digitalWrite(Relay4,HIGH);
 
  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.setInt("S1",0);        
  Firebase.setInt("S2",0);
  Firebase.setInt("S3",0);
  Firebase.setInt("S4",0);
  
}
 
 
void firebasereconnect()
{
  Serial.println("Trying to reconnect");
    Firebase.begin(FIREBASE_HOST);
  }
 
void loop()
{
  if (Firebase.failed())
      {
      Serial.print("setting number failed:");
      Serial.println(Firebase.error());
      firebasereconnect();
      return;
      }
      
  value1=Firebase.getString("S1").toInt();        //Reading the Status of Variable 1 from the firebase
  
  if(value1==1)                                            
     {
      digitalWrite(Relay1,LOW);
      Serial.println("Relay 1 ON");
    }
    else if(value1==0)                                    
    {                                      
      digitalWrite(Relay1,HIGH);
      Serial.println("Relay 1 OFF");
    }
 
  value2=Firebase.getString("S2").toInt();         //Reading the Status of Variable 2 from the firebase
  
  if(value2==1)                                                          
     {
      digitalWrite(Relay2,LOW);
      Serial.println("Relay 2 ON");
    }
    else if(value2==0)                                                  
    {                                      
      digitalWrite(Relay2,HIGH);
      Serial.println("Relay 2 OFF");
    }
 
   value3=Firebase.getString("S3").toInt();         //Reading the Status of Variable 3 from the firebase
  
  if(value3==1)                                                        
     {
      digitalWrite(Relay3,LOW);
      Serial.println("Relay 3 ON");
    }
    else if(value3==0)                                                    
    {                                      
      digitalWrite(Relay3,HIGH);
      Serial.println("Relay 3 OFF");
    }
 
   value4=Firebase.getString("S4").toInt();         //Reading the Status of Variable 4 from the firebase
  
  if(value4==1)                                                          
     {
      digitalWrite(Relay4,LOW);
      Serial.println("Relay 4 ON");
    }
    else if(value4==0)                                                    
    {                                      
      digitalWrite(Relay4,HIGH);
      Serial.println("Relay 4 OFF");
    }    
}


Home Automation using Google Firebase & ESP8266

Home Automation Google Firebase

After uploading the code the NodeMCU will connect to the WiFi Network. Using the Firebase Authentication Token & Host the Android App as well as Nodemcu Board connects to the Google Firebase.

Now you can send ON/OFF Command from Mobile Application to turn ON/OFF the home appliances.

Home Appliances control with Google Firebase


Video Tutorial & Guide

Home Automation with Google Firebase & ESP8266 | MIT App Inventor | Relay Appliances Control
Watch this video on YouTube.

Share. Facebook Twitter Pinterest LinkedIn Tumblr Email Reddit Telegram WhatsApp
Previous ArticleGetting Started with A9G Low Power GSM/GPRS+GPS Module with Arduino
Next Article GPS Tracker using A9G GPRS/GPS Module & Arduino

Related Posts

IoT Based PM & Air Quality Monitoring System using ESP32

IoT Based PM & Air Quality Monitoring System using ESP32

DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

Updated:May 10, 20261K
IoT Activity Tracker with ESP32 & Accelerometer Gyroscope

IoT Activity Tracker with ESP32 & Accelerometer/Gyroscope

Updated:May 2, 2026

ESP32 IoT Vehicle Motion Analyzer with MPU6050 & LIS3MDL

Updated:April 27, 20261K
High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

Updated:April 27, 20262K
DIY Colorimeter using AS7265x Spectroscopy Sensor & ESP32

DIY Colorimeter using AS7265x Spectroscopy Sensor & ESP32

Updated:February 1, 20261K
View 12 Comments

12 Comments

  1. bobeck on October 27, 2020 9:32 PM

    I have a very similar project at home but this one is dependent on an NTP server for the timer. It is set up to turn off/on lights by using relays also at a predetermined time of day and night. The only problem is after a power failure, the esp8266 gpio04 pin is reset to default state. Any idea how to prevent this in the software programming side, asside from privision of battery power supply. Thanks in advance.

    Reply
  2. Sisodiya Hardipsinh on February 25, 2021 1:46 PM

    Sir we used JSON 5.x library at place of JSON 6.x library. But it’s not working then what problem is there??

    Reply
  3. shubham on June 21, 2021 3:35 PM

    ‘WiFi’ was not declared in this scope

    please help

    Reply
  4. shubham on June 21, 2021 4:12 PM

    Trying to reconnect
    setting number failed

    my ESP8266 is not connecting please help

    Reply
  5. alahadtech on June 21, 2021 4:27 PM

    pls solve fingerprint problem

    Reply
  6. Sisodiya Hardipsinh on June 21, 2021 5:32 PM

    Bro there is some issues is this code.
    I have one updated code if you want then tell me i will give you.

    Reply
    • Tejaswi on July 13, 2021 8:28 AM

      I am getting error like “no matching function for call to ‘FirebaseESP8266::setInt(const char[3], int)
      if u have any code that is working fine, can you give it to me.

      Reply
      • Sisodiya Hardipsinh on July 13, 2021 10:03 AM

        [email protected] this is my mail id. mail me on this number i will send you my code

  7. Faisal Faris on November 17, 2021 8:03 PM

    I have sent an email to you

    Reply
  8. Hrutik Jadhav on April 27, 2022 2:44 PM

    have you got any solution for this issue???

    Reply
  9. Sisodiya Hardipsinh on April 27, 2022 8:57 PM

    Yaa i have one….

    Reply
  10. sajeed on September 23, 2022 1:41 PM

    please any one help me my code not connecting with firebase this same code

    Reply

CommentsCancel reply

Latest Posts
IoT Based PM & Air Quality Monitoring System using ESP32

IoT Based PM & Air Quality Monitoring System using ESP32

May 31, 2026
DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

May 10, 2026
IoT Activity Tracker with ESP32 & Accelerometer Gyroscope

IoT Activity Tracker with ESP32 & Accelerometer/Gyroscope

May 2, 2026
A Guide to Sourcing Obsolete ICs for Vintage Projects

Beyond AliExpress: A Guide to Sourcing Obsolete ICs for Vintage Projects

April 21, 2026

ESP32 IoT Vehicle Motion Analyzer with MPU6050 & LIS3MDL

April 27, 2026
Building a Smart Sensor Node with a BLE Microcontroller

Building a Smart Sensor Node with a BLE Microcontroller

February 26, 2026
High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

April 27, 2026
DIY Colorimeter using AS7265x Spectroscopy Sensor & ESP32

DIY Colorimeter using AS7265x Spectroscopy Sensor & ESP32

February 1, 2026
Top Posts & Pages
  • How to use INA219 DC Current Sensor Module with Arduino
    How to use INA219 DC Current Sensor Module with Arduino
  • 12V DC to 220V AC Inverter Circuit & PCB
    12V DC to 220V AC Inverter Circuit & PCB
  • Designing of MPPT Solar Charge Controller using Arduino
    Designing of MPPT Solar Charge Controller using Arduino
  • ECG Graph Monitoring with AD8232 ECG Sensor & Arduino
    ECG Graph Monitoring with AD8232 ECG Sensor & Arduino
  • How to use INA226 DC Current Sensor with Arduino
    How to use INA226 DC Current Sensor with Arduino
  • Buck Converter: Basics, Working, Design & Application
    Buck Converter: Basics, Working, Design & Application
  • How to use Modbus RTU with ESP32 to read Sensor Data
    How to use Modbus RTU with ESP32 to read Sensor Data
  • IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
    IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
Categories
  • Arduino Projects (197)
  • Articles (60)
    • Learn Electronics (19)
    • Product Review (15)
    • Tech Articles (28)
  • Electronics Circuits (46)
    • 555 Timer Projects (21)
    • Op-Amp Circuits (7)
    • Power Electronics (13)
  • IoT Projects (204)
    • ESP32 MicroPython (7)
    • ESP32 Projects (81)
    • ESP32-CAM Projects (15)
    • ESP8266 Projects (76)
    • LoRa/LoRaWAN Projects (22)
  • Microcontrollers (38)
    • AMB82-Mini IoT AI Camera (4)
    • BLE Projects (18)
    • STM32 Projects (19)
  • Raspberry Pi (93)
    • Raspberry Pi Pico Projects (57)
    • Raspberry Pi Pico W Projects (12)
    • Raspberry Pi Projects (24)
Follow Us
  • Facebook
  • Twitter
  • Pinterest
  • Instagram
  • YouTube
About Us

“‘How to Electronics’ is a vibrant community for electronics enthusiasts and professionals. We deliver latest insights in areas such as Embedded Systems, Power Electronics, AI, IoT, and Robotics. Our goal is to stimulate innovation and provide practical solutions for students, organizations, and industries. Join us to transform learning into a joyful journey of discovery and innovation.

Copyright © How To Electronics. All rights reserved.
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us

Type above and press Enter to search. Press Esc to cancel.

Ad Blocker Enabled!
Ad Blocker Enabled!
Looks like you're using an ad blocker. Please allow ads on our site. We rely on advertising to help fund our site.