Home Automation using ESP32 & Firebase Realtime Database πŸ”₯ | App + Web + Manual Switch Sync

Home Automation using ESP32 & Firebase Realtime Database

Home Automation ESP32 Projects Embedded Systems Smart Home Firebase Projects Electronics Projects

App + Web + Manual Switch Sync (Complete Guide)

https://www.kincony.com/images/F16/ESP32-F16-1.jpg
https://i.sstatic.net/XikVI.png
https://europe1.discourse-cdn.com/arduino/original/4X/a/8/f/a8f2a32c3ebd9bb6ce239ca634f8a98edf9689d0.jpeg

5

πŸš€ Introduction

Aaj ke smart world me Home Automation ek luxury nahi, balki necessity banti ja rahi hai.
Is project me hum ESP32 + Firebase Realtime Database ka use karke ek complete smart home system banate hain jisme:

βœ… Mobile App se control
βœ… Web Dashboard se control
βœ… Physical Manual Switch se control
βœ… Sab kuch real-time sync me

Matlab chahe aap light mobile se ON karo, switch se OFF, ya website se control β€” har jagah same state reflect hogi πŸ”₯


🧠 System Overview (Kaise kaam karta hai?)

Is system ka core concept hai single source of truth β€” Firebase Realtime Database.

Flow:

Mobile App / Web / Manual Switch
            ↓
Firebase Realtime Database
            ↓
         ESP32
            ↓
          Relays

ESP32 hamesha Firebase ko listen karta rehta hai, aur jaise hi koi value change hoti hai, relay turant ON/OFF ho jata hai.


πŸ”© Hardware Components Required

https://cdn3.botland.store/110879-pdt_540/esp32-wifi-bt-42-platform-with-esp-wroom-32-module-compatible-with-esp32-devkit.jpg
https://esp32io.com/images/tutorial/esp32-4-channel-relay-module-wiring-diagram-2.jpg
https://global.discourse-cdn.com/smartthings/optimized/3X/f/1/f13cde27717c9388c64350af5b305af2c1442d69_2_1024x628.jpg

4

ComponentDescription
ESP32 Dev BoardMain controller
Relay Module (4/8 Channel)AC appliances control
Manual SwitchesPhysical ON/OFF
Bulb / Fan / SocketLoad
Power Supply5V / 12V
Connecting WiresJumper wires

πŸ’» Software & Tools Used

SoftwarePurpose
Arduino IDEESP32 programming
Firebase Realtime DBCloud sync
Android App / KodularMobile control
Web Dashboard (PHP/JS)Browser control

☁️ Firebase Realtime Database Structure

https://www.researchgate.net/publication/349745105/figure/fig10/AS%3A997382770663454%401614805991910/JSON-Structure-of-Firebase-Realtime-Database.ppm
https://www.researchgate.net/profile/Christian-Gyampomah-2/publication/349745105/figure/fig10/AS%3A997382770663454%401614805991910/JSON-Structure-of-Firebase-Realtime-Database_Q320.jpg
{
  "devices": {
    "device01": {
      "relay1": 0,
      "relay2": 1,
      "relay3": 0,
      "relay4": 1
    }
  }
}

πŸ‘‰ 0 = OFF
πŸ‘‰ 1 = ON

Yahi data App, Web aur ESP32 sab use karte hain.


πŸ”Œ Relay Pin Configuration (ESP32)

#define RELAY1 23
#define RELAY2 22
#define RELAY3 21
#define RELAY4 19

βš™οΈ ESP32 Complete Code (Firebase + Relay + Manual Switch Sync)

#include <WiFi.h>
#include <FirebaseESP32.h>

#define WIFI_SSID "YOUR_WIFI"
#define WIFI_PASS "YOUR_PASSWORD"

#define FIREBASE_HOST "your-project.firebaseio.com"
#define FIREBASE_AUTH "DATABASE_SECRET"

FirebaseData fbdo;

int relays[] = {23,22,21,19};
int switches[] = {32,33,25,26};

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

  WiFi.begin(WIFI_SSID, WIFI_PASS);
  while (WiFi.status() != WL_CONNECTED) delay(500);

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

  for(int i=0;i<4;i++){
    pinMode(relays[i], OUTPUT);
    pinMode(switches[i], INPUT_PULLUP);
  }
}

void loop() {

  for(int i=0;i<4;i++){
    if(Firebase.getInt(fbdo,"/devices/device01/relay"+String(i+1))){
      digitalWrite(relays[i], fbdo.intData());
    }

    if(digitalRead(switches[i])==LOW){
      Firebase.setInt(fbdo,"/devices/device01/relay"+String(i+1), !digitalRead(relays[i]));
      delay(300);
    }
  }
}

πŸ”₯ Is code ka fayda:

  • App se ON β†’ relay ON
  • Switch se OFF β†’ Firebase update
  • Web pe live status update

πŸ“± Mobile App Control (Kodular / Android)

Mobile app Firebase ke same path ko read/write karti hai.

Features:

  • Toggle buttons
  • Real-time update
  • Multiple devices support
  • Login based control

🌐 Web Dashboard Control

Web dashboard JavaScript + Firebase SDK use karta hai.

Web Features:

  • Browser se control
  • Live ON/OFF state
  • Admin panel ready
  • Multi-user support

πŸ” Manual Switch Sync (Most Important Feature πŸ”₯)

Normal home automation me issue hota hai:

Switch se OFF kiya β†’ App me still ON dikhata hai ❌

Is project me:
βœ… Switch press β†’ Firebase update
βœ… Firebase update β†’ App & Web sync
βœ… No mismatch ever


πŸ” Security Best Practices

  • Firebase rules enable karein
  • User-wise device access
  • Read/Write authentication

πŸš€ Future Enhancements

  • ⏱ Timer & Scheduler
  • πŸŽ™ Voice control (Alexa / Google)
  • πŸ“Š Energy monitoring
  • 🌍 Control from anywhere

🎯 Final Conclusion

Ye ESP32 + Firebase Home Automation System ek complete production-ready solution hai jo:

βœ” Real-time
βœ” Scalable
βœ” Secure
βœ” Beginner-friendly
βœ” Professional-grade

Agar aap Smart Home, IoT, ya Startup-level product banana chahte ho β€” ye system best base hai πŸ’ͺπŸ”₯

πŸ“ž 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


▢️ 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




🌟 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 |

Leave a Reply

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