top of page

Automatic detection Obstacle Using GSM900 and Ultrasonic sensor module

By Bernice Zuiya

Introduction

                       Automatic detection of an obstacle using Ultrasonic sensor and send a feedback using GSM900 module. this consist of building a system which use two modules:

  • GSM900 module

  • Ultrasonic sensor (For measuring the distance)

When an object is detected near around 4 cm for example, the controller will send commands to the GSM900 module to send an SMS along with the distance detected. This maybe implemented in different way such as in a system which is use to inform a user if someone comes closer to a door. 

GSM900 module

Ultrasonic sensor

Working

              

             The working of this project is as a combination of two project, refer two both project for their circuit diagram. Ultrasonic distance meter project , GSM900 send Message project ; Once you understand how these two project are working then it maybe easier for you to make your own circuit diagram, let now explain the working of this project into two steps:

  1. The first step is that an ultrasonic sensor is connected to a 16F877A MCU via its two interface pins (TRIG and ECHO) then the micro-controller find the distance as explain in the project, after that finding the real distance it will compare the threshold (distance "d") if the distance is greater than d the nothing will happen but if it is not verified then it will generate a message "SMS" to be send to a user.

  2. The most hard work is already done in the first step, here we will simply send ATs command trough UART to GSM900 module for sending SMS to inform the distance detected to the user.

 

Note:  Respect the connection as mentioned it the project for GSM900 interface with a micro-controller PIC and the connexion between the Ultrasonic sensor and the controller 16F877A.

Circuit Diagram

       You can make your own circuit diagram if you understand the interface of GSM900 with MCU 16F877A and the ultrasonic sensor for distance measurement with the controller.

Code and Comment

Download the full project here

#define baudrate 9615
char txt_message[] = "Real Distance Cm";
char Warning_message[] = "- Out Of Range - ";
char numero[]="+919728458177";        // Number
char message[]=" Msg Automatic OSat, Distance is : ";  // MESSAGE
char txt0[7];
int t1;
int _Enter_Button(){
 UART1_Write(13);
 UART1_Write(10);
}
   int _Message_Send(){
   UART1_Write(26);
   UART1_Write(26);
  }
  void main() {
            UART1_Init(baudrate);
            Delay_ms(10);
            TRISB.B1 = 0;
            PORTB.B1 = 0;
            TRISB.B7 = 0;
            TRISB.B6 = 1;
            T1CON = 0X30;
                while(1)  {
                                  TMR1H = 0;
                                  TMR1L = 0; 
                                  PORTB.F7 = 1;
                                  Delay_us(10);
                                  PORTB.F7 = 0;
                                  while(!PORTB.F6);
                                          T1CON.F0 = 1; 
                                  while(PORTB.F6);
                                                        T1CON.F0 = 0;
                                                        t1 = (TMR1L | (TMR1H<<8));  // valuer
                                                        t1 = t1/36.76;
                                                        if ( t1<=30){
                                                        ShortToStr(t1,txt0);
                                                        UART1_Write_text("Real Distance is :");
                                                        UART1_Write_text(txt0);
                                                        UART1_Write(13);
                                                        UART1_Write(10);
                                                 }

                                                    else{
                                                             UART1_Write_text(Warning_message);
                                                             UART1_Write(13);
                                                             UART1_Write(10);
                                                         }
                                     Delay_ms(1000);
                                     PORTB.B1 = 1;
                                                      if (t1 <=5){
                                                          UART1_write_Text("AT+CMGS=");
                                                          UART1_Write(0X22);              // double quotes
                                                          UART1_write_Text(numero);      
                                                          UART1_Write(0X22);              // double quotes
                                                          _Enter_Button();
                                                          Delay_ms(1000);
                                                          UART1_write_Text(message);
                                                          UART1_write_Text(txt0);
                                                          _Message_Send();
                                                          _Enter_Button();
                                                          Delay_ms(5000);
                                                          PORTB.B1 = 0;
                                                }
                                     }
                        }

bottom of page