1 System Structure
The power control system consists of a remote control and a socket node, and its working principle is shown in Figure 1. When the user is at home, the socket is controlled by the remote control in a radio frequency manner. After the socket node receives the signal, the microcontroller decodes it and, based on the result, powers on and off the socket with a specific number, so that the connected electrical appliances are started or turned off. When the user is far away from his residence, he can send a text message to the remote control through the GSM network. After the microcontroller reads the information, it transmits the information to the indoor wireless network through the radio frequency chip, so that the socket at the corresponding address is controlled. It can be seen that the remote control belongs to the gateway node in the entire smart home system. On the one hand, it forms an indoor radio frequency local area network with the socket node, and on the other hand, it is connected to the GSM network, extending the remote control distance. The internal structure of the remote control is shown in Figure 2, including temperature and humidity detection circuit, clock module, nRF905 radio frequency transceiver module, GSM module and other functional circuits, all of which are connected to the control core LM3S811. The microcontroller adopts the ARM Coaex-M3 architecture. Relying on the high-density Thumb-2 instruction set, the memory overhead is greatly reduced and the operating system porting is also more convenient.
Figure 1 Working principle of remote control socket
Figure 2 Remote control structure diagram
The socket node mainly realizes RF communication with the remote control and on/off control of the relay. Its structural block diagram is shown in Figure 3. The smoke sensor in the socket is used to prevent fire hazards. Once smoke or flammable gas is detected, the corresponding relay on the socket will be disconnected and report to the remote control through the RF transceiver module. After the remote control receives the information, it will promptly remind the user to take corresponding measures through the SMS function of the GSM module to prevent the occurrence of danger or further expansion of property losses. Due to the small workload on the socket end, considering both cost and performance, this system uses the STC12C5620AD microcontroller as the main control chip on the socket end.
Figure 3 Socket node structure diagram
2 Hardware Circuit Design
2.1 Temperature and humidity detection circuit
This system uses temperature sensor LM35 and humidity measurement module CHM-02 for environmental monitoring. The voltage output of LM35 is linearly related to Celsius temperature, and can achieve a measurement accuracy of ±1/4℃ at room temperature without calibration. The CHM-02 module can detect humidity in the range of 20~95%RH at 0~70℃, and the measurement accuracy at room temperature is 5%RH. The interface diagram of the temperature and humidity sensor and MCU is shown in Figure 4. Since the analog signals output by the two sensors are within the detection range of the A/D sampling circuit on the MCU chip, the output ends of the two sensors are directly connected to the two ADC pins of the MCU. The use of analog sensors not only makes full use of the on-chip resources of the controller, but also improves the utilization rate of subroutines.
Figure 4 Schematic diagram of the interface between the temperature and humidity sensor and the MCU
2.2 Smoke Detection Circuit
The smoke sensor MQ-2 is based on the electrochemical properties of SnO: and has good detection sensitivity for combustible gases and smoke. The schematic diagram of the smoke detection circuit is shown in Figure 5. Before normal operation, MQ.2 needs to energize and preheat the Hh poles of the internal heating wire. In order to prevent the internal signal line temperature from being too high due to excessive heating current, the heating wire is connected in series with a 100 Ω resistor. When the smoke or combustible gas in the environment exceeds the warning threshold, the conductivity between the AB poles of the sensor increases rapidly, and the voltage obtained by the load resistor m in series with it also increases accordingly. After the voltage signal is amplified by the low-power op amp TLC27M2, an analog output corresponding to the smoke or combustible gas concentration is obtained, which is finally connected to the ADC module of the controller for quantization. [page]
Figure 5 Schematic diagram of smoke detection circuit
2.3 Clock Module
In addition to displaying the system time, the clock module can also time the power on and off of a single socket. The schematic diagram of the clock circuit is shown in Figure 6. The DS1302 communicates with the MCU in serial mode. To ensure the stability of signal transmission, the interface has been pulled up. The chip is powered by dual power supplies. When the main power supply is working normally, the backup power supply can be charged with a trickle current; when the power is off, the backup power supply is started to avoid clock stagnation caused by sudden power outages. Considering the convenience of use, the remote control is powered by a lithium battery. The main power pin VCC2 of the DS1302 is connected to the 3.3 V output of the integrated regulator, while the backup power pin VCC1 is connected in series with a 4700 μF capacitor, and the two power pins are isolated by a diode. Since the chip consumes very little power, the discharge of the capacitor can temporarily maintain the operation of the chip during the battery replacement process.
Figure 6 Clock circuit schematic
2.4 RF transceiver module nRF905
The RF transceiver module is the bridge connecting the socket and the remote control. The nRF905 integrated transceiver can be configured and used in three ISM bands with very low power consumption. All nodes in this system are set to work in the 433 MHz band. The schematic diagram of the RF transceiver circuit is shown in Figure 7. The SMA interface is used to connect a single-ended antenna with a characteristic impedance of 50 Ω, which is conducive to the omnidirectional radiation of the signal. The single-ended antenna is also called an unbalanced antenna. Its main reference point is the signal ground, and the antenna interface of the nRF905 (pins ANT1 and ANT2) is a differential RF output port. In order to maintain signal balance and ensure impedance matching of the two ports, a balun circuit is added between the two to adjust the characteristics of the chip output end.
Figure 7 RF transceiver circuit
2.5 GSM Communication Module
Combining the short-range RF network with GSM technology not only takes advantage of the flexible configuration of the short-range RF network, but also takes advantage of the communication distance of GSM technology. The core of the GSM communication circuit is the SIM300 module, and its peripheral circuit is shown in Figure 8.
Figure 8 GSM communication circuit schematic
Schematic diagram SIM300 communicates with MCU through the serial port, and the 22 Ω resistor connected in series between the module and the SIM card is used for impedance matching. To ensure the transmission quality of the signal, the SIM card data line is pulled up, and the SMF05C type electrostatic suppressor connected in parallel with the pin is used for electrostatic protection. The 100 μF tantalum capacitor and 1 μF ceramic capacitor connected in parallel between the power supply and the ground are used to remove low-frequency burrs, and to a certain extent, take into account the high-frequency characteristics. Pressing the button S1 will lower the potential of the PWRKEY pin for about 2 s, which can complete the power-on and power-off of the module. The current state is indicated by the light-emitting diode connected in series with the VDD_EXT pin. In order to facilitate program control, a triode switch circuit is added on the basis of the original button. When the module works abnormally, the state of the PWR port can be rewritten by software to achieve automatic reset of SIM300.
3 Software Design
The remote control and the socket are both nodes in the entire RF wireless network, but the difference in hardware structure determines the difference in their functions and status, and also makes the two different in software design. [page]
3.1 Remote Control Node Programming
The remote control is the control core of the system and the link between the user and the socket. Therefore, there are many concurrent modules in the program and the tasks are heavy. Considering that the ARM processor used in the remote control can provide comprehensive support for the operating system, the use of the μC/OS-Ⅱ operating system to schedule multiple tasks in the node can effectively ensure the real-time and stability of the system and is also conducive to the expansion of functions. Before the operating system is transplanted, the tasks need to be divided, and each function corresponds to a system task. At the same time, the problem of frequent scheduling caused by excessive division should be avoided. The program flow of the remote control node is shown in Figure 9, which contains 7 tasks. The tasks are synchronized and communicated through semaphores, message queues, message mailboxes, etc. From the user's point of view, these tasks are executed concurrently.
Figure 9 Remote control node program flow chart
The priority of the key scanning task is the highest among all user tasks. The key values entered by the user are read through the interrupt method, and the data is stored in the message mailbox KeyMbox. If the number keys 1-6 are pressed, the RF sending task is notified to process; if the clock setting button is pressed, the clock is adjusted or the timer is set. The clock timing task is used to obtain the clock output value of DS1302. After the timing time is reached, a message is sent to notify the RF sending task to process, and it is automatically suspended after completion. The RF sending task is to send the power on and off control signal to the corresponding numbered socket in the RF mode according to the control code obtained in other tasks, and then wait for the socket end to return the action information. If there is no feedback after the timeout, it will be resent once, and the task will be suspended after resending 3 times. The danger alarm task needs to undergo the same frequency carrier detection and address matching confirmation before it starts to receive the RF signal, and then send the information to the mailbox. After decoding and confirming the danger alarm mark, it will notify the user in the form of a short message through the GSM module. The SMS receiving task is responsible for receiving user text messages and storing them in the message mailbox GSMMbox. Through the AT command "AT+CMGR=I", only the short message with serial number 1 is read each time. After successfully extracting the control code (including the socket ID number and the switch action code), the message is deleted and the message is transmitted to the RF task. The environmental monitoring task is responsible for cyclic sampling of indoor temperature and humidity information. Although the linearity of the temperature sensor is good, the external environment has a greater impact on the humidity sensor, and its output voltage value needs to be piecewise linearized. The data is stored in the message queue, and the final result is the arithmetic mean of the three measured values. The LCD display task has the lowest priority. After the above tasks are completed, it is responsible for displaying the final status of each socket, clock information, and indoor temperature and humidity measurement results.
3.2 Socket Node Programming
The program flow of the socket node is shown in Figure 10, where the most important work is to realize the reception and transmission of RF signals. When there is no smoke alarm, nRF905 enters the receiving mode and listens to the channel at the same time; if the same frequency carrier is detected and the data packet address is valid, the reception is started; when the CRC check result is correct, the hardware will automatically remove the preamble, check code and address code of the data packet, and notify the MCU that the data is ready, and then the MCU reads the received information through the SPI serial bus.
Figure 10 Socket node program flow chart
The transmission of RF signals is essentially the reverse process of reception. When nRF905 enters standby mode, the MCU transmits the address and data information to the transmission register of the RF chip, and starts the chip to enter the RF transmission mode. Then the hardware on the chip automatically completes the data packaging, encoding, modulation and transmission tasks. After a frame of data is sent, the RF chip enters standby mode and waits for the next activation. Each reception or transmission process of the RF circuit is accompanied by the on or off action of the relay. Under default conditions, the smoke sensor is enabled. In order to prevent users from smoking indoors and causing system misjudgment, the smoke detection function can also be set to disabled.
4 Testing and Analysis
In the house shown in Figure 11, a field test was conducted. Six sockets and one remote control were placed in seven areas, A to G. In order to evaluate the anti-interference ability of the system, two interference sources with frequencies of 432 MHz and 434 MHz were placed at the junction of each area. The position of the remote control was changed, and each of the six sockets was remotely controlled 200 times, and the feedback signal from the socket was recorded. If an error message was returned or no feedback was given, it was recorded as a packet loss.
Figure 11 Network node distribution diagram at the test site
The results show that the average bit error rate of the remote control in areas C and E is slightly higher than that in other areas; when the remote control is in area G, the average bit error rate is the lowest and the effect is the best.
5 Conclusion
This system realizes intelligent wireless control of household sockets. Without changing the internal structure of the original household appliances, users can control the power-on and power-off status of the sockets through radio frequency, SMS, timing, etc. When a fire or combustible gas leak occurs indoors, the socket can automatically cut off the power. The entire system has no special requirements for the control object and has strong adaptability. It is a cheap smart home solution.
Previous article:Transplantation of μC/OS-Ⅱ on ARM Series MCU S3C44B0x
Next article:MiniGUI transplantation based on OMAP5912 development board
- Popular Resources
- Popular amplifiers
- Practical Development of Automotive FlexRay Bus System (Written by Wu Baoxin, Guo Yonghong, Cao Yi, Zhao Dongyang, etc.)
- ARM Cortex-M4+Wi-Fi MCU Application Guide (Embedded Technology and Application Series) (Guo Shujun)
- Key technologies for inverter control of new energy access to smart grids
- TI-DSP multi-core technology and real-time software development
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- The ultimate setup for your next Python project
- 12. [Learning LPC1768 library functions] PWM experiment
- How to Actually Build a Drone
- TLV5616 has no output voltage
- What is the DMD lens action mechanism of the projector?
- Design of Watchdog Circuit Based on DSP Processor TMS320F2812
- Seeking long-term cooperation engineers to do part-time STM32 51 8S FPGA image processing
- 【K210 Series】6. Performance Test
- Capacitor selection problem after single-phase rectifier bridge
- Sensortile.box installation and testing