0% found this document useful (0 votes)
554 views

Program For Arduino Communication With SIM 900 A Mini Module

This document provides code to control a GSM SIM900A mini module from an Arduino board. The code initializes serial communication with the module, then defines functions to send SMS messages, make calls, hang up calls, and more in response to input characters from the serial monitor. Connections are made between the Arduino 5V pins and the module.

Uploaded by

Thien Nguyenngoc
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
554 views

Program For Arduino Communication With SIM 900 A Mini Module

This document provides code to control a GSM SIM900A mini module from an Arduino board. The code initializes serial communication with the module, then defines functions to send SMS messages, make calls, hang up calls, and more in response to input characters from the serial monitor. Connections are made between the Arduino 5V pins and the module.

Uploaded by

Thien Nguyenngoc
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

/*THIS TUTORIAL USED GSM SIM900A MINI V3.9.

Connect 5VT to D9 and 5VR to D10

Feed GSM SIM900A with Arduino's 5V

Code by IDAYU SABRI - MYBOTIC

*/

#include <SoftwareSerial.h>

SoftwareSerial mySerial(7, 8);

char msg;

char call;

void setup()

mySerial.begin(115200); // Setting the baud rate of GSM Module (Baudrate default at SIM 900A
mini module is 115200)

Serial.begin(9600); // Setting the baud rate of Serial Monitor (Arduino)

Serial.println("GSM SIM900A BEGIN");

Serial.println("Enter character for control option:");

Serial.println("h : to disconnect a call");

Serial.println("i : to receive a call");

Serial.println("s : to send message");

Serial.println("c : to make a call");


Serial.println("e : to redial");

Serial.println();

delay(100);

void loop()

if (Serial.available()>0)

switch(Serial.read())

case 's':

SendMessage();

break;

case 'c':

MakeCall();

break;

case 'h':

HangupCall();

break;

case 'e':

RedialCall();

break;

case 'i':

ReceiveCall();
break;

if (mySerial.available()>0)

Serial.write(mySerial.read());

void SendMessage()

mySerial.println("AT+CMGF=1"); //Sets the GSM Module in Text Mode

delay(1000); // Delay of 1000 milli seconds or 1 second

mySerial.println("AT+CMGS=\"+84819009419\"\r"); // Replace x with mobile number

delay(1000);

mySerial.println("sim900a sms");// The SMS text you want to send

delay(100);

mySerial.println((char)26);// ASCII code of CTRL+Z

delay(1000);

void ReceiveMessage()

mySerial.println("AT+CNMI=2,2,0,0,0"); // AT Command to recieve a live SMS

delay(1000);

if (mySerial.available()>0)

{
msg=mySerial.read();

Serial.print(msg);

void MakeCall()

mySerial.println("ATD+84819009419;"); // ATDxxxxxxxxxx; -- watch out here for semicolon at the


end!!

Serial.println("Calling "); // print response over serial port

delay(1000);

void HangupCall()

mySerial.println("ATH");

Serial.println("Hangup Call");

delay(1000);

void ReceiveCall()

mySerial.println("ATA");
delay(1000);

call=mySerial.read();

Serial.print(call);

void RedialCall()

mySerial.println("ATDL");

Serial.println("Redialing");

delay(1000);

You might also like