Smart Room — Build Guide

This page shows how I built: the Auto Bin, the Toilet Flusher (same mechanism), and the Smart Light. All builds are Arduino-based and designed to be simple, cheap and easy to reproduce.

Overview — what I used (quick)

1) Auto Bin (servo + spoon + ultrasonic + voice)

Parts: Servo, HC-SR04, Arduino, small spoon (or thin strip), DFPlayer Mini + microSD + small speaker (or just a passive speaker), power supply (5V), wires.

How it works (short)

When the ultrasonic detects a hand/object within a set distance (e.g. < 20 cm), the Arduino rotates the servo which swings the spoon to press the bin lid (or push a latch). Optionally play a short sound using the DFPlayer Mini.

Mechanical tip — spoon mechanism

Wiring (Bin)

HC-SR04:
  Vcc -> 5V
  GND -> GND
  Trig -> Arduino pin 7
  Echo -> Arduino pin 6

Servo:
  Vcc -> 5V (prefer separate 5V regulator or use 5V power bank)
  GND -> GND (common ground!)
  Signal -> Arduino pin 5

DFPlayer Mini (optional voice):
  Vcc -> 5V
  GND -> GND
  TX  -> Arduino RX via SoftwareSerial pin 10
  RX  -> Arduino TX via SoftwareSerial pin 11
Speaker -> DFPlayer speaker pins
    

Power note: Servos draw spikes when moving — don't power them directly from Arduino if using heavy loads. Use a dedicated 5V supply (power bank, 5V regulator) and connect grounds together.

Arduino sketch — auto bin with DFPlayer voice

This sketch uses the DFRobotDFPlayerMini library (install via Library Manager) and SoftwareSerial. If you don't use DFPlayer, ignore the DFPlayer parts.

// AutoBin: ultrasonic -> servo, optional DFPlayer voice
#include <Servo.h>
#include <SoftwareSerial.h>
#include "DFRobotDFPlayerMini.h"

Servo binServo;
const int trigPin = 7;
const int echoPin = 6;
const int servoPin = 5;
const int triggerDistance = 20; // cm
unsigned long lastTrigger = 0;
const unsigned long triggerCooldown = 2500; // ms

// DFPlayer (optional)
SoftwareSerial dfSerial(10, 11); // RX, TX (to DFPlayer)
DFRobotDFPlayerMini dfplayer;
bool useDFPlayer = true;

void setup() {
  Serial.begin(9600);
  binServo.attach(servoPin);
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  binServo.write(10); // rest angle
  // init DFPlayer
  if (useDFPlayer) {
    dfSerial.begin(9600);
    if (!dfplayer.begin(dfSerial)) {
      Serial.println("DFPlayer not found");
      useDFPlayer = false;
    } else {
      dfplayer.volume(20); // 0..30
    }
  }
}

long readDistanceCm() {
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  long duration = pulseIn(echoPin, HIGH, 30000);
  long dist = duration * 0.034 / 2;
  return dist;
}

void openBin() {
  // play sound if available
  if (useDFPlayer) dfplayer.play(1); // file 0001.mp3 on microSD
  binServo.write(75); // adjust to your mech
  delay(700);
  binServo.write(12); // back to rest
}

void loop() {
  long d = readDistanceCm();
  if (d > 0 && d < triggerDistance) {
    if (millis() - lastTrigger > triggerCooldown) {
      lastTrigger = millis();
      openBin();
    }
  }
  delay(120);
}
    

Put an mp3 named 0001.mp3 on the root of the microSD for DFPlayer to play track 1. If you prefer voice TTS, skip DFPlayer and use a phone + HC-05 to send a signal to Arduino to play an action.

2) Toilet Flusher — same mechanism

I reused the exact same servo+spoon approach for the toilet flusher. Mount the spoon or small lever to push the flush lever, calibrate angles, and protect the servo from splashes (use a small enclosure or waterproof the area).

3) Smart Light (Relay) + Voice/Bluetooth Control

Parts: 1-channel 5V relay module, Arduino, HC-05 Bluetooth (optional), lamp or LED strip, appropriate AC caution if switching mains.

Wiring (Light)

Relay module:
  Vcc -> 5V
  GND -> GND
  IN  -> Arduino pin 4  (digital output)

HC-05 (optional, for Bluetooth control):
  Vcc -> 5V (or 3.3V depending on module)
  GND -> GND
  TX  -> Arduino RX via SoftwareSerial pin 8
  RX  -> Arduino TX via SoftwareSerial pin 9

Lamp:
  Lamp's live wire -> relay COM
  Lamp's neutral -> mains neutral (be careful)
  Relay NO -> mains live (only connect mains if you know what you're doing)
    

SAFETY: If you are switching mains AC, you must know basic electrical safety. Use insulated connectors, fuse protection, and, if unsure, use a qualified electrician. For testing, use a low-voltage lamp or LED strip.

Arduino sketch — relay controlled via Bluetooth commands

This listens for simple text commands over Bluetooth: ON or OFF. You can use a phone terminal app to send those commands.

#include <SoftwareSerial.h>
SoftwareSerial btSerial(8, 9); // RX, TX (to HC-05)
const int relayPin = 4;

void setup() {
  Serial.begin(9600);
  btSerial.begin(9600);
  pinMode(relayPin, OUTPUT);
  digitalWrite(relayPin, LOW); // relay off (change if your module is active LOW)
}

void loop() {
  if (btSerial.available()) {
    String cmd = btSerial.readStringUntil('\\n');
    cmd.trim();
    Serial.println("BT cmd: " + cmd);
    if (cmd.equalsIgnoreCase("ON")) {
      digitalWrite(relayPin, HIGH);
      Serial.println("Light ON");
    } else if (cmd.equalsIgnoreCase("OFF")) {
      digitalWrite(relayPin, LOW);
      Serial.println("Light OFF");
    }
  }
  // optional: echo Serial -> BT
  if (Serial.available()) {
    btSerial.write(Serial.read());
  }
}
    

If you want voice commands, use phone voice assistant + a Bluetooth terminal app that converts speech to text then send commands to HC-05. Another option: connect a small microphone + speech-to-text module (more advanced).

Power & Battery tips

Testing & calibration checklist

  1. Test the ultrasonic sensor reading via Serial monitor and adjust triggerDistance.
  2. Test servo motion without the mechanical load — check angles in code and adjust.
  3. If using DFPlayer, test sound playback first with a small speaker and a proven mp3 file.
  4. Test the relay with a low-voltage lamp before connecting mains AC.
  5. Place everything in position, then test the complete sequence.

Troubleshooting quick hits

Final notes

This is a practical, low-cost setup — perfect for demos and hacky home automation. If you want, I can:

Tell me which of those you want next and I’ll add it straight into this page.