Home Automation with Timer & Manual Switch – Web + App Ready! πŸ”₯ Connect Your Own Firebase | No Code!

Home Automation with Timer & Manual Switch – Web + App Ready! πŸ”₯ Connect Your Own Firebase | No Code!

Home Automation ESP32 Projects Firebase Projects

Welcome to another exciting IoT project by YaranaIoT Guru β€” a complete home automation system with timer scheduling and manual switch control, fully integrated with a web interface and mobile app via Firebase.

This project is perfect for those who want smart control of home appliances without relying solely on voice commands. You can:

  • Turn appliances ON/OFF manually.
  • Schedule timers for devices to automatically switch on or off.
  • Control everything from a web dashboard or mobile app.
  • Connect multiple users or devices via Firebase Cloud Database.

With this setup, you don’t need coding experience for the web/app interface β€” it’s designed for easy plug-and-play control.


πŸ”Ή Why Build This Project?

Traditional home automation often depends on expensive hubs or proprietary apps. This project lets you:

  1. Control devices via manual switches at home.
  2. Use web or mobile apps connected to Firebase.
  3. Schedule devices for automatic operation using timers.
  4. Expand it for multiple appliances without additional cost.

It’s a complete IoT ecosystem for your smart home.


πŸ”Ή How It Works

  1. The NodeMCU / ESP8266 acts as the brain of the system.
  2. Device states (ON/OFF) are stored in Firebase Realtime Database.
  3. Manual push buttons connected to NodeMCU can toggle devices locally.
  4. The web interface or mobile app fetches device states from Firebase.
  5. Users can turn devices ON/OFF remotely or set timers.
  6. NodeMCU continuously reads Firebase values and updates the connected appliances.

This creates a fully synchronized smart home system with multiple control modes.


πŸ”Ή Features

βœ… Manual switch control for local operation
βœ… Timer-based automation for scheduled tasks
βœ… Web dashboard and mobile app control
βœ… Firebase Realtime Database integration
βœ… Works with multiple appliances
βœ… No coding required for web/app setup
βœ… Scalable, cost-effective, and beginner-friendly


πŸ”Ή Applications

  • Automated lighting control in homes
  • Smart fan scheduling
  • Garden or outdoor appliance timers
  • Classroom or lab appliance management
  • IoT learning projects and workshops

πŸ”Ή Tools & Platforms Used

  • Hardware: NodeMCU ESP8266, 4-channel relay, push buttons, jumper wires, breadboard
  • Software: Arduino IDE, Firebase, Web Browser, App Interface (HTML/JavaScript or prebuilt templates)
  • Programming: Arduino (C/C++)
  • Cloud Services: Firebase Realtime Database for remote control and data storage

In Part 2, we will cover all components, circuit diagram, and hardware connections, including how to connect manual switches, relays, and NodeMCU.

πŸ”Ή Components Required

ComponentQuantityDescription
NodeMCU ESP82661Wi-Fi microcontroller to control relays and communicate with Firebase
4-Channel Relay Module1Switches appliances ON/OFF safely
Push Buttons / Manual Switches2–4For local manual control of appliances
Jumper WiresAs requiredFor connections between NodeMCU, relays, and switches
Breadboard / PCB1To prototype circuit connections
Power Supply (5V/USB)1Powers NodeMCU and relay module
Appliances (Lights, Fans, LEDs)2–4Devices to control
Resistors (10KΞ©)2–4Pull-down resistors for push buttons

πŸ”Ή Circuit Diagram & Connections

The NodeMCU ESP8266 is the brain of this system. It connects to a relay module to control appliances and push buttons for manual operation.

Relay Connections:

NodeMCU PinRelay PinDevice Controlled
D1 (GPIO5)IN1Light 1
D2 (GPIO4)IN2Fan 1
D3 (GPIO0)IN3Appliance 3
D4 (GPIO2)IN4Appliance 4
VINVCCRelay Power
GNDGNDCommon Ground

Manual Switch Connections:

NodeMCU PinSwitchFunction
D5 (GPIO14)SW1Toggle Light 1
D6 (GPIO12)SW2Toggle Fan 1
Pull-down resistor10KΞ©Ensures stable LOW signal when switch is not pressed

