Connecting GSM With Arduino Mega 2560

Introduction:

In this article I will explain about sending and receiving emergency warning messages from Arduino Mega 2560. It can easily send and receive messages at the time of emergency.
 
Parts Of List:
  • Arduino Mega 2560
  • GSM
  • Bread Board
  • Jumber Wires
GSM:
  • GSM means Global System For Mobile, it can be used to send and receive  message in critical area.
  • It can also act as the GSM modem.
  • It can have a PIN configuration and MIC is also attached.


                            Figure 1: GSM Board 
Connection:

ArduinoMega 2560 To GSM Board:
  • Connect the RX pin of the GSM board to the 04 of the Arduino Mega 2560.
  • Connect the TX pin of the GSM board to the 03 of the Arduino Mega 2560.
  • Connect the 5V power supply to the Arduino Mega 2560.
  • At last connect the 12 DC voltage to the GSM board. 
LED To Arduino Mega2560: 
  • Connect the positive pin in digital pin 11 in the Arduino Mega2560
  • Connect the negative pin in the GND to the Arduino Mega 2560.


    Figure 2: Connection from GSM to Arduino Mega2560 
Programming:  
  1. #include<SoftwareSerial.h>      
  2. SoftwareSerial firstSerial(03,04);  RX/TX    
  3. int led=11;    
  4. void setup()      
  5. {      
  6.   pinMode(led,OUTPUT);    
  7.   firstSerial.begin(9600);      
  8.   Serial.begin(9600);      
  9.   delay(1000);      
  10. }      
  11. void loop()      
  12. {      
  13.   if(Serial.available()>0)    
  14.   digitalWrite(led,HIGH);      
  15.   switch(Serial.read());      
  16. }      
  17. void sndmsg()      
  18. {      
  19.   firstSerial.println("AT+CMGF=1");      
  20.   delay(1000);      
  21.   firstSerial.println("AT+CMGS=\"+xxxxxxxxxx\"\r");  //Enter Your Mobile Number instead XXXX while Testing    
  22.   delay(1000);      
  23.   firstSerial.println("sms messagers sender ");      
  24.   delay(100);      
  25.   firstSerial.println((char)23);      
  26.   delay(1000);      
  27. }      
Explanation:
  • For sending message it will have mobile number in the code.
  • For receiving message it will have the SIM card inside the GSM modem.
  • When the message is sent, the LED glows. 
Output:

                                          
                                                                            Figure 3: Output 
   
Read more articles on Arduino:

Up Next
    Ebook Download
    View all
    Learn
    View all