Components Required:
1. Arduino Uno
2. Linux PC/Windows PC (Tested with Windows 10, Ubuntu 14.04 LTS)
3. USB cable A to B
4. SIM800L GSM Module
5. 12V 1A Adapter (if you are using SIM900A GSM Modem)
6. SIM Card
7. Jumper Wires
Way to go ->
1. Connect Arduino Uno to PC via the USB cable.
2. Upload SMS.ino to the Arduino.
SMS.ino
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // (Rx, Tx)
void setup()
{
mySerial.begin(9600); // Setting the baud rate of GSM Module
Serial.begin(9600); // Setting the baud rate of Serial Monitor (Arduino)
delay(100);
}
void loop()
{
if (Serial.available() > 0)
switch (Serial.read())
{
case 's':
SendMessage();
break;
case 'r':
RecieveMessage();
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=\"+91xxxxxxxxxx\"\r"); // Replace x with mobile number
delay(1000);
mySerial.println("I am SMS from GSM Module");// The SMS text you want to send
delay(100);
mySerial.println((char)26);// ASCII code of CTRL+Z
delay(1000);
}
void RecieveMessage()
{
mySerial.println("AT+CNMI=2,2,0,0,0"); // AT Command to receive a live SMS
delay(1000);
}
4. In the empty box at the top of the serial monitor type -> s, and click Send to send an SMS.
4. In the empty box at the top of the serial monitor type -> s, and click Send to send an SMS.
No comments:
Post a Comment