Showing posts with label GSM. Show all posts
Showing posts with label GSM. Show all posts

Tuesday, 8 May 2012

GeoLocation Tracking with GPS and GSM

The main objective of this project is to design a system where the location of the client module can be remotely sent to a customer on demand in human readable address


It consists of 2 main modules

1. Server Module

  • GSM modem : The server GSM modem will take the request from the customer in the form of a SMS to track the client module
  • Server Application : The server application keeps polling the server GSM modem for any request from customer or response from client module. For any request from customer, it will send a request to client module to send the Geo Location data. In case of response from client module, it will Reverse Geocode the Co Ordinates using Yahoo&Reg/ Google&Reg reverse geocoding service and send an SMS with the location in a human readable address

2. Client Module

  • GSM modem : The client GSM modem is used to receive and respond to location request
  • ARM processor : When there is request on the location, the ARM processor takes the raw data from GPS receiver and converts them to Geolocation Co-ordinates and sends the same to Server module using client GSM modem

Note:

  • In this project we wanted to send the location as human readable address and hence Yahoo® / Google® Reverse Geo Coding is used. In case only Geo Co ordniates is required to be sent, it will not require a Server Module
  • Below are the examples of Rest Webservices of Reverse Geocoding. The XML is parsed in the Server Application program
        Google® : http://maps.googleapis.com/maps/api/geocode/xml?latlng=12.971891,77.641154&sensor=true

        Yahoo® : http://where.yahooapis.com/geocode?q=12.971891,77.641154&gflags=R&appid=[yourappidhere]
  • The processor in the client module required 2 serial ports one for GSM modem and the other for GPS reciver. Hence ARM processor was chosen over 8051

Saturday, 17 March 2012

Sending SMS using AT Commands

This article describes sending a SMS from a Microcontroller through a GSM modem using AT Commands. through RS232. AT commands can be sent to a GSM modem via a computer serial port or from the serial port of a 8051 Microcontroller.

Computer serial port


1. Connect your GSM modem to the computer serial port. New systems nowadays dot not have serial port, hence you would need to buy a USB to serial converter and connect the GSM modem to it.

2. If you are using Windows XP® OS, open Programs -> Accessories -> Communications -> HyperTerminal

3. Select the COM port you have the modem connected to.

4. Check the port settings, make sure that the baud rate matches with that of the GSM modem and and also that the Flow Control is set to "None".

5. Type the AT Commands below in the HyperTerminal Editor

AT+CMGF = 1 and Enter
AT+CMGS="+919449XXXXXX" and Enter
"Electronicprojs.Blogspot.com" and Hit CTRL+Z

6. In Windows 7® OS though, there is no hyperterminal program inbuilt. You will have to download a similar one. There are many good free programs available.

7. You would need to note that in this case we are connecting the serial port cable from Female pin (GSM Modem) to Male pin (Computer). Hence no crossing is required. In other words, we should use a straight cable.

8051 MicroController Serial port


1. 8051 SFR's are programmed for a baud rate of 9600.

2. Send the AT commands in #5 above through code. For Enter use escape character "\r" and for CTRL+Z use ASCII 0x1A.

3. The serial port cable is connecting from Female pin (GSM Modem) to Female (8051 Board). So you need a have a female to male converter. Also, make sure that the Rx and Tx inside in the converter are crossed. In otherwords, the Rx pin of GSM Modem should go to Tx pin of 8051 microntroller. This is called a crossed cable.

4. Below is the C program using Keil® Compiler for 8051. We added infinite while loop after the sendsms() routine because otherwise we found that the code compiled was sending the SMS in a infinite loop.

Note : Beginners always complain about their code working through serial port of a computer but the same not working through chip. It is very essential to understand the difference between crossed cable and straight cable as well as the pins configurations of male and female connectors before starting.

C program

#include <REGX51.H>
#include <AT89X51.H>

unsigned char *command_AT = "AT\r";
unsigned char *command_CMGF = "AT+CMGF=1\r";
unsigned char *command_CMGS = "AT+CMGS=\"+919449XXXXX\"\r";
unsigned char *message = "electronicprojs.blogspot.com";
unsigned char CTRLZ = 0x1A;

void puts(unsigned char* ptr);
void putc(unsigned char chr);
void sendsms(void);
void initialize();

