Home Automation System With Your Own Application (android App)

by SenulD in Circuits > Gadgets

2411 Views, 39 Favorites, 0 Comments

Home Automation System With Your Own Application (android App)

20.04.2022_12.25.46_REC.png
photo1647505490.jpeg
20220317_134255.jpg
20211111_223712.jpg
20220317_135019.jpg

I was minded to make a home automation system since few months. So I made a system in last month.

It works with Internet. So I can control my system anywhere in the world with internet access.

To control this system I made my own mobile application ( Android application ) instead of using normal app like Blink.

In this tutorial I will explain how I made my home automation system.


Home automation System 

If we take hardware parts 

  • I used ESP32 dev module (This microcontroller will receive commands from our phone and operate the system)
  • relay system (This receive the signals from the microcontroller and working as a switch to operate the AC units)

These are the main parts and I used some I.E.Ds for testing and to get status.


Software,

I used MIT app inventor to make mobile application

For coding part on ESP32 I used Arduino application


In my project I want to send data from anywhere in the world to my system.

For that part I used popular Realtime data base called google firebase


Let's check what we need to make this project.

Supplies

photo1647602859.jpeg
photo1647602738.jpeg
photo1647603201.jpeg
Resistor-1K-Ohm-5.jpg

We need Some electronics and some softwares to this project.

  • ESP32 devkit v1 module (You can use any ESP32 module)
  • Relay module
  • Some LEDs (For testing)
  • 10K resistors
  • M to F jumping wires

Softwares,

Arduino application (To program ESP32 module.)

Mobile app (To control our system)

How It Works?..

Home auto mation system.drawio.png
How to make Home Automation System

Check the image. As image describes, First from the phone we sent data to the data base. Via internet. Then data base store data in cloud. It updates Realtime.

Then our esp32 takes the data from the database.

So simply we send commands from the phone and esp32 takes them then work according to it.!

Data Base

database-2.png

With this Realtime cloud-base database we can send data anywhere from the world if we have a internet connection.

So what this Data base do is It takes data that we send from the phone and store it on a cloud.


For that we use database called Google firebase

( Firebase is a platform developed by Google for creating mobile and web applications. It was originally an independent company founded in 2011. In 2014, Google acquired the platform and it is now their flagship offering for app development.)

Build a Data Base

How to make Home Automation System : Part 02
Screenshot_1.png
Screenshot_3.png
Screenshot_4.png
Screenshot_5.png
Screenshot_6.png
Screenshot_7.png
Screenshot_8.png
Screenshot_9.png
Screenshot_10.png
Screenshot_11.png
Screenshot_12.png
Screenshot_13.png
Screenshot_14.png
Screenshot_15.png
Screenshot_16.png
Screenshot_17.png
Screenshot_18.png
Screenshot_19.png
Screenshot_20.png
Screenshot_21.png
Screenshot_22.png
Screenshot_23.png

We need to create firebase project and need to create Realtime data base.

Here are the steps to create the database.

First, Log in to your google Account.

Open your browser, Search google firebase.

Click on their website.

Then go to console.

Make new project.

After create you a new project go to Realtime data base.

Then create a Realtime data base.

Copy your URL in database project and save it somewhere. We need that URL later.

Now go to project settings.

Then service accounts -> database secrets .

Copy your and save your Secret key. It also need us later.

Check the images. They explain how to do these all steps step by step.

Android Application

How to make Home Automation System : Part 03

So, Let's make our own App. I'll put a video that explains how to create mobile app to automation system.


Download it from here : App

Note : If you use this sample , Application is a saved file and you have to open Mit app invertor and open that file from it. Then you can change it as you want. After you add Url and Token build your app and use it.

After you installed the application Open the database and check if database is update live when you click the buttons.

If it is updating, we are good to go!.

Make the Circuit

digram_bb.png
20211111_223847.jpg
photo1647507355.jpeg
How to make Home Automation System : Part 04

Now we have database and App, all we need is the circuit. To build the circuit, find those circuit parts and bring them to on your table.

Check the diagram. Build it according to the diagram.

Note: You can connect relay power pins to whatever you want power supply. But note signal pins coming from the ESP32. So you need to make Common Ground. Connect the GND pin of relay to one of GND pin on sp32.

Few ELDs in the diagram are for testing.

Coding Part

Screenshot_24.png
Screenshot_25.png

So now we need to make a code to work our circuit according to our commands.

For that we should make a code that should be able to get data from the data base live and run the circuit according to that data.

First of all open the Arduino software.

Then select the board as ESP32 dev module.

And select the correct port.

Note : If you haven't work with ESP32 before there are some things should be done first, like prepare the software. For that there are many guides on the internet. So follow a how to get start with ESP32 tutorial and come back here.

And we need to install firebase library to Arduino software.

To do that go to Sketch -> manage libraries and search "Firebase ESP32 client" and install the library.

Code

Screenshot_1.png
Screenshot_4.png
Screenshot_5.png

Use this URL to get the code : Home Automation System

But I'll try to explain what I have done and what happen in the code. So you can make your own code or modify the code as you want.

Check the images.

Let's Run the System!

20220317_133838.jpg
20220317_134901.jpg

Now we have the App ,Database and the circuit.

So upload the code.

Get your phone and check if it is work. First check if the Inbuild led is working. If you done everything right, it should be working.

Congratulations!. We have finished our project.