Send and Receive Messages using SIM800L with Arduino

You can send & receive messages using SIM800L with Arduino, even can you this GSM module with Arduino to make calls as well. In this way you can use this module in locations where you have no internet connection and far away from your spot.

SIM800L HARDWARE

Most important part of the module is the Chip made by SIMCom. Its operating voltage in which it works fine ranges from 3.7 V to 4.4 V (recommended), but you can use 5 V with some nominal current.

Note:  don’t forget to connect ground first then other connection with your Arduino to avoid module damage or make all connections first then power-up the circuit.

GSM MODULE SIM800L PINOUT

SIM800L Pinout

  1.  U.FL Connector
    An antenna is required to transmit and receive signals wirelessly. In this module SIM800L we have a choice to choose between two antennas, First one is IPX Antenna and other is the helical antenna.
    Here we can connect any 3dBi GSM antenna using U.HL to SMA connector if we want wired antenna to other locations.
    SMA UFL Antenna
  2. NET
    Here we can connect helical antenna come along with the module.
    helical gsm antenna
  3. VCC
    Voltage supply pin, the voltage at which it works fine ranges from 3.7 V to 4.4 V (recommended), but you can use 5 V with some nominal current.
  4. RST
    Reset pin, pulling this pin low for 100 ms will hard reset the module.
  5. RxD
    This is the receiver pin used in Serial communication
  6. TxD
    This is the transmitter pin used in Serial communication
  7. GND
    Ground pin, connect it to the Ground pin of Arduino
  8. LED
    There is an LED which tells you about the status of your module.

      1. If it blinks once every second: Module is running but not yet connected to the cellular network.
      2. If it blinks once every two seconds: The GPRS data connection request is activated.
      3. If it blinks once every three seconds: The module got connected to the cellular network and now it can send or receive SMS & calls
  9. RING
    It is used in detecting calls and/or SMS, it remains by-default HIGH but if a call is received it gives LOW pulse for 120ms.
  10. DTR
    This pin is used to activate/deactivate sleep mode. Where high means sleep mode activated, disables serial communication while low means sleep mode deactivated.
  11. MIC +
  12.  MIC –
    Pins 11, 12 MIC +/- is used for microphone pins
  13. SPK +
  14. SPK –
    pins 13, 14 SPK +/- is used for Speaker interface
  15. Micro SIM socket
    Sim support 2G will work perfectly fine. See the diagram to see how to insert a sim. It supports  4 Bands namely GSM850, EGSM900, DCS1800 and PCS1900.

ARDUINO INTERFACING WITH SIM800L

CONNECTION TABLE

S.N. ARDUINO SIM800L
1. +5 V VCC
2. GND GND
3. 2 (RX) TXD
4. 3 (TX) RXD

CIRCUIT DIAGRAM INTERFACING SIM800L WITH ARDUINO

SEND & RECEIVE MESSAGES USING SIM800L

Note:  don’t forget to connect ground first then other connection with your Arduino to avoid module damage or make all connections first then power-up the circuit.

SEND & RECEIVE MESSAGES USING SIM800L ARDUINO CODE

Arduino code for SIM800L has been done into 3 parts

  1. Testing AT commands
  2. Receive message using sim800l
  3. Send a message using sim800l

1. TESTING AT COMMANDS

#include <SoftwareSerial.h>
/* Tutorial link:  https://pijaeducation.com/arduino/gsm/send-receive-messages-using-sim800l-with-arduino/
   Create software serial pins: pin 2 as RX & 3 as TX
   Connect SIM800L module Rx to Pin 3 (Tx) of Arduino & Tx to Pin 2 (Rx) of Arduino
*/
SoftwareSerial mySerial(2, 3);

