2023 Service Innovation Competition A10 Topic: Smart Home Remote Control System
Editing Record
2023-06-06 First Release
2023-06-07 Part of the MCU code is released, please download from the attachment
Competition Introduction
The China University Student Service Outsourcing Innovation and Entrepreneurship Competition (hereinafter referred to as the Competition) is a national competition held annually in response to the country's relevant strategic measures and calls to encourage the development of the service outsourcing industry and strengthen the training of service outsourcing talents.
The main purpose of the competition is to build a platform for the display of innovation and entrepreneurship capabilities of college students in service outsourcing that combines industry and academia; promote exchanges between schools and enterprises, and promote higher education to provide talent guarantees for the development of the service economy; publicize the service economy and enhance the public's attention and attention to the development of the service outsourcing industry. The participating teams are all from domestic colleges and universities in China, mainly undergraduates, and are free to form teams. The competition is open to the public. After registration, independent topic selection, decentralized preparation and centralized defense, the corresponding outstanding teams will be selected.
Award information
This project has won the second prize in the Eastern Division of the Service Outsourcing Competition (the third prize should be awarded nationwide later).
Competition topic description
1. Topic direction
Internet of Things and Industrial Automation
2. Topic category
Application category
3. Topic name
Smart home remote control system
4. Project description
[Problem description]
Based on Android, design and develop a smart home remote control APP to remotely control the opening, closing and adjustment of smart home devices in the room, such as lights, air conditioners, door locks, etc. Bring users a smarter and more convenient life.
[User expectations]
(1) Smart control center
The smart control center is mainly composed of smart host gateways, which are used to connect various devices to form a smart home network. Including remote APP control commands are all executed by the smart host to achieve the purpose of smart linkage of devices and smart scene switching.
(2) The security system of the smart home
sends wireless remote control information to the smart door lock through the APP that controls the door lock to achieve remote unlocking (the method is not limited, it can be sending a temporary password or directly opening the door remotely).
(3) The smart lighting system
can realize the one-click opening and closing of all lights in the house through the APP. Implement zone control for lights in rooms, living rooms, dining rooms, master bedrooms, and second bedrooms. For multiple light sources in one area, set up independent control switches. The system displays the number of light sources turned on in the room and the areas turned on, so that users can easily enter the system to operate the switches.
(4) The smart HVAC system
requires the air conditioner in the house to be fully turned on and off with one click through the APP. The air conditioners in the living room, master bedroom, and second bedroom can be controlled separately, and the switch, mode control (cooling, heating, ventilation), temperature setting, and wind speed (low wind, medium wind, high wind) can be controlled separately.
(5) System scalability
requirements In addition to the above functions, the system can flexibly connect to other home appliances and remotely control them through the APP. (One connection is sufficient)
5. Task requirements
[Development instructions]
(1) Smart control center The
smart control center is mainly composed of a smart host gateway, which is used to connect various devices to form a smart home network. Including remote APP control commands are all executed by the smart host to achieve the purpose of smart linkage of devices and smart scene switching.
(2) The security system of smart home
sends wireless remote control information to the smart door lock through the APP that controls the door lock to achieve remote unlocking (the method is not limited, it can be sending a temporary password or directly opening the door remotely).
(3) The smart lighting system
requires the house lights to be fully turned on and off with one click through the APP. The lights in the rooms, living room, dining room, master bedroom, second bedroom and other areas are controlled by zones. For multiple light sources in one area, independent control switches should be set up. The system displays the number of light sources turned on in the room and the area where they are turned on, so that users can enter the system to operate the switches.
(4) The smart HVAC system
requires the house air conditioner to be fully turned on and off with one click through the APP. The air conditioners in the living room, master bedroom and second bedroom can be controlled separately, and the mode control (cooling, heating, ventilation), temperature setting and wind speed (low wind, medium wind, high wind) can be realized.
(5) System scalability
requirements In addition to the above functions, the system can flexibly connect to other home appliances and realize remote control through the APP. (You can just connect one)
[Submitted materials]
(1) Project overview;
(2) Project introduction PPT;
(3) Project detailed plan;
(4) Project demonstration video;
(5) Materials required by the enterprise:
① Complete demand analysis document;
② Complete system design document;
③ Complete test cases;
④ Complete source code and database;
⑤ Complete test report.
⑥ Product APK installation package
(6) Other materials submitted voluntarily by the team.
[Task list] (1) Demand research and analysis;
(2) System design, including hardware system design and software system design, software includes outline design and detailed design;
(3) Test case writing;
(4) Coding;
(5) Deploy the test environment and complete the test.
【Development tools and data interface】
Eclipse or AndroidStudio, etc.
Regarding code open source
, since I have only completed the hardware part, I will only open source the hardware PCB board and ESP32 code. The remaining APP and smart gateway ends are not open source for the time being.
Hardware solution
2.1.3 Hardware development process
2.1.3.1 Hardware architecture

