How to connect arduino uno to GSM module very simple

There are various types of GSM modules accessible in market. We are utilizing the most prevalent module dependent on SIM900 and Arduino Uno for this instructional exercise

Worldwide System for Mobile correspondence (GSM) is advanced cell framework utilized for cell phones. It is a global standard for portable which is broadly utilized for long separation correspondence. 

There are different GSM modules accessible in market like SIM900, SIM700, SIM800, SIM808, SIM5320 and so forth. 

SIM900A module enables clients to send/get information over GPRS, send/get SMS and make/get voice calls. 

The GSM/GPRS module utilizes USART correspondence to speak with microcontroller or PC terminal. AT directions are utilized to design the module in various modes and to perform different capacities like calling, presenting information on a site, and so forth. 

For more data about Sim900A and how to utilize it, allude the point Sim900A GSM/GPRS Module in the sensors and modules area.

Arduino uno - GSM900A

8                     - RXD
9                     - TXD
GND              - GND

Code

#include <SoftwareSerial.h> 
SoftwareSerial sim(8, 9); 
int _timeout; 
String _buffer; 
String number = "enter your number with contry code"; //-> change with your number 

void setup() { 
  delay(7000); //delay for 7 seconds to make sure the modules get the signal 
  Serial.begin(9600); 
  _buffer.reserve(50); 
  Serial.println("Sistem Started..."); 
  sim.begin(9600); 
  delay(1000); 
  Serial.println("Type s to send an SMS, r to receive an SMS, and c to make a call"); 

void loop() { 
  if (Serial.available() > 0) 
    switch (Serial.read()) 
    { 
      case 's': 
        SendMessage(); 
        break; 
      case 'r': 
        RecieveMessage(); 
        break; 
      case 'c': 
        callNumber(); 
        break; 
    } 
  if (sim.available() > 0) 
    Serial.write(sim.read()); 

void SendMessage() 
  //Serial.println ("Sending Message"); 
  sim.println("AT+CMGF=1");    //Sets the GSM Module in Text Mode 
  delay(1000); 
  //Serial.println ("Set SMS Number"); 
  sim.println("AT+CMGS=\"" + number + "\"\r"); //Mobile phone number to send message 
  delay(1000); 
  String SMS = "Hello, how are you?"; 
  sim.println(SMS); 
  delay(100); 
  sim.println((char)26);// ASCII code of CTRL+Z 
  delay(1000); 
  _buffer = _readSerial(); 

void RecieveMessage() 
{       
  Serial.println ("SIM800L Read an SMS"); 
  delay (1000); 
  sim.println("AT+CNMI=2,2,0,0,0"); // AT Command to receive a live SMS 
  delay(1000); 
  Serial.write ("Unread Message done"); 

String _readSerial() { 
  _timeout = 0; 
  while  (!sim.available() && _timeout < 12000  ) 
  { 
    delay(13); 
    _timeout++; 
  } 
  if (sim.available()) { 
    return sim.readString(); 
  } 

void callNumber() { 
  sim.print (F("ATD")); 
  sim.print (number); 
  sim.print (F(";\r\n")); 
  _buffer = _readSerial(); 
  Serial.println(_buffer); 

Use this you can send sms and receive sms and send call to your phone. 

1 comment:

Powered by Blogger.