DIY Electronics
— Building circuits, programming microcontrollers, and making things blinkHome Automation PCB for a Smart Switch
Designed a custom PCB to retrofit mains switches with smart control. Safety note: this project involves mains voltage (120/240V AC). If you are not comfortable with mains-side wiring, use a commercial module instead.
The design uses a HiLink HLK-PM01 isolated mains-to-5V module, which provides a compact, certified, isolated supply from mains. This eliminates the need to design your own transformer or SMPS — important for safety and regulatory compliance. A BTA16 TRIAC controlled by an MOC3021 optocoupler provides zero-crossing switching of the load. The ESP8266 sits on the low-voltage side, entirely isolated from mains.
Creepage and clearance: IPC-2221 specifies minimum 3mm creepage for 250V in a home environment. My PCB has 6mm between any mains-side trace and the ESP8266 circuit. I conformal-coated the finished boards.