• Home
  • Prakash
    • R and D
    • Smart Home
  • Basics
    • Capacitors
      • Color codeing Disc Capacitor Capacitor characterstics Polarity Non Polarity Series Connection Parallel Connection
    • Diodes
      • Zener Diode Light Emitting Diode Signal Diode Photo Diode
    • Inductors
    • Transistor
      • Silicon Germenium NPN PNP MOSFET SCR
    • Resistors
      • Color codeing 4-Band 5-Band Series Parallel Potential Meter
    • Logics
      • Analog Logic
      • Digital Logic
      • Hexa Decimal Numbers
      • Octal Numbers
      • Binary Fraction
      • Binay to Decimal
    • OP-Amplifiers
      • Basics
      • Oscillators
      • Transistor Switch
      • 555 IC circuits
      • Waveform Generators
      • 741 IC Circuits
    • Power supply
      • Transformer
      • Halfwave Rectifier
      • Fullwave Rectifier
      • Bridge Rectifier
      • 78xx Series
      • 0 to 30v Regulator
  • Modules
    • H-Bridge
      • L293D Bridge
      • Relay Bridge
    • RF 434MHz Modules
    • Relay Modules
    • Push to ON switch
    • Push to OFF switch
  • Sensors
    • Analog sensors List-1
      • LDR Photo Diode Solar Cell Transducers Temperature Humidity Sensor Soil Moisture Ranger Sensor Range Detection
    • Analog sensors List-2
      • Flame Sensor Force Sensor Flex Sensor Ambient Sensor Motion Sensor Vibration Sensor Sound Sensor UltraSonic Sensor GrayScale Sensor
    • Digital Sensors
      • Touch Sensor Tilt Sensor Signal
    • 3-Axis Sensor
    • Gyro Sensor
  • Projects
    • Embedded
      • Mini Projects 8051 Arduino NodeMCU MSP430 Raspberry IOT ARM
    • C #
      • Visual Basic Visual Studio
    • Matlab
    • VLSI
    • PHP-HTML
    • Contribute
  • Downloads
  • Technology

Interfacing GSM Module with Arduino

SINGLE WIRE COMUNICATION 
  • int sensor1=2;

  • int x;

  • int state;

  • int flag=0; 

  • int led1 =5;

  • int reset = 8;

  • int buz =13;

  • boolean s1;

  • void setup()

  • {  pinMode(sensor1,INPUT);
  •   pinMode(led1,OUTPUT);
  •   pinMode(reset,OUTPUT);
  •   digitalWrite(led1,LOW);
  •   digitalWrite(buz,LOW);
  •   Serial.begin(9600);
  •   delay(2000);
  •  Serial.println("AT+CNMI=2,2,0,0,0");
  •   delay(2000);
  •   Serial.println("AT+CMGF=1");
  •   delay(2000);
  •   Serial.print("AT+CMGS=\"");
  •     Serial.print("+919959352839");
  •     Serial.println("\"");
  •     delay(900);
  •     Serial.print("security sys on");
  •     delay(900);
  •     Serial.write(0x1A);
  •     Serial.write(0x0D);
  •     Serial.write(0x0A);
  • }
  • void loop()
  • {  s1=digitalRead(sensor1);

  •   if(s1==HIGH)

  •   {

  •     if(x==0)

  •     { digitalWrite(led1,HIGH);     
  •     Serial.print("AT+CMGS=\"");
  •     Serial.print("+919959352839");
  •     Serial.println("\"");
  •     delay(900);
  •     Serial.print("Sensor#1 is Active");
  •     delay(900);
  •     Serial.write(0x1A);
  •     Serial.write(0x0D);
  •     Serial.write(0x0A);
  •         digitalWrite(buz,HIGH);
  •         delay(5000);
  •         digitalWrite(buz,LOW);
  •         x=1;
  •   }
  •  delay(1000);
  •   }
  • }

In this article, I am going to explain about interfacing of GSM Module with Arduino. Interfacing a GSM module to Arduino is pretty simple. We have to make only 3 connections between the GSM module and Arduino. For the working demonstration we will be sending an SMS to a particular number whenever a switch is pressed.

Components Required

  • Arduino Uno
  • GSM Modem
  • Switch
  • 1kΩ Resistor
  • Breadboard
  • Connecting Wires

Hardware

Circuit Diagram

Interfacing GSM Modem with Arduino - Circuit Diagram
Interfacing GSM Modem with Arduino – Circuit Diagram

Connections

  • Connect TX pin of GSM Module to RX pin of Arduino Uno.
  • Connect RX pin of GSM Module to TX pin of Arduino Uno.
  • Connect GND pin of GSM Module to GND pin of Arduino Uno.

Steps to boot GSM module

  1. Power ON the GSM module by providing 5V and GND.
  2. Insert the SIM card to GSM module and lock it.
  3. Initially blinking rate of network LED will be high. After sometime observe the blinking rate of ‘network LED’ (GSM module will take some time to establish connection with mobile network)
  4. Once the connection is established successfully, the network LED will blink continuously for every 3 seconds.
  5. Even we can check the connection establishment of GSM module with mobile by making a call to the number of the SIM. If we hear a ring back, the GSM module has successfully established network connection.

Software

Code

const int Input1=8;
int State1=0;

void setup(){
  Serial.begin(9600);
  pinMode(Input1, INPUT);
}

void loop()
{
  State1= digitalRead(Input1);

  if(State1 == HIGH)
    {
      sendsms();
      delay(2000);
    }
}

void sendsms()
{
  Serial.println("AT\r");
  delay(1000);
  Serial.println("AT+CMGF=1\r");
  delay(1000);
  Serial.println("AT+CMGS=\"XXXXXXXXXX\"\r");
  delay(1000);
  Serial.println("MESSAGE 1");
  delay(1000);
  Serial.println((char)26);
  delay(100);
}

Code Explanation

Input1 is a constant integer type, constants won’t change and it is set to pin number 8 of Arduino. State1 is a variable, variables will change and  it is assigned with 0 value.
const int Input1=8;
int State1=0;
Put your setup or configuration code in the setup function, it will only run once during the startup. Initialize the Input1 pin as an input. Set the Baudrate of Serial communication as 9600.
void setup(){
  Serial.begin(9600);
  pinMode(Input1, INPUT);
}
Put your main code in void loop() function to run repeatedly. Read the state of the State1 variable value and check if the switch is pressed which is connected pin number 8 of arduino. If it is, then it will call GSM function to send SMS to the programmed mobile number.

void loop(){
  State1= digitalRead(Input1);

  if(State1 == HIGH)
  {
    sendsms();
    delay(2000);
  }
}
This function is to used establish communication between arduino and GSM module by AT commands to send SMS to the provided mobile number.
void sendsms()
{
  Serial.println("AT\r");        //AT is the abbreviation of Attention. Checking communication.
  delay(1000);
  Serial.println("AT+CMGF=1\r"); // To set the modem in SMS sending mode.
  delay(1000);
  Serial.println("AT+CMGS=\"XXXXXXXXXX\"\r"); // For sending SMS to a number.
  delay(1000);
  Serial.println("MESSAGE 1"); // Message to send
  delay(1000);
  Serial.println((char)26);    // End command for SMS a^Z, ASCII code 26.
  delay(100);
}

Practical Implementation

Interfacing GSM Modem with Arduino - Practical Implementation
Interfacing GSM Modem with Arduino – Practical Implementation

Working

The switch will be connected digital pin 8 of arduino as an input. Whenever we press the switch, the arduino will communicate with GSM module by using AT commands and sends “MESSAGE” to the programmed mobile number. AT+CMGS at command is used to send SMS.
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
Terms and Conditions -
Privacy Policy -

Contact Us

Name

Email *

Message *