Send SMS using SIM900A GSM/GPRS Arduino Module.
Requirements:
- Arduino UNO/Nano/Mega
- SIM900A GSM Module
- 12V/1A DC Power Adapter
- Connecting Wires
Circuit Diagram:
Pin Connections:
Connect RX of GSM module to Pin 7 in UNO
Connect TX of GSM module to Pin 8 in UNO
Connect GND of GSM module to Pin GND in UNO
Connect 5V of GSM module to Pin 5V or Vin in UNO
Note: Some GSM modules requires External 12V power adapter. Use 12V/1A DC power adapter instead of using 5V in Arduino.
Code:
#include <GPRS_Shield_Arduino.h>
#include <SoftwareSerial.h>
#include <Wire.h>
#define MESSAGE “Hello World”
#define PIN_TX 8
#define PIN_RX 7
#define BAUDRATE 9600
#define PHONE_NUMBER “Enter your Mobile Number here”
#define MESSAGE_LENGTH 160
char message[MESSAGE_LENGTH];
char phone[16];
char datetime[24];
int8_t messageIndex = 0;
GPRS Sim900_test(PIN_TX,PIN_RX,BAUDRATE);
void setup() {
Serial.begin(9600);
pinMode(4, OUTPUT);
while(!Sim900_test.init())
{
delay(1000);
Serial.println(“SIM900 initialization error”);
}
Serial.println(“SIM900 initialization success”);
memset(message, 0, 160);
}
void loop() {
Sim900_test.sendSMS(PHONE_NUMBER, MESSAGE);
delay(100000);
}
Code Explanation:
#define MESSAGE “Hello World”
You can change the Message String if Required.
#define PHONE_NUMBER “Enter your Mobile Number here”
Replace “Enter your Mobile Number here” with the mobile number which you need to send the SMS.
Sim900_test.sendSMS(PHONE_NUMBER, MESSAGE);
This is the function from GPRS_Shield_Arduino Library it requires the parameters of phone number and a message string.
Note: This program will send the SMS for every 100 seconds.