main()
{
initialize();
sendsms();
while(1);
}

void initialize()
{
SCON  = 0x50;   /*SCON: mode 1, 8-bit UART, enable receive      */
TMOD |= 0x20;   /*TMOD: timer 1, mode 2, 8-bit                  */
TH1   = 0xFD;   /*TH1:  for 9600 baud                           */
TR1   = 1;      /*TR1:  timer 1 run                             */

}

void sendsms()
{
puts(command_AT);
puts(command_CMGF);
puts(command_CMGS);
puts(message);
putc(CTRLZ);
}

void puts(char* p)
{
char *temp = p;  /*temp pointer so that the actual pointer is not displaced */
while(*temp != 0x00)
{
putc(*temp);
temp++;
}
}

void putc(unsigned char chr)
{
SBUF = chr;
while(TI==0);  /*Wait until the character is completely sent */
TI=0;                    /*Reset the flag */
}

Sunday, 4 March 2012

People Counting Machine with GSM

The main objective of this project is to design a system which counts the number of people present inside a premises with the count being sent automatically as an SMS upon dialing the phone number.


It consists of 3 modules

1. Infrared Transmitter and Receiver
There are two of them say IR1 and IR2. Breaking the beam of IR1 first and then IR2 will increment the count by 1 where as breaking the beam IR2 and then IR1 will decrement the count. The output of IR1 and IR2 are connected to microntroller interrupts INT0 and INT1 respectively. Complete design of IR Tx and Rx can be found here : Infrared Beam break Detector


2. Microncontroller with LCD
The microcontroller used here is 89c51. INT0 and INT1 of the micronctroller is connected to output of IR1 and IR2 respectively. It is connected to a GSM module via a serial port. And the microncontroller is also connected to a LCD which displays the total count at any given point of time. The microntroller increments or decrements the count based on weather INT0 interrupt occurs first and then INT1 or vice versa and continuously displays on the LCD. Micronctroller will also receive a serial interrupt when there is an incoming call in whch time it will read the phone number, disconnect and send the total count as a SMS

3. GSM Module
The microcontroller sends AT commands to GSM module to read the phone number, disconnect and send an SMS to the calling number. Below are the AT commands used.

1. Disconnect a call
ATH  and Enter

2. Read the phone number of an incoming call
  • Set the below AT command only once
  • AT+CLIP=1 and Enter
  • When there is a incoming call, the data from GSM will be similar to below for default settings
    • RING
      +CLIP: "+919449XXXXXX",145,"","",0
      RING
      +CLIP........
    • Read the phone number above into an array and send the SMS
    3. Send an SMS

    AT+CMGF=1 and Enter
    AT+CMGS="+919449XXXXXX" and Enter
    "Hello World" and CTRL+Z

    During programming CTRL+Z requires to be sent as 0x1A Ascii character while the escape character for Enter is '\r'. For better understanding on sending a SMS and C code, refer to Sending SMS using AT commands


    Saturday, 25 February 2012

    Burglar Alert through SMS

    The main purpose of this project is to design a system that would automatically send SMS to a predefined number up on the Infrared beam is broken between transmitter and receiver.


    It consists of 3 modules

    1. Infrared transmitter and receiver
    It consists of 38kHz Infrared transmitter and TSOP1738 Infrared receiver. The transmitter has 40 burst cycles and 40 gap cycles that satisfies the requirement of TSOP1738 that between 10 to 70 burst cycles, there has to be atleast 14 gap cycles. Complete design can be found here : Infrared Beam Break Detector circuit

    2. Microcontroller
    The microcontroller used here is 89c51. When the Infrared beam is broken, there is a high to low signal in the Infrared Beam Break Detector circuit. The micrcontroller is initialized to received edge triggered external interrupt (EXT0). When a interrupt is triggered, the micrcontroller sends the necessary AT commands to send an SMS to a predefined phone number.

    3. GSM modem
    The microcontroller sends AT commands to GSM module to send an SMS to the predefined number. Below are the AT commands used. The AT commands are

    AT+CMGF=1 and Enter
    AT+CMGS="+919449xxxxxx"
    and Enter
    "Burglar Alert!" and CTRL+Z

    Complete explanation and C-code can be found here : Sending SMS using AT commands