The project
These days, smart devices are everywhere. But I’ve always wondered: how easy is it to make one yourself? To find out, I took a simple USB lamp from Amazon and converted it into a smart lamp I can control from my phone using Home Assistant, a Wemos D1 Mini, and a few basic electronic components.
This guide walks you through the hardware, the software, and even some 3D printing to help you build your own first smart project.
Parts and Tools
- Wemos D1 Mini (ESP8266 microcontroller, Wi-Fi enabled, small and inexpensive)
- MOSFET (to act as an electronic switch for the lamp)
- Raspberry Pi 5 running Home Assistant
- USB desk lamp (any simple model with a basic control panel will do)
- Perf board (for soldering up the final circuit)
- Optocoupler (for handling color switching)
- Soldering tools + breadboard for prototyping
- Fusion 360 + 3D printer (for making the enclosure)
Step 1: Stripping Down the Lamp
The first job was to strip the lamp’s USB cable to see what I was working with. Luckily, it only had power and ground wires—perfect for a first project.
Step 2: Breadboard Testing
I wired up the Wemos, MOSFET, and lamp on a breadboard to check that everything worked. The Wemos controlled the MOSFET, which switched the lamp on and off.
With that working, I moved on to setting up Home Assistant.
Step 3: Setting Up Home Assistant
Getting Home Assistant running on a Raspberry Pi was surprisingly straightforward:
- Open Raspberry Pi Imager
- Select Home Assistant OS from the OS list
- Flash it to an SD card
- Insert the SD card into the Pi
- Connect the Pi to your router via Ethernet
Once it booted, I added the Wemos using ESPHome. That gave me remote control over the lamp directly in Home Assistant.
Step 4: Fixing the On/Off Button
There was a problem: the lamp still required me to press the physical button on its control panel to actually turn on.
To solve this, I:
- Opened up the lamp and located the button responsible for power.
- Desoldered the button and replaced it with a simple wire bridge across the correct pins.
Now, when I toggled the lamp in Home Assistant, it powered up immediately—no button press needed.
Step 5: Adding Color Control
The lamp also had a color-change feature, which I wanted to keep. This worked by shorting different pins on the PCB.
I added an optocoupler to safely handle this switching and wired it to the Wemos. This meant I could now change the lamp’s color directly from Home Assistant.
(I skipped brightness control—the lamp wasn’t very bright anyway—so I just left it at maximum all the time.)
Step 6: Moving Off the Breadboard
With everything working, it was time to clean up. I transferred the circuit onto a Perf board. A custom PCB would have been overkill, but the perf board made the build sturdier.
After a lengthy soldering session, the electronics were secure and functioning.
Step 7: Designing a Case
To keep the electronics safe and give the project a finished look, I designed a simple enclosure in Fusion 360.
- The design included a base and a top plate.
- Both parts were 3D printed and fixed together with M2 nuts and bolts.
The result was a neat little smart lamp module that looked far more polished than the breadboard mess I started with.
Final Thoughts
Although simple, this project was my first real step into DIY home automation. I can now:
- Turn the lamp on/off from my phone
- Change its color remotely
- Control it entirely via Home Assistant
It’s a small project, but one I’m really happy with—and it’s opened the door to all sorts of other smart device ideas.
