Design and implementation of GSM SMS alarm system based on STM32

Publisher:ShiningSmileLatest update time:2012-11-02 Source: 21ic Keywords:STM32 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Introduction

With the rapid development of China's economic construction and the great improvement of people's living standards, people pay more and more attention to whether their environment is safe. Especially when there is no one at home or only the elderly and children, the safety of family members' lives and property is increasingly valued. Therefore, home anti-theft has become an important social issue. At present, the security of many residential areas mainly relies on traditional mechanical (anti-theft nets, anti-theft windows) anti-theft systems. This not only hinders the appearance, does not meet the requirements of fire escape, but also cannot effectively prevent the invasion of bad people. With the rapid development of electronic technology, the anti-theft alarm system has urgently developed from the original simplification and localization to intelligence and integration. At present, GSM short message service has been used as a basic service of GSM network. It is applied to the home wireless anti-theft alarm system based on the connection between GSM SMS module and single-chip microcomputer, making home anti-theft more timely and convenient, and directly reflecting the situation of the crime scene on the user's mobile phone screen in the most intuitive Chinese short message form. At the same time, a pyroelectric infrared sensor is used for detection, changing the tangible traditional anti-theft net and anti-theft window into an invisible monitoring, providing the most intuitive, efficient and reliable guarantee for home anti-theft.

1 Overall design and working principle of the system

The design block diagram of the GSM SMS alarm system is shown in Figure 1. The entire system [1] consists of an STM32 microcontroller module, a pyroelectric sensor module, a GSM module and a traditional speaker module. The GSM module uses the SIM900A chip and peripheral design circuit produced by SIMCom, while the pyroelectric sensor module uses the design circuit of the infrared dedicated chip BISS0001. First, when the pyroelectric sensor module detects the infrared light emitted by a person, it converts it into a voltage signal through its peripheral amplifier circuit and transmits it to the STM32 microcontroller. The microcontroller judges the data sent by the pyroelectric sensor module and sends a high level to the GSM module through the serial port, so that the GSM module sends a text message to the set mobile phone number, notifying the owner of what has happened at home in time,

and at the same time making the speaker sound an alarm, thereby realizing the expected function of the system. However, when the owner is at home during the day, there is no need to set the anti-theft function and
the function can be turned off; if the owner is leaving the house or sleeping at night, the protection function needs to be turned on. These "arm" and "disarm" functions can also be turned on and off by sending specific text messages to the GSM module through a mobile phone, and the pyroelectric sensor detection will take effect to avoid unnecessary trouble and false alarms.



Figure 1 System overall block diagram

2 System Hardware Circuit Design

2.1 STM32F103 Minimum System

The STM32 series of microcontrollers [2] produced by ST are designed for embedded applications that require high performance, low cost, and low power consumption. The STM32 used in this system is an interconnected product with the following standard functions: 72MHZ main frequency, 56k bytes of Flash, 64 bytes of SRAM, 2 watchdogs, multiple 16-bit timers, 80% of the pins can be used as general-purpose I/O ports, and communication peripherals such as USART and SPI. Its peripherals fully meet the functional requirements of this system. Therefore, this system uses STM32F103 as the main controller, and its minimum system is shown in Figure 2.

This system uses a 4-wire JTAG interface, namely TMS (test mode selection), TCK (test clock), TDI (test data input), TDO (test data output), and a conventional 20-pin interface. It can be connected to a PC through an emulator to achieve online simulation debugging, which is convenient and reliable. The system uses an 8MHZ crystal oscillator, and a load circuit needs to be connected at this time. In addition, the reset circuit is designed in a simple way, which can achieve reliable system reset. Figure 2 STM32F103RBT6 minimum system [page]

2.2 GSM Module

The GSM module [3] uses SIM900A produced by SIMCom. It is a compact GSM/GPRS module with SMT packaging, STE-based single-chip design, ARM926EJ-S architecture, powerful performance, and support for AT commands. The GSM MODEM is