void setup() {
  Serial.begin(9600);
  mySerial.begin(9600);
  Serial.println("Initializing...");
  delay(1000);

  // Send attention command to check if all fine, it returns OK
  mySerial.println("AT");
  updateSerial();

  // Signal quality test, value range is 0 - 31 , 31 is the Excellent
  mySerial.println("AT+CSQ");
  updateSerial();

  // Used to read the ICCID from the SIM, if returns means SIM is plugged
  mySerial.println("AT+CCID");
  updateSerial();

  // Check whether it has registered on the network
  mySerial.println("AT+CREG?");
  updateSerial();
}

void loop() {
  updateSerial();
}

// For data transmission from Serial to Software Serial port & vice versa
void updateSerial() {
  delay(500);
  while (Serial.available()) {
    mySerial.write(Serial.read());//Forward what Serial received to Software Serial Port
  }

  while (mySerial.available()) {
    Serial.write(mySerial.read());//Forward what Software Serial received to Serial Port
  }
}

2. RECEIVE MESSAGE USING SIM800L

#include <SoftwareSerial.h>
/* Tutorial link: https://pijaeducation.com/arduino/gsm/send-receive-messages-using-sim800l-with-arduino/
   Create software serial pins: pin 2 as RX & 3 as TX
   Connect SIM800L module Rx to Pin 3 (Tx) of Arduino & Tx to Pin 2 (Rx) of Arduino
*/
SoftwareSerial mySerial(2, 3);

void setup() {
  Serial.begin(9600);
  mySerial.begin(9600);
  Serial.println("Initializing...");
  delay(1000);

  // Send attention command to check if all fine, it returns OK
  mySerial.println("AT");
  updateSerial();
  // Configuring module in TEXT mode
  mySerial.println("AT+CMGF=1");
  updateSerial();

  // Decides how newly arrived SMS messages should be handled
  mySerial.println("AT+CNMI=1,2,0,0,0");   
  updateSerial();
}

void loop() {
  updateSerial();
}

// For data transmission from Serial to Software Serial port & vice versa
void updateSerial() {
  delay(500);
  while (Serial.available()) {
    mySerial.write(Serial.read());//Forward what Serial received to Software Serial Port
  }
  
  while (mySerial.available()) {
    Serial.write(mySerial.read());//Forward what Software Serial received to Serial Port
  }
}

3. SEND MESSAGE USING SIM800L

#include <SoftwareSerial.h>
/* Tutorial link: https://pijaeducation.com/arduino/gsm/send-receive-messages-using-sim800l-with-arduino/
   Create software serial pins: pin 2 as RX & 3 as TX
   Connect SIM800L module Rx to Pin 3 (Tx) of Arduino & Tx to Pin 2 (Rx) of Arduino
*/
SoftwareSerial mySerial(2, 3);

void setup() {
  Serial.begin(9600);
  mySerial.begin(9600);
  Serial.println("Initializing...");
  delay(1000);

  // Send attention command to check if all fine, it returns OK
  mySerial.println("AT");
  updateSerial();

  // Configuring module in TEXT mode
  mySerial.println("AT+CMGF=1");
  updateSerial();

  // to send message use these 3 statements, upto write(26)
  // change ZZ with country code and xxxxxxxxxxx with phone number to sms
  mySerial.println("AT+CMGS=\"+ZZxxxxxxxxxx\""); // 1)
  updateSerial();
  mySerial.print("https://Shoolinlabs.com/tutorial"); // 2) text content 
  updateSerial();
  mySerial.write(26); // 3)
}

void loop() {
  updateSerial();
}

// For data transmission from Serial to Software Serial port & vice versa
void updateSerial() {
  delay(500);
  while (Serial.available()) {
    mySerial.write(Serial.read());//Forward what Serial received to Software Serial Port
  }

  while (mySerial.available()) {
    Serial.write(mySerial.read());//Forward what Software Serial received to Serial Port
  }
}

 

 

4.4 9 votes
Article Rating
Subscribe
Notify of
guest
2 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
Gigi
Gigi
2 years ago

how to use it without serial bro?

2
0
Would love your thoughts, please comment.x
()
x