A Smart Home Remote Monitoring System Based on SMS

Publisher:SHow111timeLatest update time:2012-06-19 Source: 自动化技术与应用Keywords:SMS Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1 Introduction

With the acceleration of the pace of life and the improvement of living standards, people have put forward higher requirements for the safety, intelligence, comfort and convenience of modern homes. Smart home control systems are new things that have emerged to meet this demand. They are developing in the direction of intelligence, remoteness, miniaturization and low cost. Nowadays, mobile phones are very popular. How can ordinary people remotely control their home electrical appliances and remotely check the status of equipment or security systems through mobile phones with only a small amount of investment? At the same time, once a safety accident such as gas leakage, fire, theft, etc. occurs at home, the alarm can be immediately notified and handled in time. For this reason, this paper proposes a smart home remote monitoring system based on SMS and Atmega128.

2 System structure and working principle

The smart home remote monitoring system designed in this paper consists of CPU module, SMS transceiver module, power module, clock module, LCD display module, keyboard module, driver module, wireless transceiver module, detection module and other modules, as shown in Figure 1. The working principle of the system is as follows: the user sends the control or query command to the SMS transceiver module in the form of SMS through the GSM network through the mobile phone, and the CPU reads the SMS into the memory through the serial port, and then responds to the command after analysis and processing, and controls the opening or closing of the corresponding electrical appliances, thus realizing the remote control of home appliances. The CPU regularly detects the signals of smoke sensors, CO sensors, and access control systems. Once there is a gas leak, fire, theft or other dangerous situations at home, the system immediately cuts off the power supply, buzzer alarms and sends alarm SMS to the designated mobile phone, thus realizing remote monitoring of the home. In order to achieve a more humanized design, when the user is at home, he can control the on and off of each home appliance through a handheld wireless remote control, and set the authorized mobile phone number, authority and precise time of the system through the built-in small keyboard. The LCD is used to display the status of each appliance and the status of each sensor in real time.

Figure 1 System structure diagram

3 Hardware System Design

The CPU uses Atmega128 microcontroller, which is an 8-bit low-power CMOS microprocessor based on AVR RISC structure, with high cost performance, low power consumption and high reliability. The SMS transceiver module uses Saro310 GSM Modem from Xiamen Sangrong Company. The sensor uses SS-168 smoke detection alarm and HD-111 household CO detection alarm from Hong Kong Jiayong Company. They output switch signals when detecting dangerous signals and can send alarm signals to the CPU in a timely and accurate manner. The LCD display module uses LCD12864 with Chinese character LCD display. It has its own Chinese character library. You only need to query the Chinese character library table to realize the Chinese display of LCD. It occupies few CPU pins and only needs three pins to complete communication and control.

Figure 2 Schematic diagram of the main modules of the system.

The keyboard module uses a 4 × 4 small keyboard. The switch drive module realizes the control of weak current over strong current. Because there are high-power electrical appliances in this system, the current will be large when starting, which may reach 10A, so a 2JB0.5-1 solid-state relay is used. The clock module uses the DS1302 clock chip to provide a real-time clock for the CPU. It uses serial data transmission, can provide a programmable charging function for the power-off protection power supply, and can turn off the charging function. The programming is simple and the power consumption is small. The wireless transceiver module uses the superheterodyne two-way wireless receiving module JL-RT01A. The power module introduces 220V AC power from the plug, and after the 220V/36V/12V transformer steps down, the rectifier bridge rectifies, the secondary capacitor filters, and the three-terminal voltage regulator chips 78L05 and 78L24 stabilize the voltage, it provides 5V and 24V power supply for the core board and the interface driver module respectively. [page]

Figure 3 Main program flow chart.

4 Software System Design

The Atmega 128 chip has rich integrated instruction functions and abundant memory and other resources. In order to improve programming efficiency, code readability, portability and maintainability, this system uses C language to develop system software.

4.1 Main program flow

After the system is powered on, it first initializes the underlying hardware (including LCD devices, serial port parameters, etc.) and system I/O, and then sends the ATE command to the SMS module through the RS-232 port to query whether the SMS module is working properly. If a response is received, the AT commands such as "AT + CMG F", "AT + C NMI", "AT + CSCA" are sent in sequence (refer to the AT command set) to set or obtain relevant parameters and complete SMS preprocessing. Then it enters the loop waiting state, periodically queries whether the SMS module has received new SMS, detects the signal input of each sensor and keyboard operation, etc. If a new SMS is found, it is determined whether it comes from an authorized mobile phone. If so, after verifying the authority of the mobile phone number, the SMS is analyzed and responded according to the specific command (see Table 1-3). Once an abnormality is detected in the smoke sensor, CO sensor, etc., the power supply of the main electrical appliances is immediately cut off, an alarm signal is output, and a SMS is sent to the designated mobile phone.