controlled by the STM32 serial port. The microcontroller and the GSM module generally use a serial asynchronous communication interface. The communication speed can be set, usually 19200bps. The GSM MODEM and the microcontroller use serial communication. The TXD and RXD of the MODEM are the transmitting and receiving ends, respectively, and are connected to the PA10 and PA9 of the microcontroller to form a serial communication. The GSM module is powered on by pulling the PWRKEY signal low for a period of time and then releasing it. When the module is powered on, AT commands can be sent to control the module. Users can set the baud rate and save the parameters through "AT+IPR=x". Once configured to a fixed baud rate, the character "RDY" will be received from the serial port when the module is powered on. These characters cannot be displayed when the automatic baud rate is activated. Similarly, the module can be shut down by pulling the PWRKEY signal low for a period of time and then releasing it. Or use the AT command "AT+CPOWD=1" to shut down the module. This command deregisters the module from the network, puts the software into a safe state, saves useful data, and then completely disconnects the power supply. Before shutting down, the module serial port will automatically send the following string "NORMAL POWER DOWN", after which AT commands cannot be executed. The module enters power-down mode, and only the RTC is active. The power-down mode can be detected by the STATUS pin, which outputs a low level in power-down mode. The GSM main module (including the SIM part) is shown in Figure 3.



Figure 3 GSM main module (including SIM part)

2.3 Pyroelectric sensor module

The pyroelectric sensor module [4] includes a pyroelectric sensor and a peripheral amplifier circuit. When a person enters the range that the sensor can detect, the sensor detects the energy change and converts it into a weak electrical signal. The signal is then amplified by the peripheral amplifier circuit and converted into a voltage signal and transmitted to the single-chip microcomputer. Its working principle is as follows: the human body has a constant body temperature, generally 37 degrees, so it will emit infrared rays with a specific wavelength of about 10um. The passive infrared probe works by detecting the infrared rays of about 10um emitted by the human body. The infrared rays of about 10um emitted by the human body are enhanced by the Fresnel filter and then focused on the infrared sensing source. Experiments have shown that the detection distance of the sensor without a Fresnel lens is less than 2m, but after adding a Fresnel lens, the detection distance can be increased to about 10m. The infrared sensing source usually uses a pyroelectric element. When the temperature of the human body changes, this element loses its charge balance and releases the charge to the outside. After subsequent circuit detection and processing, it can generate an electrical signal and send it to the single-chip microcomputer for processing.

The schematic diagram of the pyroelectric BISS0001 module is shown in Figure 4. In the figure, the operational amplifier OP1 (inside the chip) amplifies the output signal of the pyroelectric infrared sensor in the first stage, and then C104 couples it to the operational amplifier OP2 (inside the chip) for the second stage amplification. After being processed by the bidirectional amplitude detector composed of voltage comparators COP1 and COP2, the effective trigger signal Vs is detected to start the delay timer, and the output signal Vo is amplified by transistor T1 to drive the relay to connect the load. CDS1 is a photoresistor used to detect the ambient illumination. When used as a lighting control, if the environment is brighter, the resistance value of CDS1 will decrease, keeping the input of pin 9 at a low level, thereby blocking the trigger signal Vs. JP1 is the working mode selection switch. When the JP1 jumper cap jumps to port 2 or 3, it is connected to port 1, and the chip is in a non-repeatable triggering working mode. In this working mode, even if there is human activity in the detection area, the module will automatically stop outputting for a period of time (blocking delay) and then detect again. This working mode is generally called pulse output; when the JP1 jumper cap jumps to port 1 or 2, it is connected to port 2, and the chip is in a repeatable triggering working mode. As long as there is someone in the detection area, the module will always have output. This mode is generally called level output. In addition, the output delay time Tx is adjusted by the size of the external R33 and CY2, and the trigger blocking time Ti is adjusted by the size of the external R13 and CY1. The module uses a low-power voltage regulator 7133A-1, which can ensure a stable supply of 3.3V working voltage under a wide input voltage to ensure that the module can work normally.