diagram 2.8 Hardware architecture
2.1.3.2 Hardware networking solution
In this project, we used WIFI technology to build an Internet of Things. The smart gateway and related devices are connected to the network provided by the home router. Each device is connected to the MQTT server installed on the smart host gateway through the MQTT client to realize the sending and receiving of instructions and data. After the user sends a command to the MQTT server on the smart host gateway, the MQTT server will forward the sent message to the device that has subscribed to the topic. After the device receives the relevant command and parses the parameters, it realizes the final control. At the same time, the device can also return some sensor or status data to the user through the MQTT server. The following figure shows the structure diagram of the hardware network.

Figure 2.9 Hardware networking structure diagram
2.1.3.3 Smart gateway solution
The smart control center is mainly composed of a smart host gateway, which is used to connect various devices to form a smart home network. In the selection of this smart control center, we used Raspberry Pi 4B as the smart host gateway. Raspberry Pi 4B is a single-board computer launched by the Raspberry Pi Foundation in the UK and released in June 2019. Raspberry Pi 4B uses a 64-bit quad-core ARM Cortex-A72 processor and uses 4GB of LPDDR4 memory.
The physical picture of Raspberry Pi 4B is as follows:

Figure 2.10 Physical picture
of Raspberry Pi 4B The main technical specifications of Raspberry Pi 4B are as follows:
2.1.3.3.1 Processor
Broadcom BCM2711, quad-core Cortex-A72 (ARM v8) 64-bit SoC @ 1.5GHz
2.1.3.3.2 Memory
2GB, 4GB or 8GB LPDDR4 (depending on the model)
2.1.3.3.3 Connection
2.4 GHz and 5.0 GHz IEEE 802.11b/g/n/ac wireless LAN, Bluetooth 5.0, BLE
Gigabit Ethernet
2 × USB 3.0 interfaces
2 × USB 2.0 interfaces
2.1.3.3.4 GPIO
Standard 40-pin GPIO header (fully backward compatible with previous boards)
2.1.3.3.5 Video, sound
2 × micro HDMI port (supports up to 4Kp60)
2-channel MIPI DSI display port
2-way MIPI CSI camera interface
4-pole stereo audio and composite video ports2.1.3.3.6
Multimedia
H.265 kp60 decoding (4);
H.264 (1080p60 decoding, 1080p30 encoding);
OpenGL ES, 3.0 graphics2.1.3.3.7
SD card support
Micro - SD card slot for loading operating system and data storage2.1.3.3.8
Input power
5V DC through USB-C connector (minimum 3A1)
5V DC through GPIO header (minimum 3A1)
Supports Power over Ethernet (PoE) (requires separate PoE HAT)
2.1.3.4 Main control chip solution2.1.3.4.1
Selection of main control chip
In the selection of the main control chip for the control function board, we used the ESP32-C3 microcontroller launched by Espressif Systems. The ESP32-C3 series chips are extremely low-power, highly integrated MCU system-on-chip (SoC) that integrate 2.4 GHz Wi-Fi and low-power Bluetooth® LE dual-mode wireless communications. The functional block diagram of the chip is shown in the figure below.

