
Wireless Communication Solution Before choosing, I had previously encountered Zigbee networking, which is also a commonly used networking method due to its low cost and simplicity. Here are several reasons for choosing this network:

Speaking of modularity, a core control board is needed. Essentially, it integrates the microcontroller and the purchased Zigbee module onto one circuit board, while reserving various interfaces to facilitate later adaptation to various devices. This way, a single circuit board can be used for various smart home devices.

The soldered finished product is as follows:

This will become the core control board for all my future smart home solutions.

Everyone must be very familiar with the ESP8266, and I happen to have one on hand, so it fits perfectly.

To facilitate the display of the gateway node’s status and the reading of related information for future debugging, I added a 4.3-inch serial touch screen to the gateway, making it easier to read information and perform debugging tasks.

After completing the design of the Zigbee node core board and selecting the gateway hardware, the main components of the smart home system are now constructed.
Without detailing the programming yet, I will write the corresponding device interface program for the gateway after debugging each smart device. That is, after completing the development of a smart device, I will connect it to the gateway, allowing it to join the home Zigbee network for linked control or networked control. After all, the ZigBee module I am using only serves as a communication tool, while the actual functionality relies on the microcontroller on the core board. This development method is referred to as iterative development, which is a good solution for larger projects.
02
Production Section
Next is the design of the smart wall switch, which aims to make the wall switch in the home intelligent, allowing for network control, achieving scene linkage, and smart control.
As for the actuator, which acts as the original mechanical switch, I plan to use a relay to replace it. The relay allows me to control the on/off of 220V AC voltage using signals output from the microcontroller, providing good isolation and insulation performance.

For the smart switch node, I configured the Zigbee module as a router node. The benefit of this is that the wall switch also acts as a router, assisting some remote terminal nodes in completing multi-hop data transmission. For example, if I want to use a wireless switch in the bedroom to control the light at the front door, directly sending data to the smart switch at the front door may fail due to insufficient signal strength. In this case, adding a router node in the living room allows the wireless switch’s signal to transmit to the smart switch at the front door.

When the Zigbee module receives data from the smart gateway (e.g., closing or opening the switch), the output data will also trigger a serial interrupt that wakes up the microcontroller, which will then execute the received instructions and subsequently return to idle mode.

Additionally, to better monitor the status of each switch, after each switch action, the current status will be reported to the smart gateway, allowing the gateway to check the status of all switches in the home.

Connecting the Zigbee coordinator node to the computer, turning on the power of the smart switch, you can see that every time I touch the switch, the corresponding relay will act, and the coordinator node’s serial port will output some data:

Below is an interpretation of a frame of data (this data packet structure is defined by me and is not the command structure required by the Zigbee module).

After testing, the smart switch achieved the functionality I wanted. Next, I will design the PCB board for the casing I purchased.

After converting to PCB files, and after simple component placement and wiring, the completed effect is as follows:

The AC high-voltage section and DC low-voltage section are separated by grooves to provide good anti-interference characteristics. The back side is designed for the positions of the Zigbee module and the microcontroller.

After installing the touch module, I used double-sided tape to stick the touch module onto the panel glass.

After programming, close the casing, and use labels on the back to indicate the definition of the connections for easy installation.

Use the smart switch to replace the traditional switch in the home.

03
Writing the Corresponding Program for the Gateway


Upload the program to the ESP8266 and start testing!
04
Comprehensive Testing

05
Production of Wireless Remote Control Switch
Before going to bed at night, the wall switch is too far from the bed, making it inconvenient to turn off the light. Therefore, I plan to design a remote wireless switch that can control all smart devices in the home through pairing, similar to a stick-on switch. Below is the introduction to the design of the wireless remote control switch.

Take out the completed Zigbee minimum system board.

The wireless remote control switch has a button for operation, so I soldered a push-button switch onto the minimum board module.

Additionally, I soldered the power line, using a button battery for power supply (the button battery is on the back).

I used a 3D printer to print the casing (the printer wasn’t adjusted very well, so the print is somewhat rough), and I cut the board to fit inside:

2) Configuration Corresponding to the Gateway

In this interface, press the pairing button on the wall switch:

At this time, the display will show relevant information. Device number 1 will display on the first line, and so on. The part that exceeds one page will automatically scroll:

If the reset button is damaged, you can also use the MAC address addition method:


Click the pairing button on the right side of the information, and the screen will display a prompt for pairing:

At this time, press the button on the wireless remote control switch:

Then you will see the pairing success prompt on the display:

At this point, you can control the light on and off using the wireless remote switch:


More practical project recommendations:
STM32 IoT Smart Home Project
Raspberry Pi + Compute Stick 2 for Real-Time Face Recognition Project
Building a Cloud Computing Platform for Embedded Development Boards
STM32 for the Simplest Air Mouse
Arduino Rubik’s Cube Robot
STM32 Version “AI Soul Painter”
STM32 Electronic Photo Album Production
STM32 + DDS Homemade Signal Generator
Remote Control of Home Appliances Using Raspberry Pi with Web Interface
STM32 “Cloud” Music Player
Raspberry Pi Remote Monitoring
Design of Glow Tube Clock Based on STM32
Homemade FPGA Minimum System Board (PCB can be directly made)
Building NAS with Raspberry Pi 4 for Easy Network Access
ESP32 Car Software and Hardware Practical Sharing
Achieving Creative Gesture Recognition with Only 79 Lines of Code
Using IoT + Electronic Ink Screen to Create Custom Display Screens
Creating a Pathfinding Robot Worth Over a Thousand with Just a Few Dozens
Holographic Display with Naked Eye, Visual Persistence POV Project
DIY Gesture Recognition Module
Practical Small Designs That Anyone Can DIY from Scratch
Raspberry Pi to Create a Smart Doorbell + Smart Door Lock with Video
Strangely! My Development Board Can Automatically Play Games
Homemade Breathing Machine
Recommended Reading:
