The system uses Ultrasonic sensors to measure the water level and according to the signal a on-board microcontroller based circuit calculate the water level generate SMS (Short messaging service) inserting the water level data and send it to the central server using a GSM (Global System for Mobile Communications) modem. In the central server data was extracted from the SMS and inserted into a database. A user can access the web interface and the view the data.
So that’s about the project introduction. Here I’m going to write some important areas of the project rather telling it all. Even though it is too long for one post so they will be put in to several posts.
As first part I would write about programming the microcontroller. The main functions would be getting the signal from Ultrasonic sensor and calculate water level, display it on the LCD (), Configure the GSM modem and send the SMS. For this I used PIC18F452 microcontroller and program it using MicroC. Among them sending the SMS is bit useful to know so this is how it is done.
The GSM modem has a serial port and it is connected to the microcontroller through a MAX232 IC. Communication devices such as modems are configured using AT (attention) commands. Therefore, we have to send AT commands through the serial port. I used the USART library in MicroC to send serial Data.
As for the configuration, I set the message mode, message center number and destination number. The AT commands to each of them would be like below.
AT+CMGF=1
This sets the message mode to text. There is also PDU mode, which gives more options. However, this thing bit complicate.
AT+CSCA=“+947100003”
This is AT command for setting the message center. This depends on the service provider. You can check your service provider in mobile phone’s settings.
AT+CMGS=“+94719192564”
Then the recipients phone number. Message is to follow this. You can try these commands on a phone or modem connected to the PC through a HyperTerminal by connecting to the correct com port. You can check the device manager to find out what is the com port the device is connected. If you correctly type and enter the command then you will get a reply “OK”. With the last command, it will prompt for the message when you hit enter. Then type the message and press “ctrl+z” to send the message.
Now it comes to send the SMS with microcontroller. I used the Usart_Init(int baud rate) and Usart_Write(char letter) methods for this. The commands were stored in char arrays and send them character at a time using for loops. Usart_Init requires the baud rate to initialize the Usart module. This is data sending rate so it must be supported by the device as well.
- See more at: http://www.assumedaltitude.lkblog.com/2011/11/reservoir-water-level-monitoring-system.html#sthash.A8rvJyyA.dpuf