Figure 2.11 ESP32-C3 functional block
diagram2.1.3.4.2 Comparison of common ESP32 modelsSeriesESP32
ESP32
-
S2
ESP32-C3Release
time2016
2020
2020 CPU Xtensa® LX6 32-bit dual-core/single-core processorXtensa® LX7 32-bit single-core processorRISC -V 32-bit single-core processorMain
frequency240M 240M 160MUltra - low power coprocessor (ULP) ULP FSM PicoRV32 core, 8 KB SRAM, ULP FSM N/A SRAM 520KB 320KB 400KB ROM 448 KB 128 KB 384 KBOn -chip FlashNone /2 MB/4 MBDifferent specificationsNone /2 MB/4 MBDifferent specificationsNone /4 MB different specifications External Flash supports up to 16MB Maximum supports 1GB Maximum supports 16MB External PSRAM supports up to 8MB Maximum supports 1GB N/A Wi-Fi 802.11 b/g/n, 2.4 GHz 802.11 b/g/n, 2.4 GHz 802.11 b/g/n, 2.4 GHz Bluetooth Bluetooth v4.2 BR/EDR Bluetooth Low Energy N /A Bluetooth 5.0 ADC 2*12-bit SAR ADC, 18 channels 2*12-bit SAR ADC, 20 channels 2*12-bit SAR ADC, 6 channels DAC 2*8-bit 2*8-bit N/A Timer 4*64-bit general timer, 3 watchdog timer 4*64-bit general timer, 3 watchdog timer 2*54-bit general timer, 3 watchdog timer Temperature sensor N/A 1 1 Touch sensor 10 14 N/A Hall sensor 1 N/A N/A GPIO
34
43
22
SPI
4
4
3
UART
3
2
2
I2C
2
2
1
I2S
2
1
1
Camera
1
1
N/A
RMT (infrared remote control)
1*8 channels
1*4 channels
1*4 channels
LED PWM
1*16 channels
1*8 channels
1*6 channels
MCPWM
2, providing six PWM outputs
N/A
N/A
USB OTG
N/A
1
N/A
TWAI
1
1
1
SD/SDIO/MMC host
1
N/A
N/A
SDIO slave
1
N/A
N/A
Ethernet MAC
1
N/A
N/A
USB serial port
N/A
N/A
1
Table 2.6 Comparison of common ESP32 models
2.1.3.5 System power supply scheme
In the system power supply module scheme, in order to facilitate debugging and home wiring. We currently use 5V input, and each function board has both a USB port and a KF128 terminal. The power input can be selected from two input interfaces, and cannot be used at the same time.
In the chip power supply part, the chip needs to be powered by 3.3V. It uses a SY8089A1AAC DCDC chip launched by Silergy. The maximum input voltage is 5V. By adjusting the voltage of the FB pin, the output voltage can be adjusted. Here, the output voltage is 3.3V.
At the input end, in order to prevent static electricity and lightning from breaking through the devices on the PCB, a TVS transient suppression diode is added to absorb external surges and protect the devices on the board.
The following figure shows the input connectors of the power supply module and the peripheral circuit schematic of SY8089.

Figure 2.12 Schematic diagram of power supply module connectors

Figure 2.13 Schematic diagram of power supply module
2.1.3.6 Indicator module solution
In the indicator module, we used WS2812 RGB LED. WS2812 is a common addressable RGB LED (light emitting diode), which contains a red, a green and a blue LED, and a built-in control circuit. This allows each LED to be controlled individually, so that various color effects and animations can be created. It is widely used in many applications, including lighting for art installations, stage performances, and architectural decoration. They are also commonly used in DIY projects such as LED matrices, wearable electronics, and interactive displays.
WS2812 LEDs use a single-wire interface for communication, and the microcontroller can send control signals to control these indicators, informing the user of the current status and facilitating the user to identify the problem.
The basic parameters of WS2812 are as follows:
1. Power input voltage: 3.5-7.5V
2. OUT R/G/B constant current value: 12mA
3. Top SMD internally integrated high-quality external control single-line serial cascade constant current IC
4. The control circuit and chip are integrated in the SMD 5050 components to form a complete external control pixel point, with uniform color temperature effect and high consistency
5. Built-in data shaping circuit, any pixel point receives the signal and then undergoes waveform shaping before output, ensuring that line waveform distortion will not affect
6. The default is that the light is off when powered on
7. Grayscale adjustment circuit (256 grayscale levels are adjustable)
8. Data shaping: After receiving the data of this unit, the subsequent data will be automatically shaped and output
9. Built-in high-precision and high-stability oscillator
10. Single-line data transmission, which can be infinitely cascaded
11. High data protocol compatibility
12. Data transmission rate: 800Kbps
The typical schematic diagram of this module is as follows:

Figure 2.14 Schematic diagram of indicator light module
2.1.3.7 Buzzer module solution
In order to meet the needs of equipment prompting users, the project has added a buzzer module, which controls the passive buzzer through an AO3400 NMOS to make the buzzer make sound.
In order to ensure that the size of the PCB board is as small as possible, the project did not choose the traditional plug-in buzzer, but used a chip buzzer, the material model is MLT-8530, the parameters are as follows:
Drive mode: passive (external drive)
Construction type: electromagnetic
Rated voltage: 3.6V
Frequency: 2.7kHz
Sound pressure (SPL): 80dB@5V
Size: 10cm 8.5x8.5x3mm
Because the buzzer is inductive and complex, its switch will affect the power supply and cause power supply fluctuations, so it is necessary to add a freewheeling diode (as shown in the figure D2). The figure below shows the schematic diagram of the buzzer module.

Figure 2.15 Schematic diagram of the buzzer module

Figure 2.16 MLT-8530 physical picture
2.1.3.8 The curtain control solution
uses the curtain motor + matching track solution. The motor is connected to 220V AC. The control board controls the operation of the curtain motor by short-circuiting the dry contact interface led out from the motor through the relay.
Product parameters:
Motor name: Five-core wire strong electric motor
Product model: WX-82
Rated power: 45W
Rated current: 0.14A
Body weight: 1.05KG
Rated torque: 1.2N/m
Running speed: 14cm/sPower
supply standard: five-core
wireRunning noise: 33dBMinimum
width: 0.9mMaximum
width: 12mMaximum
load: 50KGProtection
level: 20IPWorking
temperature: -10℃-50℃
Input voltage: 220VReference
Taobao products:

Figure 2.17 Motor product figure2.1.3.9
Other home appliance control solutionsIn
the control of air conditioners and TVs, we use infrared transmission, which decodes the infrared signal sent by the remote control of the device and re-transmits it through the infrared transmission module on the home appliance control function board to achieve home appliance control.
2.1.3.10 Access control function board
solution2.1.3.10.1 Unlock circuit chip selectionIn
the unlock circuit, we use a RZ7899 single-channel H-bridge driver chip. RZ7899 is a DC bidirectional motor drive circuit, which is suitable for motor drive of toys, automatic valve motor drive, electromagnetic door lock drive, etc. It has two logic input terminals to control the motor forward, backward and brake. The circuit has good anti-interference, small standby current, low output internal resistance, and built-in diode to release the reverse impact current of inductive load.
In order to protect the microcontroller and power supply, MOS tube is not used to control the lock to open, but an H-bridge chip RZ7899 is used. The chip has built-in overcurrent protection circuit and freewheeling diode, which is more suitable for this project.
The characteristics of RZ7899 are as follows:
small standby current, less than 2uA.
Wide operating voltage range of 3.0V~25V.
There is emergency stop function,
overheat protection function
, overcurrent and short circuit protection function
. The package shape is: SOP8
2.1.3.10.2 Unlock detection circuit scheme
In the unlock detection circuit part, the LOCK_STATE pin in the unlock circuit schematic diagram inputs the unlock signal. When the door lock is opened, the level of the pin will change accordingly, and the door lock can be detected to be opened and closed.
2.1.3.10.3 Unlocking circuit schematic diagram

Figure 2.18 Unlocking circuit schematic diagram
2.1.3.10.4 Relay control circuit selection
In the access control board, in order to control the equipment related to access control, the project added a relay with a maximum current of 5A. The relay control module consists of an optocoupler, SS8050 transistor, and a relay. The figure below shows the schematic diagram of the relay control module. The optocoupler converts the signal sent by the microcontroller into an optical signal, which is converted into an electrical signal on the other side to control the conduction of the 8050 below to achieve relay control. At the same time, a freewheeling diode needs to be added at both ends of the relay power supply to prevent reverse current from damaging the onboard circuit.
In terms of relay selection, we considered many factors, such as size and maximum current. Finally, considering that the current of the equipment controlled on the access control board is generally not very large, and there is not much space left on the control board, the HF49FD/005-1H11 model of Hongfa Relay Factory was selected, with a maximum current of 5A to meet basic needs.
The following figure shows the schematic diagram of the relay control circuit:

Figure 2.19 HF49FD/005-1H11 physical picture

Figure 2.20 Relay control module schematic diagram
2.1.3.10.5 Curtain control circuit selection
The curtain control circuit is basically the same as the relay control circuit. The principle is to short-circuit the curtain control line through the relay to complete the curtain control.
In terms of relays, the HF49FD/005-1H11 model of Hongfa Relay Factory is also used. This model is small in size and relatively easy to integrate into the control board.

Figure 2.21 Schematic diagram of curtain control module
2.1.3.10.6 Schematic diagram of access control function board

Figure 2.22 Schematic diagram of access control function board 1

Figure 2.23 Schematic diagram of access control function board 2

Figure 2.24 Schematic diagram of access control function board 3
2.1.3.10.7 Assembly diagram of access control function board Figure

2.25 Top assembly diagram of access control function board

Figure 2.26 Bottom assembly diagram of access control function board
2.1.3.10.8 Physical diagram of access control function board Figure

2.27 Physical diagram of access control function board
2.1.3.11 Lighting control function board solution
2.1.3.11.1 Lighting module solution
The lighting module is a device on the lighting control function board, mainly composed of WS2812 RGB LED. Users can issue lighting control instructions and provide the R, G, B values of the LED light to the microcontroller to control the light to display the specified color. The figure below shows the schematic diagram of the lighting module.

Figure 2.28 Schematic diagram of lighting module2.1.3.11.2
Schematic diagram of lighting control function boardFigure

2.29 Schematic diagram of lighting control function board 1Figure

2.30 Schematic diagram of lighting control function board 2Figure

2.31 Schematic diagram of lighting control function board 3
2.1.3.11.3 Assembly diagram of lighting control function boardFigure

2.32 Top assembly diagram of lighting control function boardFigure

2.33 Bottom assembly diagram of lighting control function
board2.1.3.11.4 Actual diagram of lighting control function boardFigure

2.34 Actual diagram of lighting control function
board2.1.3.12 Fan control function board
solution2.1.3.12.1 Selection of boost circuit chipSince
the fan requires 12V voltage to be driven and the input voltage is 5V, a boost chip MT3608 is mounted on the fan control board to boost the input 5V to 12V to power the fan.
MT3608 is a BOOST boost chip launched by Xi'an Aerospace Minxin. This chip is a constant frequency 6-pin SOT23 package for small current boost converters. The MT3608 switching frequency is 1.2MHz and allows the use of miniature, low-cost capacitors and inductors with a height of no more than 2mm. The internal soft start can reduce the inrush current and extend the service life. The MT3608 includes undervoltage lockout, current limiting and thermal overload protection to prevent damage in the event of output overload. The MT3608 uses a small 6-pin SOT-23 package.
The figure below shows the peripheral circuit of the MT3608. The input voltage 5V is input through the EN pin, the FB pin sets the output voltage through the voltage divider resistor, and the chip is boosted through the inductor and diode above, and finally outputs 12V.

Figure 2.35 Schematic diagram of boost module
2.1.3.12.2 Fan control circuit solution
The fan control circuit consists of an H-bridge drive circuit, a PWM speed control circuit, an INA199 current sampling circuit, and a fan speed measurement circuit. The figure below shows the schematic diagram of the fan control circuit.
First, the 5V voltage is boosted to 12V through the boost module, and then the start and stop of the fan is controlled through the H-bridge drive circuit. The PWM speed control circuit sends a PWM speed control signal from the microcontroller to control the fan speed. The INA199 current sampling circuit and the fan speed measurement circuit provide corresponding implementation for the fan speed measurement function.

Figure 2.36 Schematic diagram of fan control module
2.1.3.12.3 Schematic diagram of fan control function board

Figure 2.37 Schematic diagram of fan control function board 1

Figure 2.38 Schematic diagram of fan control function board 2

Figure 2.39 Schematic diagram of fan control function board 3
2.1.3.12.4 Assembly diagram of fan control function board Figure

2.40 Assembly diagram of top layer of fan control function board

Figure 2.41 Assembly diagram of bottom layer of fan control function board
2.1.3.12.5 Actual diagram of fan control function board

Figure 2.42 Actual diagram of fan control function board
2.1.3.13 Solution of home appliance control function board
2.1.3.13.1 Selection of temperature and humidity sensor
The temperature and humidity acquisition module uses SHT30 chip. SHT30 integrates temperature and humidity acquisition circuits internally, communicates externally through I2C interface, can provide extremely high reliability and excellent long-term stability, and has the advantages of low power consumption, fast response, strong anti-interference ability, etc. The figure below shows the schematic diagram of temperature and humidity acquisition module.

