Build a Modular Smart Light Switch with Sensor Blocks

A smart light switch that you can snap together, change, and move is a game‑changer for any DIY home. It lets you add motion sensing, dimming, or even voice control without rewiring the whole house. In this post I walk you through the whole build, step by step, using the Sensor Blocks system that I love to tinker with at Sensor Blocks Hub.

What you need

Before we start, gather the parts. Keeping the list short makes the project feel less like a treasure hunt.

  • Sensor Blocks kit – includes a power block, a motion sensor block, a relay block, and a microcontroller block.
  • Standard wall switch box – the one you already have in the wall.
  • 2‑core and 3‑core cable – for power and sensor wiring.
  • Screwdriver set – flathead and Phillips.
  • Wire stripper – a cheap one works fine.
  • Heat‑shrink tubing or electrical tape – for safety.
  • Optional: LED dimmer block – if you want brightness control.
  • A laptop – to upload the simple code.

All of these parts are easy to find on the Sensor Blocks Hub store, and most of them are already in my workshop drawer.

Overview of the design

The idea is simple: the wall‑mounted switch becomes a container for a few Sensor Blocks that talk to each other. The power block brings 120 V (or 230 V, depending on your region) into the box. The motion sensor block watches the room and tells the relay block when to turn the light on or off. The microcontroller block holds the logic and can be re‑programmed later if you change your mind.

Because the blocks snap together, you can replace the motion sensor with a temperature sensor, or add a dimmer block, without opening the wall again. That modularity is the core value of Sensor Blocks – you build once, change often.

Choosing the right blocks

Power block

Pick the block that matches your mains voltage. The 120 V version has a built‑in fuse, which is a nice safety net. If you live in Europe, grab the 230 V version – same shape, different rating.

Motion sensor block

The PIR (passive infrared) sensor inside this block detects movement up to 6 m. It has a built‑in LED that flashes when it sees motion, which is handy for debugging.

Relay block

A single‑pole, single‑throw (SPST) relay is enough for a standard light. It can handle up to 10 A, so most household bulbs are safe.

Microcontroller block

The Arduino‑compatible block runs a tiny sketch that decides when the relay should close. It has a USB‑C port for easy code upload.

Wiring plan

Think of the wiring as three layers:

  1. Mains power – from the wall to the power block, then to the relay.
  2. Control signal – from the motion sensor to the microcontroller, then to the relay coil.
  3. Ground and safety – all low‑voltage grounds tied together, heat‑shrink on any exposed copper.

Draw a quick sketch on a napkin; it saves a lot of head‑scratching later.

Step 1: Prepare the wall box

  1. Turn off the breaker for the circuit you’ll work on. Safety first – I always double‑check with a voltage tester.
  2. Remove the old switch and pull the box out just enough to see the wiring.
  3. Clean any old wire nuts and make sure the box is firmly attached to the wall studs.
  4. If the box is too small for the blocks, swap it for a deeper “deep‑nest” box – they are cheap and fit nicely.

Step 2: Wire the power block

  1. Strip about 1 cm of insulation from the two mains wires (live and neutral).
  2. Connect the live (usually black or brown) to the “L” terminal on the power block, and the neutral (white or blue) to the “N” terminal. Tighten the screws firmly.
  3. Run a short piece of 2‑core cable from the power block’s “output” terminals to the relay block’s “common” and “normally open” contacts. This will feed the light when the relay closes.
  4. Clip a piece of heat‑shrink over each connection and apply heat. It looks tidy and keeps the copper from touching the metal box.

Step 3: Add the motion sensor block

  1. Use a 3‑core cable to link the power block’s low‑voltage side to the sensor block. The three wires are: +5 V, ground, and signal.
  2. Connect +5 V to the sensor’s power pin, ground to ground, and the signal line to the sensor’s output pin.
  3. Secure the sensor block inside the box so the little IR window faces outward. I usually tape it to the back of the box with a small piece of double‑sided tape – it stays put and can be removed later.

Step 4: Program the microcontroller block

  1. Plug the microcontroller block into your laptop via the USB‑C port.
  2. Open the Arduino IDE (or the simple web editor on Sensor Blocks Hub) and paste this sketch:
const int motionPin = 2;   // sensor output
const int relayPin  = 3;   // relay control

void setup() {
  pinMode(motionPin, INPUT);
  pinMode(relayPin, OUTPUT);
  digitalWrite(relayPin, LOW); // start with light off
}

void loop() {
  if (digitalRead(motionPin) == HIGH) {
    digitalWrite(relayPin, HIGH); // turn light on
    delay(300000);                // stay on for 5 minutes
    digitalWrite(relayPin, LOW);  // turn off
  }
}
  1. Click “Upload”. The block blinks a little while it writes the code.
  2. Disconnect the USB and snap the microcontroller block into the box, linking its I/O pins to the sensor signal line and the relay coil line.

Step 5: Test and mount

  1. Turn the breaker back on.
  2. Use a voltage tester to confirm the power block is live.
  3. Wave your hand in front of the sensor. The little LED on the sensor should flash, and the light in the room should come on within a second.
  4. Wait five minutes – the light should turn off automatically. If it stays on, check the code or the wiring.
  5. Once everything works, push the blocks gently into the box, making sure no wires are pinched. Screw the cover plate back on.

Tips and troubleshooting

  • False triggers – If the sensor lights up when nobody is there, try moving the block a few centimeters away from the wall. The metal can reflect infrared.
  • Heat issues – The relay can get warm after many cycles. Give the box a little ventilation or use a relay with a built‑in heat sink.
  • Future upgrades – Want dimming? Just replace the relay block with a dimmer block and change the sketch to use PWM (pulse‑width modulation). The modular nature of Sensor Blocks makes this a painless swap.
  • Safety check – Always double‑check that the ground wires are tied together and that no bare copper is exposed. A quick visual inspection saves headaches later.

Building a modular smart switch with Sensor Blocks feels like putting together a LEGO set for adults. You get the satisfaction of a working circuit and the freedom to change it later without tearing down walls. I hope this guide helps you add a bit of smart tech to your home, one snap at a time.

#smart #iot #diy

Reactions