This system is a remote automatic control system based on infrared and GSM network for smart home environment. Its working principle is: the user sends command short message through his own mobile phone, the GSM module on duty at home receives the command and sends it to the host (single chip microcomputer), the host transmits the command to the corresponding extension (single chip microcomputer) through infrared through the command processing, and the extension starts the corresponding equipment after the command processing, completes the command given by the user and replies to the host, After receiving the response, the host sends a reply short message through the GSM module to report the user to complete the command. If the host does not receive the reply message from the extension within the specified time (here the timing is 60s), the operation is considered invalid, and the invalid reply message is sent to the user’s mobile phone, asking the user to issue the command again. If the received SMS is wrong, the host will immediately reply to the user, the operation is invalid, and request to reissue the command. The system structure is shown in Figure 1.
Figure 1 system composition diagram
Communication module between MCU and GSM
The MCU communicates with GSM module through RS232 serial communication interface, extracts short messages of GSM equipment, sends relevant information, and connects with infrared module through serial communication interface. Using infrared module, the communication between main and extension is achieved. Therefore, AT89S52 chip is selected. Two serial interfaces are needed in the control, but 89S52 has only one serial port, so it is necessary to carry out analog serial interface communication in the program. The simplest external wiring circuit is shown in Figure 2.
Figure 2 external wiring of AT89S52
89S52 and TC35 communicate through asynchronous serial interface, the communication rate is 9 600 B / s, with 1 bit start bit, 8 bit data bit, 1 bit stop bit, no parity. After the MCU starts up, it sends out at + cmgd-2 instruction to clear the data in the second storage space, and then sends out instruction to read the second storage space continuously. If there is any data, it means that it has received the data and started to process the data. After processing, the spatial data will be deleted. When the MCU sends a short message to the mobile phone, it will send a series of instructions to the GSM module, such as at, at + cmgf = 0, at + CMGs = X. after receiving the reply message, it will send out the content of the short message.
Infrared wireless communication module
The circuit of infrared transmitter is shown in Figure 3, including 38kHz crystal oscillator, inverter, NAND gate, driving gate Q1 and infrared transmitting tube D1. The 38kHz crystal oscillator, resistor R3 and inverter constitute a pulse oscillator, which is used to generate 38kHz pulse sequence as carrier signal. The infrared transmitting tube D1 uses tsal6238 produced by Vishay company to emit 950nm infrared beam.
Figure 3 infrared transmitter circuit diagram.
The circuit of the infrared receiver is shown in Figure 4. When the receiver receives the digit “O”, the Q2 tube turns on, so that the RXD receives the low level. When the receiver receives the digit “1”, the Q2 tube stops, and the RXD receives the high level.
Figure 4 circuit diagram of infrared receiver
This system will make different actions with different motors to simulate the response of smart home to system control. As shown in Figure 5, when the MCU of the extension receives the address information of the local machine, it will extract the data in the information. According to the data command, if pin p0.0 and P0.1 are set to low level and others are set to high level, then Q3 and Q4 are on, and the motor will rotate in the forward direction. If pin P0.2 and p0.3 are set to low level and others are set to high level, then Q5 and Q6 are on, and the motor will rotate in the reverse direction (the previous case is the same) Positive time). If an extension is connected with multiple motors and has multiple extensions, it can realize the synchronous control of various devices in the smart home environment.
Figure 5 motor drive circuit
The system is safe, reliable and stable. At the same time, in addition to the remote automatic control of home equipment, the system can also be used for home communication, family security, and jointly build a smart home control system.