Design and implementation of IoT intelligent computer room system

Publisher:平安心境Latest update time:2013-01-21 Source: 电子科技 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

    Since Premier Wen Jiabao proposed "Perceiving China" in Wuxi in August 2009, the Internet of Things has been officially listed as one of the country's five emerging strategic industries and written into the "Government Work Report". The Internet of Things has received great attention from the whole society in China, and its level of attention is incomparable to that in the United States, the European Union, and other countries. The development and maturity of intelligent computer rooms will greatly improve the convenience and reliability of computer room management.
    This paper briefly describes the main technologies, design methods and functional implementation required for system implementation. It mainly includes the design of communication protocols, hardware circuit design and software design methods, and finally realizes the remote control of intelligent computer rooms, such as remote monitoring of indoor temperature and humidity, remote reception of human intrusion alarms, remote control of light switches, and control of wireless remote control cars.

1 System Overall Design
1.1 System Overview
    Today's intelligent computer room system contains a wealth of functions, but there is no unified standard. According to the function, the intelligent computer room mainly includes the following aspects: computer room network system, general control management system, lighting control system, computer room security system, and computer room environment monitoring system.
    This paper discusses the following systems from the technical level of specific function realization: environmental physical quantity detection system, security system, and lighting control system.
1.2 Design Requirements
    In order to facilitate the expansion and transformation of the system, the required functions will be realized in a modular way, and each module is responsible for one or several similar functions. All modules communicate wirelessly, and each module must have its own main control MCU, power supply and specific components to realize the function.
    Since the gateway has no wireless function, a module is set up in the system to be responsible for communication relay. Communication relay includes two aspects: communication with each functional module; communication with the gateway. This module mainly receives the control command of the host computer through the gateway and transmits it to the corresponding execution module; or receives information from each module and transmits it to the host computer.
    In order to expand the detection range of environmental physical quantities, an autonomously movable platform is added, a wireless remote control car, on which sensors or wireless cameras can be installed. At the same time, in order to increase the operability of the system and reflect the people-oriented design concept, the system also needs to add a special module-a remote control terminal, which is responsible for displaying all the information of the system and can control other functional modules.
1.3 System Function Division
    The functions implemented by the entire system are: environmental physical quantity detection, selecting common temperature and humidity; security, selecting representative human intrusion detection; lighting control, controlling the switch of the light; mobile platform, selecting a wireless remote control car.
    In order to save resources, the three functions of temperature, humidity and human intrusion detection are implemented in one module. The control of the light switch is implemented by one module. In summary, the system requires a total of 5 modules, namely: communication relay module, remote control terminal module, temperature, humidity and human intrusion detection module, light control module, and wireless remote control car. The organizational structure of the system is shown in Figure 1.

a.JPG

2 Hardware Design
2.1 Basic Modules
    The five functional modules are built on the basic modules, and each module realizes specific functions by expanding the basic modules. The basic modules include the MCU minimum system, wireless communication module and power module.
    1) MCU minimum system
    MCU is the core of each module system. It is mainly responsible for processing various information and controlling various peripheral devices. Therefore, choosing a suitable MCU is the key to realizing the functions of the entire system. This design uses the most common and most versatile 51 microcontroller on the market as the main control MCU. In order to give the system more room for expansion, a 51 microcontroller with diverse peripheral functions should be selected. After actual investigation and comparison, the STC12C5A60S2 microcontroller was selected as the main control microcontroller for all modules in this design.
    The STC12C5A60S2 microcontroller has rich peripherals, including 2 full-duplex asynchronous serial communication (UART) interfaces, 2 pulse width modulation (PWM) outputs, a synchronous serial peripheral communication (SPI) interface, 8 10-bit precision A/D conversion, etc., and the microcontroller supports programming through the asynchronous serial interface. These functions greatly simplify the development and design of the system. b.JPG
    Figure 2 shows the minimum system of the STC12C5A60S2 microcontroller, which includes the following parts:
    ① External crystal oscillator circuit
    Because asynchronous serial communication is used, a 11.0592MHZ crystal oscillator is selected as the external clock source, which can ensure the correctness of asynchronous serial communication.
    ② Reset circuit
    The reset circuit includes power-on reset and key reset. Among them, power-on reset is to reset the microcontroller when the system is just turned on; key reset is used to manually reset the microcontroller when the system is running abnormally.
    ③ Power filter circuit
    The power filter circuit consists of two filter capacitors, which is an effective means to prevent power ripple from interfering with the microcontroller.
