Global System for Mobile Communication (GSM) is a mobile communication modem. It was created to describe the protocols for second-generation (2G) digital cellular networks used by mobile phones and is now the default global standard for mobile communications. And in this tutorial, i am using SIM 800l Module because it is very tiny and easy to use.
Note: Use a micro sim card and it must have a load.
This tutorial aims to:
Circuit developed using fritzing
Connect the following:
| GSM Module | Arduino Uno |
|---|---|
| 5VIN | 5V |
| GND | GND |
| SIM_TXD | RX0 or pin 0 |
| SIM RXD | TX0 or pin 1 |
| GND | GND |
GSM Module uses the AT Commands this instructions are used to control modems. AT is a short term for ATtention. There are different commands to perform different tasks using the GSM module. GSM modems and mobile phones support AT commands set that is specific to the GSM technology, which includes SMS-related commands like AT+CMGS (Send SMS message), AT+CMSS (Send SMS message from storage), AT+CMGL (List SMS messages) and AT+CMGR (Read SMS messages). Read more.
Code inside the setup function, the code to run once.
void setup() {
}
First, initialize the baud rate of the GSM Module
Serial.begin(9600);
Second, \r will start the message and followed by 1 second delay everytime we use an AT command.
Serial.print("\r");
delay(1000);
Third, set the GSM Module in Text Mode
Serial.print("AT+CMGF=1\r");
delay(1000);
Fourth, input the number to which you want to send the sms with country code
Serial.print("AT+CMGS=\"+639xxxxxxxxxx\"\r"); //replace x with the mobile number you want to send the message.
delay(1000);
Fifth, input the message you want to send.
Serial.print("This is a test message using GSM Module with Arduino.\r");
delay(1000);
Then, to end the SMS content it is identified with CTRL+Z symbol. The ASCII value of this CTRL+Z is 26. So we need to send a char(26) to GSM module using this line
Serial.println((char)26);
delay(1000);
And lastly, to read the message with the correct format we need to write this hex values.
Serial.write(0x1A);
Serial.write(0x0D);
Serial.write(0x0A);
delay(1000);
We leave the loop function empty because we have nothing to do after the setup
void loop() {
}
Note: Before uploading the program disconnect the pins 0 and 1 or the TX and RX in Arduino Uno so that it would not give an error message. And just re-connect after uploading.
This is the screenshot of the message sent from the GSM Module
To visit my previous contributions click below: