Design of a water flood alarm system controlled by SMS

Publisher:精灵宠儿Latest update time:2012-11-30 Source: 单片机与嵌入式系统 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
0 Introduction
Water flooding alarm systems are mostly used in warehouses, libraries, residences and other places where alarms are required when there is water accumulation. For some special applications such as different liquids to be detected, an alarm system with adjustable sensitivity is required; some alarm systems must meet both on-site alarms and remote wireless alarms.
The application of GSM (Global System for Mobile Communications) network is mostly concentrated on GSM mobile phone calls and SMS services. As a basic service of GSM network, short message service can send and receive short messages on mobile terminals, which has been paid more and more attention by system operators and system developers. Now more and more application products have shortened the communication distance between people and objects, and the perception ability of the scene has been greatly extended. Regardless of whether the channel is congested or not, the SMS service provides stable information transmission, thus ensuring the stability and reliability of the alarm system.
The alarm system designed in this paper is applied to the solution overflow detection of biological laboratories. Experimenters can control the start and stop of the alarm system, configure the filtering mode, add new users and customize the alarm SMS content through SMS. When the solution overflows, the alarm system can send an alarm SMS to inform the designated experimenter in time. The SMS control method makes full use of the convenience of the GSM network to save the system's hardware resources and meet the laboratory's requirements for low power consumption and small size.

1 System hardware structure
1.1 System structure
The alarm system is shown in Figure 1, which mainly consists of three parts: a single-chip system module, a GSM module, and a detection module. The single-chip microcomputer uses TI's MSP430F5438; the GSM module uses Siemens' TC35; and the detection module uses a self-made circuit board.

e.JPG


1.2 TC35 module
The TC35 module is a dual-band 900 MHz/1 800 MHz GSM network modem. The TC35 module is connected to the external processor via the RS 232 serial port, which can realize the wireless transmission of voice and data on the GSM network application platform. The operating voltage of the TC35 module is between 3.3 and 5.5 V, and the transmission power is 1 to 2 W. The TC35 processor contains the entire GSM protocol stack and communicates with the terminal device via the UART interface. The system developed using the TC35 module is controlled by AT commands.
1.3 MSP430F5438 microcontroller
The MSP430 series microcontroller is a 16-bit ultra-low power microcontroller launched by the American Texas Instruments (TI) company. It adopts a reduced instruction set (RISC) structure and is powered by a power supply voltage of 1.8 to 3.6 V. The chip integrates a wealth of peripherals, such as timers, comparators, ADCs, and a large number of interface units, which facilitates the design and development of application products. The MSP430F5438 microcontroller used in this paper has a program storage space of 256 KB, 16 KB SRAM, works at a 16 MHz external clock, has 83 I/Os, 4 configurable USARTs, and 16-channel 12-bit ADC on-chip peripherals. 1.4 Water immersion detection module design The two wires of the detection module are placed in the area to be detected for water immersion, as shown in Figure 2. Point A is connected to the input end of the ADC. The relative heights of the wires in the vertical direction are different, and water levels at different heights can be detected for alarm. When water immersion occurs, the wires are immersed in water to form a conductive path, and R2 is the equivalent resistance of water immersion. The selection of R1 should follow several principles: First, ensure that the voltage division of R1 is higher than the environmental interference voltage and the sampling accuracy of the ADC.

f.JPG


The measured tap water equivalent resistance R2 is 300 kΩ, the ADC reference voltage is 2.5 V, the sampling accuracy is 0.6 mV, and the environmental noise interference is about 10 mV. Therefore, the voltage division of R2 should be greater than 10 mV. It can be concluded that the selected resistance value of R1 should be greater than 400 Ω. Secondly, the ADC input resistance should not be too large. The larger the resistance R1//R2, the longer the ADC sampling time. The sampling time satisfies:
tsample>(Rs+2 kΩ)ln213×40 pF+800 ns (1)
Where Rs is the input resistance. When R1 is equal to 100 kΩ, tsample>36μs. [page]

2 Software Design
2.1 Software Flow
The software flow is shown in Figure 3, which is mainly divided into the following parts: MCU and TC35 initialization, filter detection, sending alarm SMS, receiving SMS and decoding processing, low power mode.

g.JPG


