Home automation using Arduino and relay modules is one of the most practical and affordable ways to turn your regular Indian household into a smart home. Whether you want to control lights, fans, geysers, or water pumps from your smartphone or set up automatic schedules, an Arduino-based home automation system can do it all — at a fraction of the cost of commercial smart home solutions like Alexa-enabled switches or Sonoff devices.
In this comprehensive guide, we will walk you through everything you need to know about building a home automation system with Arduino and relay modules, specifically designed for Indian 230V AC appliances.
- What Is Home Automation?
- Components Needed for Arduino Home Automation
- Understanding Relay Modules for AC Appliances
- Circuit Diagram and Wiring Guide
- Arduino Code for Relay Control
- Adding Bluetooth Control via Mobile App
- WiFi Control with ESP8266 Shield
- Safety Tips for 230V AC Wiring in India
- Frequently Asked Questions
- Conclusion
What Is Home Automation?
Home automation refers to the use of electronic devices and microcontrollers to automatically control household appliances such as lights, fans, air conditioners, geysers, and water pumps. Instead of manually flipping switches, you can use your smartphone, voice commands, or pre-set schedules to operate these appliances remotely.
For Indian homes, home automation is particularly useful because:
- Power saving: Automatically turn off appliances when not in use, reducing your electricity bill
- Convenience: Control lights and fans from your bed without getting up
- Safety: Monitor and control geysers and water pumps remotely to prevent damage
- Scheduling: Set timers for porch lights, garden pumps, and inverter switching
Arduino makes this possible at a cost of just ₹500–₹2,000, compared to ₹5,000–₹15,000 for commercial smart home kits.
Components Needed for Arduino Home Automation
Here is a complete list of components you will need to build a basic 4-appliance home automation system:
| Component | Quantity | Purpose |
|---|---|---|
| Arduino Uno | 1 | Main controller |
| 4-Channel 5V Relay Module | 1 | Switching AC appliances |
| HC-05 Bluetooth Module | 1 | Mobile phone control |
| Jumper Wires (M-F, M-M) | 20 | Connections |
| 5V Power Supply / USB Cable | 1 | Powering Arduino |
| Electrical Wires (1mm copper) | As needed | AC wiring |
| Switch Board / Junction Box | 1 | Housing the relay |
Understanding Relay Modules for AC Appliances
A relay is an electrically operated switch that allows a low-voltage circuit (5V from Arduino) to control a high-voltage circuit (230V AC mains in India). This is the key component that makes home automation possible — it acts as a bridge between your Arduino and your household wiring.
How a Relay Works
Each relay has three output terminals:
- COM (Common): Connect the live wire from your mains supply here
- NO (Normally Open): When the relay is activated, COM connects to NO — the appliance turns ON
- NC (Normally Closed): When the relay is de-activated, COM connects to NC — use this for fail-safe applications
The input side has:
- VCC: Connect to Arduino 5V
- GND: Connect to Arduino GND
- IN1, IN2, IN3, IN4: Signal pins connected to Arduino digital pins
Active Low vs Active High
Most relay modules available in India are active LOW, meaning the relay turns ON when the input pin receives a LOW (0V) signal. This is important to remember when writing your Arduino code — sending digitalWrite(pin, LOW) will activate the relay.
Circuit Diagram and Wiring Guide
Here is how to wire a 4-channel relay module with Arduino Uno to control 4 appliances:
Low-Voltage Side (Arduino to Relay Module)
Arduino Pin 2 → Relay IN1 (Light 1)
Arduino Pin 3 → Relay IN2 (Light 2)
Arduino Pin 4 → Relay IN3 (Fan)
Arduino Pin 5 → Relay IN4 (Geyser)
Arduino 5V → Relay VCC
Arduino GND → Relay GND
High-Voltage Side (230V AC Wiring)
Mains Live Wire → Relay COM terminal
Relay NO terminal → Appliance Live terminal
Mains Neutral Wire → Appliance Neutral terminal (direct, not through relay)
Important: Only the live (phase) wire goes through the relay. The neutral wire connects directly to the appliance. Never switch the neutral wire through a relay — this is a safety requirement as per Indian electrical standards.
Arduino Code for Relay Control
Here is the basic Arduino code to control 4 relays via serial commands. You can send commands like ‘1’, ‘2’, ‘3’, ‘4’ to toggle each appliance:
// Home Automation with 4-Channel Relay
// For Indian 230V AC appliances
#define RELAY1 2 // Light 1
#define RELAY2 3 // Light 2
#define RELAY3 4 // Fan
#define RELAY4 5 // Geyser
bool relayState[4] = {HIGH, HIGH, HIGH, HIGH}; // All OFF initially (active LOW)
void setup() {
Serial.begin(9600);
// Set relay pins as output
pinMode(RELAY1, OUTPUT);
pinMode(RELAY2, OUTPUT);
pinMode(RELAY3, OUTPUT);
pinMode(RELAY4, OUTPUT);
// Turn all relays OFF (active LOW, so HIGH = OFF)
digitalWrite(RELAY1, HIGH);
digitalWrite(RELAY2, HIGH);
digitalWrite(RELAY3, HIGH);
digitalWrite(RELAY4, HIGH);
Serial.println("Home Automation System Ready");
Serial.println("Send 1-4 to toggle appliances");
Serial.println("Send 'A' to turn all ON, 'B' to turn all OFF");
}
void loop() {
if (Serial.available() > 0) {
char command = Serial.read();
switch (command) {
case '1':
relayState[0] = !relayState[0];
digitalWrite(RELAY1, relayState[0]);
Serial.print("Light 1: ");
Serial.println(relayState[0] ? "OFF" : "ON");
break;
case '2':
relayState[1] = !relayState[1];
digitalWrite(RELAY2, relayState[1]);
Serial.print("Light 2: ");
Serial.println(relayState[1] ? "OFF" : "ON");
break;
case '3':
relayState[2] = !relayState[2];
digitalWrite(RELAY3, relayState[2]);
Serial.print("Fan: ");
Serial.println(relayState[2] ? "OFF" : "ON");
break;
case '4':
relayState[3] = !relayState[3];
digitalWrite(RELAY4, relayState[3]);
Serial.print("Geyser: ");
Serial.println(relayState[3] ? "OFF" : "ON");
break;
case 'A': // All ON
for (int i = 0; i < 4; i++) {
relayState[i] = LOW;
}
digitalWrite(RELAY1, LOW);
digitalWrite(RELAY2, LOW);
digitalWrite(RELAY3, LOW);
digitalWrite(RELAY4, LOW);
Serial.println("All appliances ON");
break;
case 'B': // All OFF
for (int i = 0; i < 4; i++) {
relayState[i] = HIGH;
}
digitalWrite(RELAY1, HIGH);
digitalWrite(RELAY2, HIGH);
digitalWrite(RELAY3, HIGH);
digitalWrite(RELAY4, HIGH);
Serial.println("All appliances OFF");
break;
}
}
}
Adding Bluetooth Control via Mobile App
To control your home automation system from your Android phone, add an HC-05 Bluetooth module. This lets you send commands wirelessly using apps like “Arduino Bluetooth Controller” or “Bluetooth Electronics” from the Play Store.
Wiring HC-05 to Arduino
HC-05 VCC → Arduino 5V
HC-05 GND → Arduino GND
HC-05 TX → Arduino Pin 10 (Software Serial RX)
HC-05 RX → Arduino Pin 11 (through voltage divider: 1kΩ + 2kΩ)
Note: The HC-05 RX pin operates at 3.3V logic. Use a voltage divider (1kΩ and 2kΩ resistors) to step down the Arduino’s 5V TX signal to approximately 3.3V.
Bluetooth-Enabled Code
#include <SoftwareSerial.h>
SoftwareSerial bluetooth(10, 11); // RX, TX
#define RELAY1 2
#define RELAY2 3
#define RELAY3 4
#define RELAY4 5
void setup() {
Serial.begin(9600);
bluetooth.begin(9600);
pinMode(RELAY1, OUTPUT);
pinMode(RELAY2, OUTPUT);
pinMode(RELAY3, OUTPUT);
pinMode(RELAY4, OUTPUT);
// All relays OFF
digitalWrite(RELAY1, HIGH);
digitalWrite(RELAY2, HIGH);
digitalWrite(RELAY3, HIGH);
digitalWrite(RELAY4, HIGH);
Serial.println("Bluetooth Home Automation Ready");
}
void loop() {
if (bluetooth.available() > 0) {
char command = bluetooth.read();
switch (command) {
case '1': digitalWrite(RELAY1, !digitalRead(RELAY1)); break;
case '2': digitalWrite(RELAY2, !digitalRead(RELAY2)); break;
case '3': digitalWrite(RELAY3, !digitalRead(RELAY3)); break;
case '4': digitalWrite(RELAY4, !digitalRead(RELAY4)); break;
case 'A': // All ON
digitalWrite(RELAY1, LOW);
digitalWrite(RELAY2, LOW);
digitalWrite(RELAY3, LOW);
digitalWrite(RELAY4, LOW);
break;
case 'B': // All OFF
digitalWrite(RELAY1, HIGH);
digitalWrite(RELAY2, HIGH);
digitalWrite(RELAY3, HIGH);
digitalWrite(RELAY4, HIGH);
break;
}
// Send status back
bluetooth.print("R1:");
bluetooth.print(digitalRead(RELAY1) ? "OFF" : "ON");
bluetooth.print(" R2:");
bluetooth.print(digitalRead(RELAY2) ? "OFF" : "ON");
bluetooth.print(" R3:");
bluetooth.print(digitalRead(RELAY3) ? "OFF" : "ON");
bluetooth.print(" R4:");
bluetooth.println(digitalRead(RELAY4) ? "OFF" : "ON");
}
}
WiFi Control with ESP8266 Shield
For internet-based control — where you can operate appliances from anywhere in the world — upgrade to WiFi using an ESP8266 module or, better yet, replace Arduino entirely with an ESP32 board that has built-in WiFi and Bluetooth.
With an ESP32, you can create a web server that hosts a control panel accessible from any device on your home network. You can also integrate with cloud platforms like Blynk, Google Home, or Home Assistant for advanced automation.
Simple ESP32 Web Server for Relay Control
#include <WiFi.h>
#include <WebServer.h>
const char* ssid = "Your_WiFi_Name";
const char* password = "Your_WiFi_Password";
WebServer server(80);
#define RELAY1 26
#define RELAY2 27
#define RELAY3 14
#define RELAY4 12
void setup() {
Serial.begin(115200);
pinMode(RELAY1, OUTPUT);
pinMode(RELAY2, OUTPUT);
pinMode(RELAY3, OUTPUT);
pinMode(RELAY4, OUTPUT);
// All OFF
digitalWrite(RELAY1, HIGH);
digitalWrite(RELAY2, HIGH);
digitalWrite(RELAY3, HIGH);
digitalWrite(RELAY4, HIGH);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.print("IP: ");
Serial.println(WiFi.localIP());
server.on("/", handleRoot);
server.on("/toggle", handleToggle);
server.begin();
}
void handleRoot() {
String html = "<html><head><meta name='viewport' content='width=device-width'>";
html += "<style>body{font-family:sans-serif;text-align:center;padding:20px;}";
html += ".btn{padding:15px 30px;margin:10px;font-size:18px;border-radius:8px;border:none;color:white;cursor:pointer;}";
html += ".on{background:#28a745;}.off{background:#dc3545;}</style></head><body>";
html += "<h1>Smart Home Control</h1>";
String labels[] = {"Light 1", "Light 2", "Fan", "Geyser"};
int pins[] = {RELAY1, RELAY2, RELAY3, RELAY4};
for (int i = 0; i = 1 && relay <= 4) {
digitalWrite(pins[relay-1], !digitalRead(pins[relay-1]));
}
server.sendHeader("Location", "/");
server.send(302);
}
void loop() {
server.handleClient();
}
Safety Tips for 230V AC Wiring in India
Working with mains electricity in India (230V AC, 50Hz) requires extra precautions. Here are essential safety guidelines:
- Always use MCBs (Miniature Circuit Breakers): Install an MCB before your relay setup. If a short circuit occurs, the MCB will trip and cut power instantly.
- Use optocoupler-isolated relay modules: These modules electrically separate the Arduino circuit from the 230V AC circuit, preventing damage to your microcontroller.
- Proper wire gauge: Use 1mm copper wire for lighting circuits and 1.5mm for power-intensive appliances like geysers and ACs.
- Enclose everything: Mount your relay module inside a proper electrical junction box. Never leave exposed 230V connections.
- Earth connection: Always ensure proper earthing for all metal-body appliances like geysers and washing machines.
- Monsoon precautions: If installing in outdoor or semi-outdoor locations (balcony, terrace), use IP65-rated enclosures to protect against moisture during the monsoon season.
- Label everything: Clearly label which relay controls which appliance for future maintenance.
- UPS/inverter compatibility: If your home has an inverter, connect essential loads (lights) through the inverter circuit and non-essential loads (geyser) through direct mains.
Frequently Asked Questions
Can I use Arduino to control a 230V geyser in India?
Yes, but you need a relay rated for the geyser’s current draw. A typical 3kW geyser draws about 13A at 230V. Use a 30A relay module for safety margin. The 4-channel 30A relay module is ideal for this purpose.
Is it safe to use relay modules with 230V AC?
Yes, when you use optocoupler-isolated relay modules and follow proper wiring practices. The optocoupler provides galvanic isolation between the low-voltage Arduino circuit and the high-voltage AC circuit. Always use relays rated for at least 10A at 250V AC for Indian households.
Can I control AC and DC appliances with the same relay?
Yes. The relay is simply a switch — it does not care whether the load is AC or DC. You can control 230V AC lights and 12V DC LED strips with the same relay module, just on different channels.
How many appliances can I control with one Arduino?
An Arduino Uno has 14 digital pins, so you can control up to 14 relays. However, for more than 8 relays, consider using a separate 5V power supply for the relay modules instead of powering them from the Arduino’s onboard regulator.
What happens to the relays during a power cut?
When power is restored, the Arduino reboots and the code sets all relays to their default state (OFF in our code). If you want relays to remember their last state, store the state in EEPROM and restore it during setup().
Can I add more than 4 channels later?
Absolutely. You can cascade multiple relay modules. Use a 4-channel and an 8-channel module together for 12 channels, or use an 8-channel relay module from the start if you plan to control many appliances.
Conclusion
Building a home automation system with Arduino and relay modules is one of the most rewarding DIY electronics projects you can undertake. For under ₹2,000, you get a fully functional smart home setup that can control lights, fans, geysers, and other appliances — either through Bluetooth from your phone or via WiFi from anywhere in the world.
The best part is that this system is endlessly expandable. Start with 4 channels and add more as you grow comfortable. Upgrade from Bluetooth to WiFi, add sensors for temperature and motion detection, and eventually integrate with platforms like Home Assistant or Google Home.
Ready to build your own smart home? Browse our complete range of relay modules, Arduino boards, and electronic components at Zbotic — India’s largest electronics component store with fast shipping across the country.
Add comment