Say “Hey Google, turn off the lights” or “Fan on”—and watch your dorm room obey. No clunky apps, no monthly fees, just your voice controlling lights, fans, and even door locks with an ESP32 (Arduino-compatible board) and Google Home. This beginner-friendly project turns your messy student space into a futuristic smart room for under $50.instructables+1
Perfect for college students tired of fumbling for switches at 2 AM or roommates arguing over the thermostat. In this 1500-word guide, we’ll break down the components, wiring, step-by-step setup, code, and upgrades—including an IoT dashboard for remote peeks from class. Let’s hack your dorm!

Why Build a Voice-Controlled Dorm Room?
Dorm life sucks for smart tech: weak WiFi, no wiring skills required, and zero budget. Traditional smart bulbs cost $200+ and need hubs. Enter ESP32—a tiny $10 powerhouse with built-in WiFi, Bluetooth, and Arduino coding support. Pair it with Google Assistant (free via Google Home app), and you get:
- Voice commands anywhere in the room (or house).
- PIR motion sensors for auto-on lights when you stumble in.
- Relays to safely control 110V appliances like fans or lamps.
- IoT dashboard for phone checks: “Is my door locked?”
Students love it because: Instant gratification (works in 2 hours), shareable on TikTok (“My dorm is smarter than yours”), and scalable—add more rooms later.seeedstudio+1
Word count so far: ~220
Components List (Total ~$40-50)
| Component | Quantity | Price (approx) | Purpose |
|---|---|---|---|
| ESP32 DevKit V1 | 1 | $10 | Brain: WiFi, code runner |
| 5V Relay Module (2-4 channel) | 1 | $5 | Controls high-voltage lights/fans safely |
| PIR Motion Sensor (HC-SR501) | 1-2 | $3 each | Auto-detects you entering room |
| Solenoid Door Lock (12V) or Servo | 1 | $8 | Locks/unlocks door |
| Jumper Wires + Breadboard | 1 set | $5 | Prototyping |
| Power Supply (5V USB for ESP32) | 1 | $5 | Powers everything |
| Optional: DHT11 Temp Sensor | 1 | $2 | Monitors room climate |
Buy from Amazon, AliExpress, or local electronics shops. No soldering needed for starters—use breadboard.
Word count so far: ~380
Circuit Wiring: Simple Step-by-Step
Power off everything first. ESP32 uses 3.3V logic—don’t fry it with 5V!