2.2 AT command set
AT command set is the communication protocol between GSM module and external processor. Users can control calls, text messages, phone book, data services, fax, etc. through AT commands. All microcontrollers control TC35 by sending AT commands through the UART serial port. The sending of AT commands must follow the specified syntax format. Each command line must start with AT (or at) and end with . After sending AT commands, a return character is usually received. The character format is . is a carriage return character (ASCII code is hexadecimal 0d, i.e. 0x0d), and is a line feed character (ASCII code is hexadecimal 0a, i.e. 0x0a). The AT commands used by the system are shown in Table 1.
2.3 Initialization process
The initialization process is divided into microcontroller initialization and TC35 initialization. The initialization of the microcontroller includes turning off the watchdog, initializing the system clock, initializing the port, initializing the UART serial port, and initializing the ADC module; the initialization of TC35 includes sending AT commands "AT&F", "AT+CMGF=1", "AT+CNMI=3,1,0,2", and "AT+CMGD=1".
The initialization system clock of the microcontroller is 16 MHz, using an external clock source. The port initialization includes the input and output direction configuration of I/O and the initialization port value configuration. When receiving serial port data from the microcontroller system, the TC35 module can adapt the transmission rate from 300 b/s to 115 Kb/s. However, the microcontroller system cannot adapt to the serial port rate of TC35. Therefore, the microcontroller and the TC35 module should be set to the same transmission rate, such as the UART serial port of the microcontroller system is set to 9600 b/s. The UART serial port selects the shift register low bit first (LSB first), 8 data bits, 1 stop bit, UART synchronous mode, and the transmission rate is 9600 b/s. The ADC reference voltage is 2.5 V. TC35 initialization is configured through AT commands between the microcontroller and the TC35 module. Send "AT+CMGF=1" to set the SMS format to TEXT, and send "AT+CNMI=3,1,0,2" to set the new SMS reminder. When TC35 receives a new SMS, it will actively report to the microcontroller and display the storage address, such as "+CMTI: "SM", 1". Send "AT+CMGD=1" to delete the SMS at address 1. Every time TC35 is used, the SMS at address 1 must be cleared. When a new SMS is received, the SMS can be stored at address 1. After decoding the SMS, the command to delete the SMS must also be executed. It should be noted that a SIM card that has been registered with a gateway does not need to set the SMS center number.

[page]

2.4 Receive SMS and decode
After TC35 is initialized, the user can send SMS to the SIM card number of the alarm system. Configure the system status to control the alarm to start and stop; configure the software filter mode to adjust the alarm sensitivity; update the user list to send alarm SMS to different users; customize the alarm SMS content, the user can define the alarm prompt SMS according to the actual situation. The user sends SMS to change the alarm system configuration through the mobile phone. When the GSM module receives the SMS, it sends "+CMTI: "SM", 1" to the microcontroller. After receiving the SMS, the microcontroller sends the SMS read instruction "AT+CMGR=1" to the GSM module. 1 is the address where the GSM module stores SMS. GSM then sends the received user SMS to the microcontroller for decoding. The receiving format is:
"+CMGR:"REC UNREAD", "+86138xKXXXXXX", "11/11/14, 08:46:41+32"F1OK".
The MCU program determines that the SMS has been received by searching for "OK". Next, the location of the SMS content can be determined by searching the number of quotation marks and the SMS "F1" can be read into the register read_sm. The hexadecimal value after F is used as the corresponding filter mode enable.
The agreement between the alarm system and the user in this article stipulates that all sent SMS must be ensured to consist of only uppercase English letters A to Z, Arabic numbers 0 to 9, and spaces. Users can change the filter mode of the alarm system, add new user mobile phone numbers, and customize the alarm SMS content by sending SMS through their mobile phones. For example, sending "1M138xxxxxxxx" to the SIM card number of the alarm system can set a new user mobile phone number. To add a second user mobile phone number, you can send "2M132xxxxxxxx". After the GSM module receives the SMS, the MCU sends the corresponding AT command to the GSM module, and the SMS is read into the register of the MCU. After decoding the SMS, it is determined which function the user wants to achieve. If it is "1M", the number is stored in the target number table for sending SMS. When the next flood occurs, an alarm SMS is sent to all target user mobile phone numbers to realize SMS group alarm. If it is "C", the
characters after it are used as the content of the custom alarm SMS. If it is "S", the characters after it are used as the start or stop enable of the system status. The decoding process is shown in Figure 4.

i.JPG


2.5 Filter detection
The ADC module is integrated in the MSP430 microcontroller. The voltage values ​​at both ends of the wire are collected at a certain period. The converted digital signal is filtered by software to determine whether it reaches the lower limit of the trigger voltage. The system uses arithmetic mean filtering, sums the N sampling values ​​and divides them by the number of sampling times. The result is compared with the trigger voltage lower limit set by the system. If the trigger voltage lower limit is reached after filtering, an alarm is triggered, otherwise the voltage continues to be collected and filtered. Users can change the filtering parameters, such as the trigger voltage lower limit, sampling period and sampling number, by sending mobile phone text messages according to the actual situation. In order to facilitate user operation, the filtering parameters are defined as 16 different modes, see Table 2.

a.JPG

[page]

2.6 Sending alarm SMS
The GSM module should be inserted with a registered SIM card. After flooding occurs, the buzzer sound alarm and SMS alarm are triggered. After TC35 is initialized successfully, sending alarm SMS requires three steps: First, the microcontroller sends the configuration target mobile phone number "AT+CMGS=138xxxxxxxx"; then, send the text message "WARNING" in TEXT format, and finally, send the hexadecimal number 1a. Through these three steps, "WARNING" can be sent to the user's mobile phone.
After the microcontroller sends the AT command, the TC35 module will return a response character. Taking the configuration of the target number as an example, how to implement software design is explained. After the microcontroller sends "AT+CMGS=138xxxxxxxx", the TC35 module returns the ">" character after receiving it, indicating that the target number is successfully configured. The microcontroller program determines whether the ">" character is received and decides to send the TEXT text. In order to prevent the program from looping indefinitely when the configuration fails, a counter needs to be set to allow the program to jump out.
Program for sending alarm SMS:
j.JPG