Figure 2.43 Schematic diagram of temperature and humidity acquisition module
2.1.3.13.2 Selection of infrared emitting tube
The infrared control module is a function on the home appliance control function board. It is used to send infrared signals to control the air conditioner, TV and other equipment in the home. It uses 5 infrared emitting diodes, which are controlled to open and close by an AO3400 N-channel MOS tube.
In the selection of infrared emitting tubes, we considered the layout of the circuit. Since there is less space available on the PCB board, we used patch infrared emitting tubes. The patch can greatly reduce the size of the PCB and greatly improve the production efficiency.
The emitting tube uses the IR67-21C/TR8 infrared emitting head produced by Everlight. The basic parameters of the emitting head are as follows:
wavelength: 940nm;
radiation intensity: 1.5mW/sr @ 20mA;
The figure below shows the schematic diagram of the infrared emitting module.

Figure 2.44 Schematic diagram of infrared control moduleFigure

2.45 Actual diagram of IR67-21C/TR82.1.3.13.3
Schematic diagram of home appliance control function boardFigure

2.46 Schematic diagram of home appliance control function board1Figure

2.47 Schematic diagram of home appliance control function board2Figure

2.48 Schematic diagram of home appliance control function board3
2.1.3.13.4 Assembly diagram of home appliance control function boardFigure

2.49 Top assembly diagram of home appliance control function boardFigure

2.50 Bottom assembly diagram of home appliance control function board2.1.3.13.5
Actual diagram of home appliance control function boardFigure

2.51 Actual diagram of home appliance control function board3
Hardware Design3.1
Functional Requirements3.1.1
Intelligent Control CenterThe
intelligent control center is mainly composed of an intelligent gateway. The intelligent gateway should be able to run the Linux operating system. On the basis of the Linux operating system, it should run related services and execute control instructions from the APP.
3.1.2 Smart Home Security System
The smart home security system includes access control function. After the user sends the door opening command, it needs to respond to the command and complete the door opening operation.
3.1.3 Smart Lighting System
The smart lighting system needs to meet the basic lighting needs of the home. First of all, the lights need to complete the basic switch operation, and each light should be able to be controlled separately. At the same time, in order to meet the user's needs to adjust the brightness and color of the light, the light should be able to change color independently.
3.1.4 Smart HVAC System
Through the smart HVAC system, users can complete the relevant operations of the air conditioner in the room in the APP: full on and off, mode control, temperature, wind speed setting.
3.1.5 Smart Ventilation System
In order to ensure the air circulation in the user's home, the smart ventilation system is added. The user can control the switch and speed of the fan in the room. The fan supports stepless speed regulation to further meet the requirements for wind speed.
3.1.6 Smart Curtain Control System
Through the curtain control system, users can remotely control the curtains at home on the mobile phone. While automatically controlling, the curtains can be manually controlled, which is more convenient to use.
3.1.7 Smart home appliance control system
In addition to the above functions, the smart home appliance control system should be able to control the home appliances controlled by infrared emission, which can achieve compatibility with the original home appliances and greatly increase the intelligence of the home.
3.2 Hardware schematic design
3.2.1 System overview
This system is controlled by Espressif's ESP32-C3 microcontroller as the core. Through this chip, it connects to the WIFI hotspot in the home, connects to the MQTT server in the smart gateway, receives commands sent by users, controls the relevant home appliances on the function board circuit, or sends relevant data of the home appliances on the function board, such as temperature and humidity, door lock status, etc.
In the smart control center, the team used the ready-made Raspberry Pi 4B solution. By deploying services on the Raspberry Pi 4B, the overall delivery of smart home is realized. Users only need a control center and a wireless router to build the simplest smart home network.
3.2.2 Circuit design block diagram
In this project, the hardware design uses structured design, and all functions can be basically divided into 14 modules as shown in the figure below.

Figure 3.1 Circuit Module
Based on the above modules, the team independently developed four function boards, namely, access control function board, lighting control function board, fan control function board, and home appliance control function board. The following pictures show the circuit design block diagrams of the four function boards.

Figure 3.2 Access control function board circuit design block diagram

Figure 3.3 Lighting control function board circuit design block diagram

