Home Automation With Firebase + Android App + ESP8266 – 01

Introduction

In this project, we will learn how to make IoT Based Home Automation Project using Google FirebaseESP8266 – 01 & Atmega328p. By Home Automation we mean controlling home appliances like lights, fans, or anything with internet-connected relays.

This project is sponsored by PCBWay. PCB way offers all kinds of PCB prototyping and manufacturing services, including this FR-4 PCBs, rigid-flex PCBs, aluminum PCBs, PCBs with dozens of layers. PCBWay also offers turnkey PCB assembly services to assist you in populating your PCBs. Recently they have introduced Online Rapid Prototyping service which includes CNC machining, Sheet metal fabrication, 3D printing, Injection molding check them out on their website.

PCBWay

Earlier we learned about Home automation using Blynk ApplicationWebServer. 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.

Home Automation PCB using esp8266 and atmega328

We will also learn to design a Home Automation Android Application using Kodular.io. Using the Firebase Host & Authentication Key, we will connect the Android Application and ESP8266-01 with Google Firebase Realtime Database. So whenever we turn ON/OFF the switches from the App the changes will be updated in the Firebase Database and our ESP8266-01 will be able to read any changes in the Firebase Database then the data will be transmitted to Atmega328 via UART then Atmega328 will toggle the GPIO Pins thus turning ON/OFF the appliances connected to Relay.

Video

https://youtu.be/M8bYB2fkhoE

Hardware’s Required

Components Quantity DIY UsthaddiyusthadAliExpressali express
ESP8266 011cart icon
12v Relay4cart iconcart icon
Atmega328p1cart iconcart icon
LM78051cart icon
BC5474cart iconcart icon
1N40074cart icon
Capacitor 63v 10uF2cart icon
Capacitor 22pF2cart icon
Resistor kit (1k ,2.2k)cart icon
16 MHz Crystal1cart icon
Header pins (male &
female)
cart icon
LD33V1cart icon
LED4cart icon
Screw Terminal 1×34cart icon
Screw Terminal 1×21cart icon
PCB1cart icon
Home Automation PCB using esp8266 and atmega328
pcbway

Software & Libraries Needed

Setting up Firebase

Step 1: If you have Gmail id then you are already Sign Up for firebase. But if you don’t have Gmail id then first Sign Up for Gmail: https://gmail.com/

Step 2:Now visit https://firebase.google.com/ and click on Get started.

Step 3: Click on “Create a Project”.

Step 4:

  • Give a name for your project, in this case, I’m giving “HomeAutomation“.
  • Accept the firebase terms.
  • Click Continue.

Step 5: Disable google analytics we don’t need that now and click “Create project“.

Step 6: Wait for some time until the project is created and click the “Continue” button.

Step 7: Under the “Build” tap select “Realtime Database” and click on “Create database“.

Step 8: Click “Next“.

Step 9: Click on “Enable”

Step 10:

  • After the database is created, click on the “Rules” tab and and changes the rules as shown below (the read and write is changed to true from false)
  • Then click on “Publish“.

Step 11:Now click on “Project Settings“.

Step 12:

  • Click in “Service Accounts“.
  • Select “Database Secrets” and copy the secret and save it in a notepad we need it in the future.

Step 13: Also copy and save the project URL from “Realtime database“.

Android App Using Kodular.io

Kodular is the best way to make apps with a simple interface and simple code! There are so many components and options, and it has a beautiful Material Design. Kodular was baked from MIT App Inventor to make app coding easier.

pcbway

Step 1:

  • Download the project file from here.
  • Then go to create.kodular.io, signup if you don’t have an account already
  • Then click on Import project.

Step 2: Click on Choose File then select the downloaded project file and click Import

Step 3:

  • Now click on the Firebase_Database1 component.
  • Then under Firebase_Database1 Properties, paste the firebase database secret to Firebase token and project URL to Firebase URL fields.

Step 4: Now click on the Export tab and select Android App (.apk). Download the app and install in on your phone.

Block Code for Kodular or MIT App Inventor

You can refer the below block code if you are making your own application.

Programming

Code for Atmega328

Upload the below code to the ATmega328 microcontroller.

Code for ESP8266-01

Before uploading the code to ESP8266 you have to change the following

  • Paste your firebase host URL to the below code which we obtained earlier from our firebase database page
  • Paste your database secret to the ESP8266 code where it’s mentioned.
  • Also, add your WiFi SSID name and password in the code.
  • Now upload the code.

PCB Assembling & Testing

As you can see below we have completed the soldering of all the required components to our PCB. Now let’s insert the Atmega328 and ESP8266-01 in the slots provided and power it ON.

Home Automation PCB using esp8266 and atmega328
Home Automation PCB using esp8266 and atmega328

Buy This Project Kit

If you need to buy this PCB or the complete project kit you can visit our store www.diyusthad.store. If you need to print this PCB from PCBWay click here.

Leave a Comment

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