[page]

    2) Wireless communication module
    The wireless communication module is the "bridge" for all functional modules to communicate with each other. As shown in Figure 3, MCU A transmits data to wireless communication module B, which transmits data to wireless communication module C in the form of electromagnetic waves, and finally, wireless communication module C transmits data to MCU D. In this way, the data transmission between module one and module two is completed.

c.JPG


    At present, the common wireless communication modules on the market are divided into two types according to the transmission mode: non-transparent transmission and transparent transmission. Combined with the actual situation of this design, it is more appropriate to choose a transparent transmission module, so that the communication protocol of this design can be set freely. After actual investigation and comparison, the LSD-RFMC-B401-A2 wireless transparent transmission module was selected. This module is a high-performance RF transceiver that operates in the 470 MHz frequency band and has full transparent transmission. It can configure various serial port data formats according to actual applications and can achieve unlimited data length transmission.
    3) Power module
    power is a necessary condition for the entire system to maintain normal operation, so a reliable power supply is necessary. Since all components in the entire system do not work at the same voltage, different voltage regulator chips are required to power each component. After actual investigation, it is known that the circuit requires two voltages of 5 V and 3.3 V. The two voltage regulator chips LM2596_5.0V and LM2596_3.3V are selected as the power supply chips for each module.
2.2 Communication relay module
    The communication relay module realizes information interaction with the host computer through the gateway, so a way to communicate with the gateway is required. The design adopts the basic module and adds the function of serial asynchronous communication with the gateway. Since the asynchronous serial communication interface of STC12C5A60S2 uses TTL level, and the external interface of the gateway platform uses RS232 level, a dedicated level conversion chip MAX232 is required. As shown in Figure 4, MAX232 is connected to the asynchronous serial communication interface 1 of the STC12C5A60S2 microcontroller, and the other end is connected to the standard DB9 socket.

d.JPG


2.3 Temperature, humidity and human intrusion detection module
    The temperature, humidity and human intrusion detection module is realized by adding temperature and humidity detection sensors and human pyroelectric detection sensors to the basic module. The temperature and humidity detection uses the DHT11 temperature and humidity sensor, and the human intrusion detection is realized by a dedicated human pyroelectric sensing module. The
    working mode of the human detection module is that when someone enters the detection range, the output level of the status pin of the module changes from high to low, and when the person walks out of the range, the output level of the status pin recovers from low to high. With this feature, the status pin can be directly connected to the external interrupt 0 pin of the STC12C5A60S2 microcontroller. When the module detects a human body, the status pin generates a falling edge level, triggering the external interrupt 0 of the microcontroller. Considering that when the human body walks out of the detection range, in order to let the system know in time, the status pin of the module is connected to the external interrupt 1 pin of the ST12C5A60S2 microcontroller after connecting it to the inverter. In this way, when the human body walks out of the detection range, the status pin of the human body detection module generates a rising edge level, which is inverted by the inverter and becomes a falling edge level, triggering the external interrupt 1 of the ST12C5A60S2 microcontroller. The circuit schematic diagram of the human body detection module is shown in Figure 5.

e.JPG


2.4 Light Control Module
    The light control module is mainly responsible for turning on and off the indoor lights. This involves the problem of weak voltage controlling strong voltage. The voltage of the module microcontroller is 5 V, while the voltage of the indoor lights is 220 V, so a relay is needed to turn the lights on and off. This design uses two common 5 V single-pole single-position relays to control the switches of the two lights.

f.JPG


    As shown in Figure 6, the light control module is a basic module with two relays controlled by the two I/O ports P2.1 and P2.0 of the STC12C5A60S2 microcontroller added to it. When the output of P2.0 is low, relay 1 is powered on, thereby connecting the two pins of the JI socket. When the output of P2.1 is low, relay 2 is powered on, thereby connecting the two pins of the J2 socket. In this way, the light can be turned on and off through the two sockets J1 and J2.
2.5 Wireless remote control car
    The wireless remote control car is a movable platform. Various sensors can be extended on the car, so that the detection range of the sensor can be expanded by moving the car. The car is powered by two DC motors, which are driven by the common dual H-bridge driver chip L298N. The microcontroller can indirectly control the movement direction and speed of the car by controlling the L298N chip. The wireless remote control car is equipped with a wireless camera, which can realize remote control. In front of the car, add some small lights and turn them on when needed so that the camera can capture dark places. The specific module is implemented by adding motor control circuit, car light control circuit and camera power control circuit to the basic module.
