Connecting GSM With Arduino Mega 2560


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
  • Jumper Wires
  • GSM means Global System For Mobile, it can be used to send and receive a message in a 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
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 is 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
  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(;      
  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. }      
  • For sending a message it will have a mobile number in the code.
  • For receiving the message it will have the SIM card inside the GSM modem.
  • When the message is sent, the LED glows. 
Figure 3: Output 
Read more articles on Arduino:

Recommended Ebook

Printing in C# Made Easy

Download Now!
Similar Articles