Imagine flipping a light switch with your voice, setting the thermostat from your phone, and never worrying about a forgotten appliance again. All it takes is an Arduino, a few sensors, and a dash of curiosity.
How to Build a DIY Arduino Home Automation System
What You’ll Need
| Component | Qty | Typical Cost |
|---|---|---|
| Arduino Uno (or Nano) | 1 | $22 |
| Relay Module (5V) | 2 | $8 |
| DHT22 Temperature/Humidity Sensor | 1 | $5 |
| HC‑SR04 Ultrasonic Sensor | 1 | $3 |
| Breadboard & Jumper Wires | 1 | $7 |
| ESP8266 Wi‑Fi Module | 1 | $6 |
| Power Supply (5V 2A) | 1 | $10 |
ℹ️
NoteAll parts are available on major electronics retailers; consider buying a starter kit to save on shipping.
Step‑by‑Step Wiring
- Mount the Arduino on the breadboard and connect the 5V and GND rails.
- Wire each relay’s IN pin to digital pins D2 and D3; connect the relay COM to the appliance’s live wire and NO to the appliance’s neutral.
- Attach the DHT22 data pin to D4 and power it with 3.3V.
- Hook the HC‑SR04 trig to D5 and echo to D6.
- Plug the ESP8266 TX/RX to D7/D8 (use a voltage divider for TX).
"The best projects start simple—once you see the lights respond, you’ll want to add more sensors.
— Alex Rivera, Maker Community
Programming the Logic
Upload the sketch below. It reads temperature/humidity, detects motion with the ultrasonic sensor, and exposes a JSON endpoint over Wi‑Fi. Your phone or Home Assistant can call /control?relay=1&state=on to toggle lights.
✦
💡
TipSecure your relays behind a non‑conductive enclosure to avoid accidental shorts.
Testing & Expanding
- Open a browser at
http://arduino-ip/control?relay=1&state=1and watch the lamp turn on. - Add more relays for fans, door locks, or garden irrigation.
- Integrate MQTT for real‑time home‑assistant control.
"Automation is just a habit you program into your home.
— Mia Chen, IoT Enthusiast
Take Action
Grab the components, follow the wiring diagram, and fire up the code. Within an hour you’ll have a functional smart switch. Then, iterate: add voice commands, schedule routines, or build a dashboard. The only limit is your imagination.