2.6 Remote control terminal module
    The remote control terminal is mainly responsible for displaying various information of the system and controlling other functional modules, and provides an alarm function when someone enters the detection range. For the display part, considering the small amount of information, a 1602 character LCD screen is used for display. This character LCD screen can display 32 characters at a time; for the remote control part, considering that there are many functions to be controlled and the I/O port resources of the microcontroller need to be saved, a 4x4 matrix keyboard is used. The keyboard can realize 16 key inputs, but only uses 8 I/O ports of the microcontroller. For the alarm function. A buzzer can be used to achieve it.

3 Software Design
3.1 Communication Protocol Design
    The communication protocol mainly includes two aspects: 1) The communication protocol between the communication relay module and the host computer; 2) The communication protocol between each module. Regardless of the communication, the correctness and parsability of the communication data should be guaranteed first.
3.1.1 Communication Relay and Host Computer Communication Protocol
    The communication between the communication relay module and the host computer includes: sending acquisition information to the host computer and receiving commands from the host computer. The received commands should be as short as possible, because the resources of the microcontroller are limited and it is not suitable for processing long strings.
    1) Upload Information Protocol
    The lower computer uploads data in the form of a string. Each string of data must meet the following two conditions at the same time:
    ① The string length is 9 characters;
    ② Start with "(" and end with ")".
    If the above conditions are not met, the upper computer should give up processing the data and immediately request the lower computer to resend the data. The string format is: (0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF), and the meaning of each byte is shown in Table 1.

g.JPG


    If the byte data is "0xEE", it means that there is no corresponding byte information in the uploaded data.
    2) Control command protocol
    control commands are also transmitted in the form of strings. Each command string must meet the following two conditions at the same time:
    ① The string length is 5 characters;
    ② Start with "(" and end with ")".
[page]

    If the above conditions are not met, the relay module shall give up processing the command. The command string is in the form of (acb). "abc" is the command information, which is the abbreviation of an English instruction. For example, to turn on light 1, the English is "open light 1", which is abbreviated as "oll". If you want to turn off light 1, send the string "(cl1)". If the abbreviated command is less than 3 characters, use the character "0" to complete it. All control commands and their meanings are shown in Table 2.

h.JPG


3.1.2 Module communication protocol
    Since a transparent transmission module is used, the information sent by one module to another module can be received by all other modules, so an address mechanism should be added to the information, and each module has its own address. When a module receives data, it should first determine whether the receiving address in the data is consistent with its own address. If it is consistent, it will continue to process the data, otherwise it will abandon the data.
    Considering the various situations of inter-module communication, the inter-module communication information is summarized into two types: command and status information, and the corresponding protocols are also two types.
    1) The relay module or remote control terminal module sends a command
    in the form of a string. The command string should meet the following two conditions:
    ① The string length is 7;
    ② The string starts with "(" and ends with ")".
    If the command string received by other modules does not meet the above two conditions, the command is abandoned. The form of the command string is: (xyabc), where "x" represents the address of the receiving module, "y" represents the address of the sending module, and "abc" is the abbreviation of the command to be executed, the same as the string in brackets of the "Send Command" item in Table 2. The module address convention is shown in Table 3. The addresses of the communication relay module and the remote control terminal module in the table are the same, so that the information data sent by other modules can be processed at the same time.

i.JPG


    2) The relay module and the remote control terminal module receive status information.
    Since the length of status information sent by other modules to the relay module and the remote control terminal module is different, the longest status information shall prevail, that is, the length of the status information of the temperature, humidity and human body detection module shall prevail. If the length of the status information of other modules is insufficient, the character "0" shall be used to complete it. The command string shall meet the following two conditions:
    ① The string length is 9;
    ② ​​The string starts with "(" and ends with ")".
    If the command string received by the communication relay module and the remote control terminal module does not meet the above two conditions, the information shall be abandoned. The information string is in the form of: (xyabcde), where "x" represents the address of the receiving module, which should be "0x11" here, and "Y" represents the address of the sending module. "ahede" represents the status information of the sending module.
    For the temperature, humidity and human body detection module, "ah" represents temperature in ASCII code, "cd" represents humidity in ASCII code, "a" and "c" represent tens, and "b" and "d" represent units. The first half byte of "e" indicates whether human detection is turned on, and the second half byte indicates whether a person enters the detection range. For the light control module, the first half byte of "a" indicates the on/off status of light 1, and the second half byte indicates the on/off status of light 2. For the wireless remote control car, the first half byte of "a" indicates the on/off status of the car's headlights, and the second half byte indicates the on/off status of the camera.