4.2 GSM Short Message Design

4.2.1 SMS sending and receiving mode selection

The Saro 310 GSM Modem module uses the AT command set to control the sending and receiving of SMS messages. It supports two SMS sending and receiving modes: TEXT and PDU.

The former does not support non-ASCII characters and cannot send and receive Chinese text messages, while the latter supports a variety of different encoding formats. Therefore, this system uses the PDU mode to send and receive text messages. The Chinese characters on the mobile phone are displayed using the national standard code. The CPU needs to convert the UCS 2 code into the national standard code first for output.

The conversion between UCS2 code and national standard code cannot be completed by algorithm, but can only be achieved by table lookup. [page]

4.2.2 SMS command format (control protocol)

SMS commands are divided into sensor query commands, basic control commands, and advanced management commands. The formats and descriptions of various commands are shown in Table 1, Table 2, and Table 3 respectively.

Table 1 Sensor query commands

Table 2 Basic control commands

Table 3 Advanced management commands

For example, to turn on the light:

uint8 ExecuteSMS Cmd(void) // execute command

{ case SMS_DD :RELAY_PORT|=BIT(RELAY_DD

) ; // Turn on the light

DvcSt t|=0x02; break; // The command code of the light is 0000 0010B

}

The SMS command is stored in the data buffer in the form of U nicode.

4.2.3 SMS command analysis

When the system receives the SMS command, it will match and scan from sensor query, basic command, and advanced management command in sequence. The scanning code is as follows:

wh ile (- - i &&! (mh = strstr (UART0 _RxBu f,DefDetCmd[i])));

if( ! i ) // If it is not a sensor command

wh ile (- - j&&! (mh = strstr (UART 0 _RxBu f,DefBasicCmd[j])));

if( ! j ) // If it is not a basic command

wh ile (- - k&&! (mh = strstr (UART 0 _RxBu f,DefAdvanceCmd[k])); [page]

Among them, UART 0 _ R x B uf points to the receive data buffer, DefDetCmd is the sensor command predefined in the system, DefBasicCmd is the basic control command, and DefAdvanceCmd is the advanced management command. After the scan is completed, different types of commands are further refined and processed, and the corresponding command numbers are returned. The system completes different operations according to different command numbers.

4.2.4 Send SMS

When the system receives a text message command with "?", it will send a report text message to the authorized number after completing the corresponding operation. The text message format is defined as follows:

typedef struct ShortMessage // short message structure

{uint8 CSCA[19]; ​​// SMS center number

uint8 FirstOctet[3];

uint8 TP_MR[3]; // message reference value

uint8 RecvPhoneNo[19]; ​​// The other party's number field

ui n t8 TP_PID[3] ; // protocol identifier

ui nt8 TP_DCS[3] ; // encoding method

uin t8 TP_VP[3]; // validity period

uint8 TP_UDL[3]; // User data length

uint8 TP_UD[255]; //Message content

}SHORTMESSAGE;

When the system is powered on, the short message preprocessing is performed first, the constants in the message structure are assigned and stored in the Flash, and the message structure is completed when the message is to be sent. The sending process is (: 1) Send the "AT+CMGS" command to the SMS module (; 2) After the SMS module responds, send the short message structure string (; 3) Wait for the sending to be completed.

4.2.5 SMS security design

In order to improve the security of the system, this system has set up an authorized number library. Only the commands sent to the system by the authorized mobile phones in the authorized number library are valid. When the system receives a new SMS, it first determines whether the number is included in the authorized number library. If the SMS comes from an unauthorized mobile phone, the information will be deleted. After executing the command sent by the authorized number, the system will send information about the command execution to the user through the SMS module. The authorized number library can be modified. The mobile phone that manages the number can send SMS commands to add unfamiliar numbers to the authorized number library or delete authorized numbers. It can also add and delete authorized numbers through the keyboard.

5 Physical Testing

The actual test results of the system are shown in Figure 4. By authorizing the mobile phone to send a text message "Turn on the light?" to the system, the system completes the analysis of the text message command, turns on the light, displays the current operation on the LCD, and replies with a text message as required.

Figure 4 LCD control command display and mobile phone query command display.

6 Conclusion

The smart home remote monitoring system designed in this paper only needs to make a few adjustments to the wiring of the original power supply, security and other systems, and can remotely control home appliances through a mobile phone. The system is highly practical, simple to operate, low cost and cost-effective. It can also be easily extended to many fields such as outdoor billboard monitoring, reservoir water level monitoring, elevator safety operation monitoring, etc.

Keywords:SMS Reference address:A Smart Home Remote Monitoring System Based on SMS

Previous article:Design of MTURTU radio telemetry system based on AVR microcontroller and MODEM chip
Next article:Zigbee sensor node hardware design based on single chip microcomputer

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号