Note: Connect each switch between the GPIO pin and 5V. The resistor connects between GPIO and GND to avoid floating input.


πŸ”Ή Working Principle

  1. Manual Switch Control:
    • When the push button is pressed, the corresponding GPIO pin detects a HIGH signal.
    • NodeMCU toggles the relay, turning the connected device ON or OFF.
  2. Timer Control via Firebase:
    • Users set ON/OFF times for each appliance in the Firebase Realtime Database.
    • NodeMCU reads these values and activates the relays automatically at the scheduled times.
  3. Web & App Control:
    • Any changes made on the web dashboard or mobile app are instantly updated to Firebase.
    • NodeMCU syncs with Firebase in real-time and adjusts appliance states accordingly.

πŸ”Ή Power Supply Notes

  • NodeMCU runs at 3.3V logic, but can accept 5V via USB or VIN pin.
  • Relay boards typically require 5V for operation.
  • Use a separate power source for larger loads to prevent voltage drops.

πŸ”Ή Safety Tips

⚠️ Important:

  • Always turn off AC power before wiring appliances to relays.
  • Use proper insulation for wires and connections.
  • For permanent installations, mount the circuit in a plastic or non-conductive enclosure.
  • Ensure relays are rated appropriately for the voltage and current of connected devices.

πŸ”Ή Final Hardware Setup

  • NodeMCU placed on breadboard.
  • Relays connected to D1–D4.
  • Push buttons connected to D5–D6 with pull-down resistors.
  • Appliances connected to relay outputs.
  • Power up the system β€” NodeMCU connects to Wi-Fi.

πŸ”Ή Step 1: Prepare Arduino IDE

Before writing code:

  1. Install Arduino IDE (latest version).
  2. Add ESP8266 Board Package:
    • Go to File β†’ Preferences β†’ Additional Board Manager URLs β†’ add http://arduino.esp8266.com/stable/package_esp8266com_index.json
    • Go to Tools β†’ Board β†’ Board Manager β†’ search ESP8266 β†’ Install
  3. Install the required libraries via Sketch β†’ Include Library β†’ Manage Libraries:
    • Firebase ESP8266
    • ArduinoJson