Figure 3.4 Fan control function board circuit design block diagram

Figure 3.5 Home appliance control function board circuit design block diagram
3.2.3 Main control chip circuit design
In order to achieve rapid development, the team used the ESP32-C3-WROOM-2 module, which is equipped with an ESP32-C3 microprocessor and the microprocessor's clock circuit, RF circuit and onboard WIFI antenna.
The figure below shows the schematic diagram of the module's peripheral circuit.

Figure 3.6 Main control chip module peripheral schematic diagram
The left side is the ESP32-C3-WROOM-2 module with the position number U3, and the right side is the pin pull-up resistor and reset button required in the chip manual.
3.2.4 Power supply module design
The power supply module mainly includes input connectors, TVS transient suppression diodes and step-down chips. Considering the safety and convenience of accessing equipment, the system is powered by 5V. At the same time, TYPE-C port and KF128 terminal block are added to maximize the convenience of power supply and reduce the requirements for home power supply.
In the chip power supply part, the chip needs to be powered by 3.3V. A SY8089A1AAC DCDC chip launched by Silergy is used. The maximum input voltage is 5V. By adjusting the voltage of the FB pin, the output voltage can be adjusted. Here the output voltage is 3.3V.
At the input end, in order to prevent static electricity and lightning from breaking through the devices on the PCB, a TVS transient suppression diode is added to absorb surges from the outside and protect the devices on the board.

Figure 3.7 Schematic diagram of power supply module connector

Figure 3.8 Schematic diagram of power supply module
3.2.5 Unlock circuit design
The unlock circuit includes connectors, unlock circuit and unlock detection circuit. In order to protect the microcontroller and power supply, MOS tube is not used to control the lock to open. Instead, an H-bridge chip RZ7899 is used. The chip has built-in overcurrent protection circuit and freewheeling diode, which is more suitable for this project.
In the unlock detection circuit part, the LOCK_STATE pin in the figure below inputs the unlock signal. When the door lock is opened, the level of the pin will change accordingly, and the opening and closing of the door lock can be detected.

Figure 3.9 Schematic diagram of unlock circuit
3.2.6 Infrared control module design
The infrared control module is a function on the home appliance control function board, which is used to send infrared signals to control home appliances such as air conditioners and televisions. It uses 5 infrared emitting diodes, and controls its opening and closing through an AO3400 N-channel MOS tube.

Figure 3.10 Schematic diagram of infrared control module3.2.7
Design of boost moduleIn
order to power the 12V fan, the team added a boost module. The boost module uses the MT3608 boost chip to boost the input 5V to 12V to power the fan.

Figure 3.11 Schematic diagram of boost
module3.2.8 Design of buzzer moduleIn
order to meet the needs of the device to prompt users, the project added a buzzer module, which controls the passive buzzer through an AO3400 NMOS to make the buzzer sound.

Figure 3.12 Schematic diagram of buzzer module3.2.9
Design of button circuitIn
order to meet the needs of chip network configuration, the project added a button circuit. Through the button, the function board can be switched to the burning mode, or by pressing some buttons on the board, the network configuration mode can be entered. In subsequent updates, the buttons can also be provided to users to complete some local control.

Figure 3.13 Schematic diagram of button circuit
3.2.10 Design of relay control module
In the access control board, in order to control the equipment related to access control, a relay is added to the project, with a maximum current of 5A. The relay control module is composed of an optocoupler, SS8050 transistor, and relay. The figure below shows the schematic diagram of the relay control module. The optocoupler converts the signal sent by the microcontroller into an optical signal, which is converted into an electrical signal on the other side to control the conduction of the 8050 below to achieve the control of the relay. At the same time, a freewheeling diode needs to be added at both ends of the relay power supply to prevent reverse current from damaging the onboard circuit.

Figure 3.14 Schematic diagram of relay control module
3.2.11 Design of indicator light module
The indicator light module is composed of two WS2812 RGB LEDs. The microcontroller can send control signals to control these indicators to inform the user of the current status, so that the user can determine the problem.

Figure 3.15 Schematic diagram of indicator light module3.2.12
Light module designThe
light module is a device on the light control function board, mainly composed of WS2812 RGB LED. Users can issue light control instructions and provide the R, G, B values of the LED light to the microcontroller to control the light to display the specified color. The figure below shows the schematic diagram of the light module.

Figure 3.16 Schematic diagram of light module3.2.13
Fan control circuit designThe
fan control circuit consists of an H-bridge drive circuit, a PWM speed regulation circuit, an INA199 current sampling circuit, and a fan speed measurement circuit. The figure below shows the schematic diagram of the fan control circuit.
First, the 5V voltage is boosted to 12V through the boost module, and then the start and stop of the fan is controlled through the H-bridge drive circuit. The PWM speed regulation circuit sends a PWM speed regulation signal from the microcontroller to control the fan speed. The INA199 current sampling circuit and the fan speed measurement circuit provide corresponding implementation for the fan speed measurement function.

Figure 3.17 Schematic diagram of fan control module3.2.14
Temperature and humidity acquisition module designThe
temperature and humidity acquisition module consists of a SHT30 chip. SHT30 integrates temperature and humidity acquisition circuits, and communicates externally through the I2C interface. It can provide extremely high reliability and excellent long-term stability, and has the advantages of low power consumption, fast response, and strong anti-interference ability. The figure below shows the schematic diagram of the temperature and humidity acquisition module.

Figure 3.18 Schematic diagram of temperature and humidity acquisition module
3.2.15 Curtain control module design
The curtain control part currently uses the mature curtain motor solution in the industry. At the control end, the curtain motor control line is short-circuited through two relays to realize the opening, closing, and stopping of the curtain. The figure below shows the schematic diagram of the two relays and connectors.

Figure 3.19 Schematic diagram of curtain control module3.3
Hardware circuit board design3.3.1
Design of access control function boardThe
following figure shows the PCB assembly diagram of access control

function boardFigure 3.20 Top assembly diagram of access control function

boardFigure 3.21 Bottom assembly diagram of access control function board3.3.2
Design of lighting control function boardThe
following figure shows the PCB assembly diagram of lighting control function boardFigure

3.22 Top assembly diagram of lighting control function boardFigure

3.23 Bottom assembly diagram
of lighting control function board3.3.3 Design of fan control function boardThe
following figure shows the PCB assembly diagram of fan control function boardFigure

3.24 Top assembly diagram of fan control

function boardFigure 3.25 Bottom assembly diagram of fan control function
board3.3.4 Design of home appliance control function boardThe
following figure shows the PCB assembly diagram of home appliance control function boardFigure

3.26 Top assembly diagram of home appliance control function boardFigure

3.27 Bottom assembly diagram of home appliance control function
board3.4 Microcontroller software
design3.4.1 Software Overview
In the software design part, thanks to the modular design of the hardware part, the software part has basically realized modular design. The following will describe in detail the software design of the smart home remote control system.
Software development language: C language
Software development framework: ESP-IDF
Software development tool: VSCode
3.4.2 WIFI connection module design
When connecting to the controlled MQTT server, you need to connect to WIFI first, and then connect to the MQTT server. The figure below shows the flowchart of the WIFI connection part.

Figure 3.28 WIFI connection module flow chart
3.4.3 Buzzer control module design
This part uses the LEDC peripheral of ESP32, and generates PWM waves through LEDC to drive the passive buzzer to make a sound. The figure below shows the schematic diagram of this part.

Figure 3.29 Buzzer control module flow chart
3.4.4 Network configuration module design
In order to connect different modules, the system has designed a network configuration module. The user connects to the WIFI that needs to be configured through the Android terminal, enters the WIFI password, and then clicks on the network configuration. The microcontroller will receive the network configuration signal from the user, and then save the SSID and password in it to NVS for the next connection to WIFI. The figure below shows the schematic diagram of the network configuration module.

Figure 3.30 Network distribution module flow
chart3.4.5 Temperature and humidity acquisition module designThe
temperature and humidity acquisition module is used to collect temperature and humidity in the home. In order to obtain data from the temperature sensor, the I2C bus protocol is required. The following figure shows the software flow chart of the temperature and humidity acquisition module.

Figure 3.31 Temperature and humidity acquisition module acquisition flow
chart3.3.6 Device control module designThanks
to the modular design, the control module of each device is basically the same. The figure below shows the flow chart of the device control module, which can basically be abstracted into three steps: initializing peripherals, processing MQTT instructions, and controlling peripherals.

Figure 3.32 Device control module flow chart