Figure 4 Schematic diagram of pyroelectric module

2.4 Power Supply

The power supply module is divided into two parts: the MCU power supply module and the GSM power supply module. The MCU power supply adopts a typical power supply design scheme, as shown in Figure 5. Among them, C9 and C10 are bypass capacitors, which play a role in suppressing interference, while C11 and C12 are electrolytic capacitors, which play a role in filtering; generally, a small capacitor is connected in parallel next to a large capacitor to reduce the high-frequency internal resistance, because large electrolytic capacitors are generally manufactured using a winding process, so the equivalent inductance is relatively large; small capacitors can provide a high-frequency channel with a small internal resistance, reducing the full-band internal resistance of the power supply. This circuit is more common in practice.



Figure 5 Power supply circuit

The SIM900A module is powered by a single power supply with VBAT of 3.4V to 4.5V. Since it is different from the operating voltage of the microcontroller, it is powered by a separate power module, as shown in Figure 6. The VBAT output voltage of 4.2V is used by the GSM module.



Figure 6 GSM module power supply

[page]

2.5 Speaker

The speaker part mainly includes a relay. When the corresponding port of the microcontroller is set to a high level, the relay is driven, so that the speaker circuit is connected and a sound is emitted to serve as an alarm.

3 System Software Design

3.1 AT Commands

AT command set is sent from TEC (Terminal Equipment) or DTE (DataTerminal Equipment) to TA (Terminal Adapter) or DCE (DataCircuit Terminating Equipment). AT commands are sent through TATE to control the functions of MS (Mobile Station) and interact with GSM network services. Users can use AT commands to control calling, SMS, phonebook, data services, supplementary services, fax, etc. The following are some common AT commands related to short messages: At present, Text and PDU (Protocol Data Unit) modes are commonly used to send short messages. The code for sending and receiving text messages using Text mode is simple and easy to implement, but the biggest disadvantage is that Chinese text messages cannot be sent and received; while PDU mode not only supports Chinese text messages, but also English text messages. Therefore, PDU mode is used here to send and receive text messages. There are three encodings that can be used to send and receive text messages in PDU mode: 7-bit, 8-bit and UCS2 encoding. 7-bit encoding is used to send ordinary ASCII characters, 8-bit encoding is usually used to send data messages, and UCS2 The encoding is used to send Unicode characters. The module integrates RF circuit and baseband, provides a standard AT command interface, and provides fast, reliable and secure transmission for data, voice, short message and fax.

First, use the command "AT + CMGF = 0" to select the PDU mode. For example, the SMSC number is +8613800471500, the other party's number is 13656639676, and the message content is: "Hello". Then the PDU string sent by the mobile phone is
08 91 68 31 08 40 17 05 F0 11 000D 91 68 31 49 17 87 90 F6 00 08 00 06 4F60597D0021.

3.2 System program main flow chart

The main flow chart of the system program is shown in Figure 7. The system is initialized first, and then detects whether it is armed. Because the single-chip microcomputer uses AT commands to control the GSM module and transmit data. AT commands are written in the AT command format supported by the GSM module and sent out through the serial port of the single-chip microcomputer. Therefore, the "arming" and "disarming" of this module can be done in the following ways: If the module is set to the minimum function mode by the command "AT+CFUN=0", the RF function and the SIM card function are turned off. In this case, the serial port can still be used, but the AT commands related to the RF function and the SIM card function cannot be used. This is the disarming state. When the module is set to the minimum function by "AT+CFUN=0", the module can return to the full function mode by the command "AT+CFUN=1". This is the armed state. Once "armed", the system works normally. If the single-chip microcomputer detects that someone enters through the pyroelectric module, it immediately sends a high level to the GSM module through the serial port, causing the module to send a text message to the owner, and the speaker sounds an alarm.



Figure 7 System program main flow chart

4 Conclusion

