Smart Home Prototype Controlled by Smartphone With Reuse Waste Material

by lechampion17 in Circuits > Arduino

497 Views, 2 Favorites, 0 Comments

Smart Home Prototype Controlled by Smartphone With Reuse Waste Material

20210624_220307.jpg

In this tutorial, we will make the smart home’s prototypes, we will use the reused waste material.

This smart home can control the lighting, sprinkler (we use the Submersible Water Pump), and may know the weather conditions, like will it rain or not, and the function will automatically control the shield of the clothesline. We can access all of the functions above only with the smartphone. For the application on the smartphone, we will make it with Android Studio, using prototype ESP8266 with Arduino IDE, and the communications between prototype and application use the Firebase

Supplies

  • ESP8266
  • Battery 1,5V x 4
  • Submersible Water Pump DC 3V-5V
  • Servo Towerpro MG90s or MG996R

  • Rain Humidity Detection Sensor

  • LED 5mm

  • Relay Module 5V 1 Channel

  • Resistor 220 ohm

  • 9 Ice Cream Stick

  • 1 Cardboard Sheet

  • Glue and Masking tape

  • Clear Plastic Book Cover

Firebase

Screenshot (5186).png
  1. Go to Firebase
  2. Go to Console
  3. Add Project
  4. Enter your Project Name (example: smarthome)
  5. Continue until 3 step done
  6. Create Project

Make Firebase Realtime Database

Screenshot (5191).png
  1. Go to Realtime Database
  2. Create Database
  3. In Security Rules set "Start in Locked Mode" then click Enable

Change Rules Database

Screenshot (5193)_LI.jpg
  1. Go to Rules
  2. Set .read and .write to true
  3. Click Publish

Make Database Child

Screenshot (5195).png
  1. Go back to Data
  2. Click + to add Child
  3. Create 4 Child, named lamp with 0 value, pump with 0 value, servo with 0 value, and rain with “Dry” value

Make Smart Home Apps With Android Studio

You can download it from my GitHub

Connect Firebase to Android Studio

Screenshot (5325).png
Screenshot (5328).png
Screenshot (5329).png

  1. Go to Tools
  2. Click Firebase
  3. Choose Realtime Database
  4. Connect your app to Firebase
  5. Add the Realtime Database to your app

Connect Firebase to Android Studio Manually (if You Have Struggle to Connect Before)

Set Firebase Authentication in App

Firebase Host (1).png
  1. You can check your Firebase Host in Realtime Database
  2. Paste to String url = ""; in Pump.java, rain.java, and MainActivity.java

Upload to Your Smartphone

Screenshot (5314).png
  1. Connect Your Phone using USB
  2. Click Run, after your device was detected

Hardware Connectivity

Screenshot (4436).png

Rain Sensor:

  • AO --- AO
  • VCC --- 3V3
  • GND --- GND

Servo:

  • Orange --- Pin D4
  • Red --- 3V3
  • Black --- GND

LED:

  • + --- D1
  • - --- Resistor 220 Ohm

Resistor 220 Ohm --- GND

Relay

  • + --- 3V3
  • - --- GND

Relay (COM) --- RED Battery Cable

Relay (NO) --- RED Pump Cable

BLACK Pump Cable --- BLACK Battery Cable

Make Prototype

597010.jpg
597008.jpg
597009.jpg
597007.jpg
597005.jpg
597006.jpg
597012.jpg
  1. Make 4 holes at the corner of the cardboard
  2. Cut 2 ice cream’s stick into 2, and put it in to the corner of the cardboard
  3. Make 2 holes for the hanger
  4. Make 1 hole, and put in 1 ice cream’s stick that has been stick together with rain censor
  5. Cut the Clear Plastic Book Cover with arched shape
  6. Make 2 holes on the right & left sides for the hanger’s cover
  7. Put in 2 ice cream’s stick, then connect it with the glue that has been stick together with clear plastic book, cover the things that has been cut on the left sides
  8. Put in 2 ice cream’s stick, then stick the servo with masking tape together
  9. Then stick the ice cream’s stick together that has been glued with the right sides clear plastic book cover that has been cut and stick it together with servo

ESP8266 Program in Arduino IDE (add New Library)

Screenshot (5306).png
  1. Download FirebaseESP8266 Library
  2. Click Sketch
  3. Click Include Library
  4. Click Add .ZIP Library
  5. Choose Firebase-ESP8266-master.zip

ESP8266 Code

Downloads

FIREBASE HOST and FIREBASE AUTH

Firebase Host.png

You can check your Firebase Host in Realtime Database
You can check yout Firebase Auth:

  1. Go to Project Settings
  2. Click Service Accounts
  3. Click Database Secrects
  4. Click Show

Demo