Basic Relay for Lights/Fan
- Connect ESP32 GPIO 16 to Relay IN1 (for light).
- GPIO 17 to Relay IN2 (for fan).
- Relay VCC to ESP32 5V, GND to GND.
- Plug lamp/fan into relay’s NO (Normally Open) and COM terminals. (Relay acts like a remote switch.)
Add PIR Motion Sensor
- PIR VCC to ESP32 5V, GND to GND.
- PIR OUT to GPIO 13.
Logic: Motion detected → auto-turn light on for 5 mins.
Door Lock with Solenoid/Servo
- Solenoid via relay: GPIO 18 to another relay channel.
- Or servo direct: GPIO 18 to servo signal, VCC/GND to 5V/GND.
Full schematic: Imagine ESP32 center, relays fanned out to appliances, sensors feeding in. (Search “ESP32 relay PIR schematic” for diagrams.) Test with multimeter—continuity on relays when activated.
Safety tip: Relays isolate low-voltage ESP32 from 110V AC. Never bypass!
Word count so far: ~620
Software Setup: Arduino IDE + Google Assistant
Step 1: Prep Arduino IDE
- Download Arduino IDE (free).
- Add ESP32 board: File > Preferences > Additional Boards:
https://espressif.github.io/arduino-esp32/package_esp32_index.json - Tools > Board > ESP32 Dev Module.
- Install libraries: ESP32, ArduinoIoTCloud, Google Assistant (via Library Manager).
Step 2: Link to Arduino IoT Cloud (Free Bridge to Google)
- Sign up at cloud.arduino.cc (free account).
- Create “Thing”: Add variables like
lightRelay (bool),fanRelay (bool),motionDetected (bool). - Note Device ID, Secret Key—paste into code.
- Arduino IoT Cloud auto-generates dashboard: Sliders for relays, graphs for sensors.
Step 3: Connect Google Home
- In Google Home app: Add device > Works with Google > Search “Arduino”.
- Link your Arduino account.
- Expose switches: In Arduino Cloud dashboard, share
lightRelayas “Dorm Light”,fanRelayas “Dorm Fan”. - Say “Hey Google, sync devices.” Now voice commands work!
Word count so far: ~850
Sample Arduino Code (Copy-Paste Ready)
Upload this to ESP32. Replace YOUR_WIFI, YOUR_KEY, etc.
This code syncs voice commands to relays and auto-lights on motion. Customize delays/colors.
#include <ArduinoIoTCloud.h>
#include <Arduino_ConnectionHandler.h>
const char* ssid = "YOUR_WIFI";
const char* pass = "YOUR_PASS";
WiFiConnectionHandler ArduinoIoTPreferredConnection(WiFi);
bool lightRelay = false;
bool fanRelay = false;
bool motionDetected = false;
const int relayLight = 16;
const int relayFan = 17;
const int pirPin = 13;
void setup() {
pinMode(relayLight, OUTPUT);
pinMode(relayFan, OUTPUT);
pinMode(pirPin, INPUT);
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
setDebugMessageLevel(2);
ArduinoCloud.printDebugInfo();
}
void loop() {
ArduinoCloud.update();
// Control relays from cloud/Google
digitalWrite(relayLight, lightRelay ? LOW : HIGH); // Active low relay
digitalWrite(relayFan, fanRelay ? LOW : HIGH);
// Motion auto-light
if (digitalRead(pirPin) == HIGH) {
lightRelay = true; // Auto-on
motionDetected = true;
delay(5000); // 5 sec on
}
}
void onLightRelayChange() { /* Auto-called by cloud */ }
void onFanRelayChange() { /* Auto-called */ }
Test: Upload, open Serial Monitor (115200 baud). Say “Hey Google, turn on Dorm Light”—relay clicks!
Word count so far: ~1100
Voice Commands That Wow
- “Hey Google, turn Dorm Light on/off.”
- “Hey Google, set Dorm Fan to on.”
- “Hey Google, what’s the motion status?” (If you add voice feedback later.)
- Routines: “Good night” → lights off, fan low, door lock.
Pro tip: Google Home Mini ($30) makes it hands-free anywhere.[hackster]

IoT Dashboard: Monitor from Anywhere
Arduino Cloud gives a free web/phone dashboard:
- Toggle relays manually.
- Live graphs: Motion events, relay uptime.
- Notifications: “Motion detected at 2 AM!”
- Share link with roommates for group control.iotcircuithub+1
Upgrade: Add DHT11 on GPIO4 for temp/humidity graphs. Code snippet:
#include <DHT.h>
DHT dht(4, DHT11);
float temp, hum;
void loop() {
temp = dht.readTemperature();
humidity = dht.readHumidity();
// Cloud vars sync automatically
}
Word count so far: ~1280
Troubleshooting Common Issues
| Problem | Fix |
|---|---|
| Google won’t sync | Re-link Arduino in Google Home; check Thing is public |
| Relay not clicking | Check wiring, active-low logic (HIGH=off) |
| ESP32 won’t connect WiFi | Wrong SSID/pass; restart router |
| PIR false triggers | Adjust sensitivity pot; add 30s warmup |
| Door lock weak | Use 12V solenoid + external power |
Power cycle ESP32 after changes. Serial Monitor is your best friend.
Advanced Upgrades for Extra Virality
- Security Cam Add-On: ESP32-CAM ($10) streams door view to app on “Unlock” command.
- Offline Fallback: IR remote + buttons for no-WiFi days.
- Multi-Room: One ESP32 per room, central dashboard.
- Energy Tracker: Current sensor logs kWh usage—brag about savings.
- Voice Feedback: Speaker module replies “Lights on!”
- IFTTT Integration: “If raining → fan off” via weather API.
TikTok it: Film “Before: Dark dorm. After: Voice magic!”—goes viral easy.
Cost Breakdown & Scalability
| Feature | Add’l Cost |
|---|---|
| Basic (2 relays + PIR) | $25 |
| + Door Lock | +$10 |
| + Temp Sensor + Dashboard | Free (software) |
| Full Smart Dorm | $50 |
Scales to apartment: Add ESP32s, one Google account controls all.
This voice-controlled smart dorm project proves Arduino/ESP32 isn’t “pro only”—it’s dorm-room revolution. Build it, share your version (#SmartDormHack), and level up from student to mad scientist.