πŸ”Ή Step 2: Firebase Setup

  1. Go to https://console.firebase.google.com
  2. Create a new project β†’ e.g., β€œHomeAutomation”
  3. Click Realtime Database β†’ Create Database β†’ Start in Test Mode
  4. Note your Database URL (something like https://your-project.firebaseio.com/)
  5. Generate Web API Key from Project Settings β†’ General β†’ Web API Key

Firebase structure example:

HomeAutomation
 β”œβ”€ device1
 β”‚   └─ state : 0
 β”œβ”€ device2
 β”‚   └─ state : 0
 └─ timers
     β”œβ”€ device1_on : "08:00"
     β”œβ”€ device1_off : "20:00"
     └─ device2_on : "09:00"

state: 0 β†’ OFF, state: 1 β†’ ON


πŸ”Ή Step 3: Arduino Code

Here’s a working example code:

#include <ESP8266WiFi.h>
#include <FirebaseESP8266.h>

#define WIFI_SSID "YourWiFi"
#define WIFI_PASS "YourPassword"
#define FIREBASE_HOST "your-project.firebaseio.com"
#define FIREBASE_AUTH "Your_Firebase_Secret"

#define RELAY1 D1
#define RELAY2 D2
#define SWITCH1 D5
#define SWITCH2 D6

FirebaseData firebaseData;

void setup() {
  Serial.begin(115200);

  pinMode(RELAY1, OUTPUT);
  pinMode(RELAY2, OUTPUT);
  pinMode(SWITCH1, INPUT_PULLDOWN_16);
  pinMode(SWITCH2, INPUT_PULLDOWN_16);

  WiFi.begin(WIFI_SSID, WIFI_PASS);
  Serial.print("Connecting to WiFi");
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("Connected!");

  Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
  Firebase.reconnectWiFi(true);
}

void loop() {
  // Read manual switches
  if(digitalRead(SWITCH1) == HIGH) {
    digitalWrite(RELAY1, !digitalRead(RELAY1));
    Firebase.setInt(firebaseData, "/device1/state", digitalRead(RELAY1));
    delay(300);
  }
  if(digitalRead(SWITCH2) == HIGH) {
    digitalWrite(RELAY2, !digitalRead(RELAY2));
    Firebase.setInt(firebaseData, "/device2/state", digitalRead(RELAY2));
    delay(300);
  }

  // Read states from Firebase
  int state1 = Firebase.getInt(firebaseData, "/device1/state") ? 1 : 0;
  int state2 = Firebase.getInt(firebaseData, "/device2/state") ? 1 : 0;

  digitalWrite(RELAY1, state1);
  digitalWrite(RELAY2, state2);

  // Timer logic example (simple HH:MM check)
  String currentTime = getCurrentTime(); // implement NTP or RTC
  String device1On = Firebase.getString(firebaseData, "/timers/device1_on");
  String device1Off = Firebase.getString(firebaseData, "/timers/device1_off");

  if(currentTime == device1On) digitalWrite(RELAY1, HIGH);
  if(currentTime == device1Off) digitalWrite(RELAY1, LOW);

  delay(500);
}

// Optional: function to get current HH:MM from NTP
String getCurrentTime() {
  // Implement NTP time fetch
  return "08:00"; // placeholder
}

πŸ”Ή Step 4: Timer Setup

Timers are stored in Firebase in HH:MM format.

  • NodeMCU checks timers every second or minute.
  • When the current time matches a timer, it toggles the corresponding relay.
  • You can add multiple timers for multiple devices.

πŸ”Ή Step 5: Web & Mobile App Interface

  • You can use prebuilt templates like Firebase + HTML/JS dashboard.
  • Example features:
    • Toggle buttons for devices (ON/OFF)
    • Display current device state
    • Set timers through web interface
  • Firebase automatically syncs device states with NodeMCU, ensuring real-time control.

No coding required for the web dashboard β€” just link the HTML/JS app to your Firebase project.


πŸ”Ή Step 6: Testing the System

  1. Power up NodeMCU and connect it to Wi-Fi.
  2. Open your web dashboard or mobile app.
  3. Toggle devices ON/OFF β†’ relays should activate appliances instantly.
  4. Press manual switches β†’ relays toggle and Firebase updates automatically.
  5. Set timers β†’ NodeMCU will automatically turn devices ON/OFF at scheduled times.

πŸ”Ή 1. Multi-User and Multi-Device Support

One of the biggest advantages of using Firebase Realtime Database is multi-user synchronization:

  • Multiple users can control the same devices via mobile app or web dashboard.
  • Device states are updated in real-time across all clients.
  • Example: You and your family members can control lights or fans from different phones simultaneously.

Setup Tips:

  1. Add multiple user accounts in Firebase.
  2. Ensure proper read/write permissions for device control.
  3. Use authentication methods like email/password or Google Sign-In for security.

πŸ”Ή 2. Enhanced Timer Features

Timers make your automation truly smart. Some advanced functionalities include:

  • Multiple ON/OFF schedules per day for each device
  • Sunrise/Sunset-based control using NTP or local timezone
  • Randomized ON/OFF for security simulation when away from home
  • Timer override via manual switch or app β€” ensures flexibility

Example Firebase structure for multiple timers:

timers
 β”œβ”€ device1
 β”‚   β”œβ”€ on1 : "07:00"
 β”‚   β”œβ”€ off1 : "09:00"
 β”‚   β”œβ”€ on2 : "18:00"
 β”‚   └─ off2 : "22:00"

NodeMCU code checks the current time and toggles relays according to all timers.


πŸ”Ή 3. Manual Switch + App Hybrid Control

This project is designed to allow manual control without affecting cloud synchronization:

  • Manual switch toggles device locally.
  • NodeMCU updates Firebase to sync the state across all devices.
  • This hybrid control ensures reliability, even if Wi-Fi is temporarily down.

Code Concept:

if(digitalRead(SWITCH_PIN) == HIGH){
  digitalWrite(RELAY_PIN, !digitalRead(RELAY_PIN)); 
  Firebase.setInt(firebaseData, "/deviceX/state", digitalRead(RELAY_PIN));
  delay(300);
}

πŸ”Ή 4. Safety Tips for Home Automation

Safety is critical when controlling AC appliances:

  1. Use relays rated for the voltage and current of connected devices.
  2. Ensure proper insulation of wires and terminals.
  3. Keep NodeMCU and relay modules in a plastic enclosure.
  4. Use fuses or circuit breakers for protection against overload.
  5. Never touch live wires while the system is powered on.

πŸ”Ή 5. Web & App Improvements

The dashboard can be enhanced with:

  • Real-time device status indicators (green for ON, red for OFF)
  • Timer visualization (graphical schedule)
  • Notifications for device status changes
  • Access control for multiple users
  • Custom themes or device icons for better UX

You can use HTML + JavaScript, or a mobile app builder like MIT App Inventor, Kodular, or Flutter to create a no-code interface.


πŸ”Ή 6. Cloud Integration & Reliability

Firebase ensures your devices remain synchronized across multiple clients:

  • Real-time database updates allow instant control.
  • Supports offline caching β€” NodeMCU continues to operate locally if internet drops.
  • When Wi-Fi reconnects, Firebase syncs back the device states.

Optional upgrade: Integrate with IFTTT for custom triggers like:

  • Turning lights ON at sunset
  • Sending notifications when devices are activated
  • Controlling devices via Google Assistant routines

πŸ”Ή 7. Testing & Demonstration

Steps to ensure the system works perfectly:

  1. Connect NodeMCU to Wi-Fi β†’ confirm serial monitor shows connection.
  2. Test manual switches β†’ verify relay toggles and Firebase updates.
  3. Test web/app control β†’ devices respond in real-time.
  4. Test timer schedules β†’ NodeMCU turns devices ON/OFF automatically.
  5. Test multi-user control β†’ multiple devices or phones control appliances simultaneously.

βœ… Successful testing indicates your home automation system is ready for daily use.


πŸ”Ή 8. Future Upgrades

You can enhance this project with:

UpgradeDescription
ESP32 UpgradeFor faster processing, Bluetooth, and dual-core performance
Energy MonitoringAdd current sensors to track appliance usage
Voice Control IntegrationLink with Alexa or Google Assistant
Security AlertsSend notifications if devices are left ON accidentally
Mobile App CustomizationBuild fully branded apps for Android/iOS
IoT ExpansionAdd temperature, humidity, or motion sensors for automated routines

πŸ”Ή 9. Conclusion

This Home Automation with Timer & Manual Switch project demonstrates:

  • Hybrid control (manual + cloud)
  • Web and mobile integration via Firebase
  • Timer-based smart scheduling
  • Scalable and beginner-friendly IoT design

It’s perfect for anyone wanting a modern smart home solution without relying entirely on voice control or proprietary apps.

✨ By following this guide, you can control lights, fans, or appliances from anywhere, schedule routines, and implement safe hybrid automation for your home.


πŸ”Ή Key Takeaways

  • NodeMCU + Relay = Safe appliance control
  • Firebase = Cloud synchronization for web & app
  • Manual switches = Local fallback control
  • Timers = Automated daily scheduling
  • Multi-user = Flexible smart home access
  • Safety precautions = Prevent electrical hazards

πŸ“ž Contact YaranaIoT Guru Empowering IoT Innovation | ESP32 | Home Automation | Smart Solutions | 50K+ Community

We’d love to hear from you! Whether it’s IoT project queries, collaborations, tech support, custom PCB design, bulk orders, corporate training, college workshops, or freelance development β€” we’re just one message away.


βœ‰οΈ Email (Official)

For detailed inquiries, project support, business collaboration, sponsorships, or documentation: πŸ“© contact@yaranaiotguru.in πŸ“§ Alternate: support@yaranaiotguru.in ⏳ Response: Within 24 hours (Mon–Sat) πŸ’‘ Best for attachments (code, schematics, logs, etc.)


πŸ“± Phone / WhatsApp (24Γ—7 Support)

Instant live help, troubleshooting, project consultation, or order updates: πŸ“ž +91 70527 22734 πŸ’¬ WhatsApp: Chat Now ⏰ Call Hours: Mon–Sat, 10 AM – 7 PM IST πŸš€ Emergency? WhatsApp anytime β€” reply within 1 hour


🌐 Official Website

Tutorials, code, PDFs, schematics, blogs, free tools & online store: πŸ”— www.yaranaiotguru.in πŸ›’ Shop: yaranaiotguru.in/shop (ESP32 DevKits, Sensors, Relays, Custom PCBs, Project Kits)


▢️ YouTube Channel

Step-by-step IoT builds, live coding, ESP32, Blynk, Node-RED, MQTT, Home Assistant & more: πŸ”— Yarana IoT Guru πŸ“Ί 1,200+ Videos | 52K+ Subs | 5.5M+ Views | 4.8β˜… Rating πŸŽ₯ New Video Every Week β€” πŸ”” Subscribe & Turn On Notifications


πŸ›  GitHub (100% Open Source)

All codes, Arduino sketches, PlatformIO projects, Node-RED flows, MQTT configs & docs: πŸ”— github.com/YaranaIotGuru ⭐ 50+ Repos | 10K+ Stars & Forks

πŸ”₯ Top Projects:

  • ESP32 WebSocket Real-Time Dashboard
  • Smart Home with Blynk & Alexa
  • IoT Irrigation System with Soil Moisture
  • MQTT + Node-RED + MySQL Logging
  • OLED Weather Station with API

πŸ“Έ Instagram

Daily reels, quick tips, live builds, student showcases & giveaways: πŸ”— @YaranaIoTGuru πŸ“± 10K+ Followers | Reels | Stories | Live Sessions


πŸ’Ό LinkedIn (Professional Network)

B2B, IoT consulting, training, hiring & partnerships: πŸ”— Yarana IoT Guru

🀝 Services Offered:

  • Custom IoT Product Development
  • Embedded Systems Training
  • College Workshops & FDPs
  • PCB Design & Prototyping

🐦 Twitter / X

Real-time updates, polls, project launches & community Q&A: πŸ”— @YaranaIoTGuru πŸ“’ Follow for instant alerts


πŸ›  Hackster.io (Project Showcases)

In-depth write-ups, circuits, BOM, code & ratings: πŸ”— hackster.io/yaranaiotguru πŸ† 50+ Projects | 100K+ Views | Top 5% Creator


πŸ“ Instructables (DIY Guides)

Beginner-friendly step-by-step guides with templates & troubleshooting: πŸ”— instructables.com/member/YaranaIoTGuru

πŸ›  Featured Guides:

  • Automatic Plant Watering System
  • Voice-Controlled Home Appliances
  • WiFi-enabled Temperature Monitor

πŸ“š Medium Blog

Deep-dive articles, trends, tutorials & career tips in embedded systems: πŸ”— medium.com/@yaranaiotguru ✍️ 50+ Articles | 15K+ Readers


πŸ›’ Online Store & Kits

Ready-to-use IoT kits, custom PCBs, sensors & merch: πŸ”— yaranaiotguru.in/shop πŸ“¦ Free Shipping in India above β‚Ή999 πŸ’³ Payment: UPI, Card, Wallet, COD


🌟 Community Platforms

PlatformLinkPurpose
Telegram Channelt.me/YaranaIoTGuruProject files, PDFs, updates
Telegram Groupt.me/YaranaIoTCommunityPeer support, doubts
Discord Serverdiscord.gg/yarana-iotLive voice help, coding rooms
WhatsApp CommunityJoin HereAnnouncements & polls

🏒 Office & Studio Address

Yarana Studio & Software (Yarana IoT Guru HQ) πŸ“ Near Rookh Baba Mandir, Umariya Badal Urf Gainda, Allahabad (Prayagraj), Uttar Pradesh – 212507, India ⭐ Google Rating: 5.0 β˜… (100+ Reviews)

πŸ•’ Opening Hours: Mon–Sat: 10:00 AM – 5:00 PM Sunday: Closed

🌐 Associated Website: yaranawebtech.in πŸ—ΊοΈ View on Google Maps: Search “Yarana Studio & Software” πŸ“Œ Walk-ins welcome | Appointment recommended for project discussions

Leave a Reply

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