Monday, November 14, 2011

Reservoir Water Level Monitoring System using Ultrasonic

The above title is the group project we did as undergraduates. In this main purpose is to gather the water level data, store them in central database and view them on web interface. This system can greatly reduce the affect of sudden water level increase due to rain, causing floods. Also it minimizes the man power requirement of irrigation department used to measure water levels in the reservoirs in distant areas.


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.


unsigned char para[5]="AT\r\n";
unsigned char textmode[12]="AT+CMGF=1\r\n";
unsigned char smsc[24] ="AT+CSCA=\"+947100003\"\r\n";
unsigned char recepient[24]="AT+CMGS=\"+94719192664\"\r";
int water_level = 10;

Usart_Init(9600);

for(i=0;i<5; i++){
Usart_Write(para[i]);//Test AT command
}
for(i=0;i<12;i++)
{
Usart_Write(textmode[i]);
}
Delay_ms(100);
for(i=0;i<24; i++)
{
Usart_Write(smsc[i]);
}
Delay_ms(100);
for(i=0;i<24;i++)
{
Usart_Write(recepient[i]);
}
Delay_ms(50);
Usart_Write(x);
Delay_ms(50);
Usart_Write(0x1A); //ctrl+z
Delay_ms(50);
Usart_Write(0x0D); //enter



This is the link to source file.

4 comments:

  1. [...] power requirement to measure water levels in the reservoirs in distant areas.” PyroFactor: Read Permalink  |   Email This [...]

    ReplyDelete
  2. is there a reciever in the computer?

    ReplyDelete
    Replies
    1. In the central computer there is SMS receiving part. You can use anything that can get a SMS (phone, USB modem, GSM modem) and a application to capture the SMS and store it in the database.
      Link to full project report in the Second part of this post.
      Or go to link below
      http://www.mediafire.com/?wpa9q6zzoh7wivq

      Delete
  3. Its really a nice post, the content of this blog is really awesome and extraordinary.And also please Read link bvba Woodstone which provide information server monitoring & server monitoring tools

    ReplyDelete