The system has the following features: Since the system is equipped with "arming" and "disarming" functions, false alarms can be avoided; at the same time, the speakers and software in the system cooperate to quickly and effectively play the alarm role; in addition, with the help of advanced, stable, mature and efficient GSM mobile network, the alarm system is more intelligent and integrated, and the alarm method is more intuitive and reliable; finally, other functions can be developed according to the actual needs of the family, such as adding cameras, etc., to make the system more perfect.

In short, due to the reasonable design of the system structure, the application of STM32 microcontroller and GSM module technology, the good functional circuit, the good and stable system performance, and the good achievement of various indicators of home anti-theft requirements. Moreover, the system has low cost, strong practicality and operability, has certain application value, and can be widely used and developed.

Keywords:STM32 Reference address:Design and implementation of GSM SMS alarm system based on STM32

Previous article:Coal Gangue Sorting System Based on ARM and CAN Bus
Next article:Design of intrinsically safe power supply for mines based on STM32

Recommended ReadingLatest update time:2024-11-16 15:26

ST launches STM32U5 with integrated graphics acceleration
The STM32U5 has vector graphics acceleration and adds a large amount of SRAM for on-chip storage to enhance the graphics processing capabilities of the MCU STMicroelectronics (ST) has launched a new STM32U5 MCU with a dedicated graphics accelerator, allowing small and cost-sensitive products to achieve
[Microcontroller]
ST launches STM32U5 with integrated graphics acceleration
STM32 automatic range voltmeter design
0 Preface In intelligent instruments, automatic range conversion technology is often used, which enables the instrument to automatically select the most appropriate range in a very short time to achieve high-precision measurement. The realization of automatic range is generally achieved by controlling the attenuation
[Microcontroller]
STM32 automatic range voltmeter design
STM32 SPI master routine
#include "stm32f10x.h" /*RCC clock configuration*/ void RCC_config(void) {  ErrorStatus HSEStartUpStatus; /* RCC registers are set to default configuration */ RCC_DeInit(); /* Turn on external high speed clock */ RCC_HSEConfig(RCC_HSE_ON); /* Wait for the external high-speed clock to stabilize*/ HSEStartUpStatus
[Microcontroller]
Necessary operations for stm32 to use swd download
1. Generally, stm32 will use swd to download because it saves pins. 2. No matter whether the JTAG pin is used or not, the best way is to disable JTAG first, so as to avoid finding that the pin cannot be pulled up or down as designed when you manipulate a certain pin. 3. Disable jtag mode: GPIO_PinRemapConfig(GPIO_
[Microcontroller]
A brief analysis of STM32 startup mode
I didn't quite understand the serial port download in the Zhengdian Atomic Development Guide, so I simply read the manual. STM32 can be divided into three boot modes: 1: boot from main Flash; 2: boot from system memory (actually ROM); 3: boot from embedded SRAM (actually regular RAM). The three modes are determined
[Microcontroller]
A brief analysis of STM32 startup mode
STM32 serial port knowledge and configuration
1. Serial port knowledge The application of the serial port is that the chip sends data to the computer, the computer downloads the program to the chip, and the chip sends the data in the chip memory back to the computer. For example, when you measure the angle or speed, after the chip measures, you must see that the
[Microcontroller]
STM32 ADC conversion interrupt read
The ADC interrupt reading method is suitable for low-frequency ADC acquisition, while high-frequency AD acquisition must use DMA. The initialization function of ADC interrupt reading only adds an interrupt configuration file compared to the direct reading method in the previous article. The code is as follows: static
[Microcontroller]
STM32-Touch Screen Experiment
void Touch_Init(void);//initialization u8 Read_ADS(u16 *x,u16 *y); //Bidirectional read with discard u8 Read_ADS2(u16 *x,u16 *y); //Bidirectional coordinate read with enhanced filtering u16 ADS_Read_XY(u8 xy); //Coordinate read with filtering (single direction) u16 ADS_Read_AD(u8 CMD); //Read AD conversion value v
[Microcontroller]
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号