3 Test results
Send the "AT&F" command to the RS 232 serial port. The ASCII code is represented in hexadecimal as: '41', '54', '26', '46', '0D', '0A'. Since the RS 232 level is negative logic, it is converted into binary complement as: 1011_1110, 1010_1011, ... As shown in Figure 5, the horizontal direction of the oscilloscope represents time (unit: μs), and each grid represents 100 μs; the vertical direction represents the voltage value (unit: mV), and each grid represents 2 000 mV. The first high level and the last low level are the start bit and the stop bit, respectively, and the 8-bit data 0111_1101 is between them. Since the serial port is low-order first (LSB), the first binary data is 1011_1110, which is consistent with the serial port command sent.

c.JPG


In order to debug and verify the alarm system functions more intuitively, the 8-bit digital tube of the single-chip system module is fully utilized in the design. As shown in Figure 6, "3111" indicates that the program is running normally, the first two digits "05" from the right indicate that the current filter mode is 05, the third digit "1" from the right indicates that a new SMS has been received, and the fourth digit "2" from the right indicates that 2 alarm SMS have been sent.

d.JPG

4 Conclusion
The alarm system in this paper uses GSM as the network core and the low-power single-chip MSP430 as the processor core to design an alarm system for water immersion detection. Through the test of the biological laboratory, the system realizes remote monitoring and flexible configuration of water immersion sensitivity in the laboratory environment. Adding short-range wireless communication function and designing a multi-node wireless communication protocol on the basis of this system will give the system a broader application space.

Reference address:Design of a water flood alarm system controlled by SMS

Previous article:PWM Buck three-level converter based on SG3525 voltage regulator chip
Next article:Design of Temperature Detector Based on Single Chip Microcomputer

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

IAR ARM, IAR STM8, IAR MSP430 share one IDE
After trying to install several IARs with different versions and compilers, I finally understood the conditions for IARs with different compilers to share the same IDE. I installed several IARs with different compilers together and shared the same IDE. The above compilers can compile and simulate STM32, STM8, and
[Microcontroller]
IAR ARM, IAR STM8, IAR MSP430 share one IDE
Comprehensive tester for electronic ballast based on MSP430F133
Introduction Electronic energy-saving lamps are products that have entered thousands of households. Improving their quality is of great significance to the modernization construction that advocates energy conservation. For manufacturers, it is the only way to enhance product competitiveness. The main principle of elec
[Microcontroller]
Comprehensive tester for electronic ballast based on MSP430F133
Design of intelligent adaptive intermittent light control system based on MSP430 single chip microcomputer
    In order to overcome the shortcomings of the existing supplementary lighting system, such as the inability to adjust the supplementary lighting time and the degree of supplementary lighting, and the inability to fully utilize the full spectrum for photosynthesis, the system is based on the MSP430 single-chip micro
[Microcontroller]
Design of intelligent adaptive intermittent light control system based on MSP430 single chip microcomputer
MSP430 interrupt program
#include    void main(void) {    WDTCTL = WDTPW + WDTHOLD;                                 // Stop watchdog timer    P1DIR |= 0x01;                                                       // Set P1.0 to output direction    P1IE |= 0x10;                                                         // P1.4 interrupt enabl
[Microcontroller]
Experiment 3: MSP430 input and output interface experiment (2 hours)
1. Purpose of the experiment     Learn to use the P port. 2. Experimental requirements     Use the buttons on the board to control the LED display. 3. Experimental content (1) Write a keyboard scanning program. (2) Write a program to display the LED flashing (1 second interval, software delay). (3) Write
[Microcontroller]
Thermistor temperature measurement using MSP430 microcontroller
Abstract The traditional digital method of measuring resistance is to first convert the resistance value into an electrical signal (such as voltage), and then use an A/D converter to convert it into a digital signal. Therefore, the circuit is complex and the cost is high. This article introduces a method of measurin
[Industrial Control]
Thermistor temperature measurement using MSP430 microcontroller
Communication methods and protocols between MSP430 multiprocessors
In a single-chip microcomputer system, multiprocessors refer to multiple single-chip microcomputers of the same or different types that work together to handle different tasks of the same system. They must have certain data exchange and collaborative processing capabilities to complete a systematic task together. Di
[Microcontroller]
Communication methods and protocols between MSP430 multiprocessors
Photovoltaic grid-connected power generation simulation device based on MSP430F169
introduction At present, energy sources such as coal and oil are becoming exhausted, and environmental pollution is becoming increasingly serious. The use of new energy and renewable energy has become an urgent matter for countries around the world. As a pollution-free renewable energy, solar energy
[Power Management]
Photovoltaic grid-connected power generation simulation device based on MSP430F169
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号