3.2 Communication relay module
    The communication relay module mainly handles two things: 1) receiving commands from the host computer and sending them to the corresponding module according to the protocol based on the content of the command; 2) receiving information from each module and sending it to the host computer according to the protocol.
3.3 Temperature, humidity and human intrusion detection module
    This module mainly implements two functions: 1) temperature, humidity and human intrusion detection, and transmitting the detection information to the relay module and the remote control terminal to achieve real-time display; 2) processing the control commands forwarded by the relay module. The program uses two flags to distinguish whether to upload detection information or process control commands. When it is determined to be a control command, it will analyze the command and execute it. After the execution is completed, the new status information will be returned to the relay module and the remote control terminal module, and then wait for the next command.
3.4 Light Control Module
    The light control module realizes the on and off operation of controlling lights 1 and 2. In the program, a flag is used to determine whether the received information is a control command. If so, the specific command is determined and executed. After the execution is completed, the status information is updated according to the protocol, and the status information is returned to the relay module and the remote control terminal module according to the protocol, and then wait for the next command.
3.5 Wireless Remote Control Car
    The wireless remote control car module realizes two major functions: car motion control; car headlight and camera on and off control. In the program, a flag is used to determine whether the received information is a control command. If so, the specific command is determined. If it is a motion command, the corresponding run command is executed, and the motion is stopped after a delay of 600 ms, and then the next command is waited; if it is not a motion command, after executing the command, the status information is updated according to the protocol, and the status information is returned to the relay module and the remote control terminal module according to the protocol, and then the next command is waited.
3.6 Remote Control Terminal Module
    The remote control terminal module implements three major functions: displaying system status information on the character LCD screen; key detection and sending commands; starting and stopping the buzzer. After the program is started, it always checks whether a key is pressed. If a key is pressed, it detects the key and transmits the command corresponding to the key to other modules according to the protocol, and then delays 500 ms to wait for the next key press. If no key is pressed, it checks whether the flag bit Flag is equal to 1. If Flag is equal to 1, it means that the status information of other modules has been received, and then the corresponding content of the LCD screen is updated according to the content of the information. If the information from the temperature, humidity and human body detection module detects that a human body has entered the detection area, the buzzer is turned on for 2 s.

4 System Test
    The system test is divided into 3 parts: 1) Based on the communication relay module: send normal and legal commands from the host computer and observe the phenomenon; then send illegal commands and observe the phenomenon. 2) Based on the remote control terminal module: press the buttons in sequence and observe the phenomenon. 3) Based on the human body sensing module: test the human body detection function. For the sake of convenience during the test, the communication relay module is directly connected to the PC with a serial port cable, and the serial port debugging assistant is used to operate and observe.
4.1 Communication relay module test setting
    Send the string "(g00)": the car moves forward a short distance.
    Send the string "(ol1)": light 1 turns on.
    Send the string "(cl2)": light 2 turns off.
    Send the string "(mmm)j": the system does not take any action.
4.2 Remote control terminal module test setting
    Press the "forward" button, and the car moves forward a short distance. Keep pressing the "turn left" button, and the car turns left in place.
    Press the "Turn on light 1" button, light 1 turns on, and the corresponding information on the LCD screen changes accordingly.
4.3 Human body detection module measurement
    When you pass your hand over the module, the buzzer of the terminal module sounds, and the LCD screen prompts that someone has entered the range. The serial port debugging assistant also receives the hexadecimal string of "0x28 0Xf0 0x32 0x33 0x34 0x30 0x00 0xff 0x29". According to the protocol, the 8th byte indicates the status information of human body detection. The first half byte indicates whether the function is turned on, and the second half byte indicates whether someone has entered the detection range. Therefore, "0xff" means that a human body has been detected entering the detection range.

5 Conclusion
    The system takes the most commonly used and reliable light switch control, temperature and humidity detection, and human intrusion detection as the main entry point. At the same time, it adds an expandable mobile platform - a wireless remote control car. Considering the independence and perfection of the system, a remote control terminal module is added, so that the entire system can perform various operations without relying on the host computer.
    The difficulty of the system is the design of the communication protocol between modules. After repeated research and searching for information, we finally refer to the form of Ethernet data frames, assign an address to each module, and write the target module address and the sending module address at the beginning of the transmitted data, so that the receiving module can judge how to process the data according to the address. After repeated debugging and modification, this system finally realized all the expected functions.

Reference address:Design and implementation of IoT intelligent computer room system

Previous article:Design and implementation of GSM wireless data transmission system with Ethernet interface
Next article:Deep-sea hydrothermal multi-point temperature and pressure acquisition and control system based on MC68HC908GP32

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号