Sim800l Delete All Sms

Tell the Arduino to send you a specified sensor data to your phone all via SMS. Used DHT11+MLX90614 for example

  • 3,240 views
  • 3 comments
  • 3 respects

Smart Machine Smart Decision SIM800 SeriesAT Command ManualV1.10 2016-02-01. Try the below script in the AT Command Tester tool //Script: atcmgd.at //Use this script to AT+cmgd AT command //Get the command support AT+cmgd=? WAIT=2 //Delete SMS message at index 1 AT+cmgd=1 WAIT=1 //Delete SMS message at index 2 AT+cmgd=2 WAIT=1 //Delete SMS message at index 3 AT+cmgd=3 WAIT=1 //Delete all read messages SMS messages, leave unread //messages. First of all here you have sim800 hardware design and here the AT commands. SIM800L is a quad-band GSM/GPRS module that works on frequencies GSM 850MHz, EGSM900MHz, DCS1800MHz and PCS1900MHz. SIM800L features GPRS multi-slot class12/ class 10(optional) and supports the GPRS coding schemes CS-1, CS-2, CS-2, CS-3 and CS-4. Setelah program selesai diupload, pengetesan dilakukan via serial monitor. Kita dapat melakukan beberapa pengetesan yang disesuaikan dengan fitur dari modul SIM800l yang kita gunakan seperti baca SMS, cek jumlah SMS, call, delete SMS, send USSD (cek pulsa), dll. I have a Huawei Modem connected to my VB.net project all AT Commands work such as CONNECT, READ and SEND SMS The only thing that I cannot work with is the DELETE SMS I have this code: With Seria.

Components and supplies

Arduino UNO
×1
SIM800L EVB
×1
MLX90614
×1
DHT11 Temperature & Humidity Sensor (3 pins)
×1

Apps and online services

About this project


Tutorial video - explaining all

Sponsored by: DigitSpace
Product used: SIM800L Module Replace SIM900A GSM GPRS 5V Serial with Antenna


Hello there, this is my third tutorial concerning SIM800L EVB version, make sure to take a look at previous ones, to not make this one long:

So here in this tutorial, I'm going to use the same module 'SIM800L EVB version' with Arduino Uno board, and I took for example 'DHT11' and 'MLX90614 contactless thermal sensor'.

And the idea is that I'm going to ask the Arduino via SMS to send me either the DHT values or the MLX values via SMS too, the project is relatively easy, the tricky part was to detect a substring withing the SMS content to be able to decide wheter the user asks for DHT values or MLX values.

HALT !!!

The Sim card used shouldn't be locked with a pin code otherwise use the AT commands to do it, and make sure you have enough credit to be able to send SMS... depends on your network provider.

This is the module I'm using:

And as said before the module works with AT commands, we saw some of them on the previous tutorials.

And for the power I'm using A Lithium Battery with A Buck converter:

Sms

Test 1

So the test #1 consist of just reading a SMS sent from the phone, and display it on the serial monitor.

Wiring

The wiring 1 can be found below, it's the basic wiring of the module, it's practical for all kind of tests.

Libraries

No special libraries are required here just the default SoftwareSerial.

Code

Code 1 can be found below.

The code is really easy first in the 'Setup()' we just send some 'AT commands' to make the module on the receiving text mode and set the way those SMS received should be handled.

And on the loop there is a classic communication function that permits the communication between the Arduino IDE Serial Monitor and Sim800L 'send/receive' between them

The functions used can be found in the code, but if you want to check them closely here's the document:

Result

Test 2

On the test#2 we will add DHT11 sensor and MLX90614 contactless thermal sensor... I used these two just as an example you can use whatever you want.

And in the code I integrated a part where I read the SMS received and check for the keywords 'DHT' or 'MLX'... and here of course you can replace it by your own or make a whole command i.e:'Send DHT data'.... to sum up with just look for a substring within a string :D

Wiring

The wiring 2 can be found below, we have just add the DHT11 and MLX90614

Libraries

Two libraries should be add (Because of the modules) depending on what you are using.

Code

Code 2 can be found below.

So in this code we:

  • Set the module to receiving SMS mode
  • Set the way to handle the SMS
  • If something is received -> Transmit to Arduino
  • Arduino will check for the 'Keywords' (DHT or MLX)
  • If one of them is found -> check which one
  • Make the reading
  • Send the Data to the programmed phone number

Result

The use of the serial monitor is optional, the device can work without it, here used just to troubleshoot in case of a problem or to check the state.

The method we used is just to look for a specified keyword within the message, doesn't care what's being sent with it

Go further

You can improve the way to detect the keywords in the SMS sent, it will be useful to do other projects that will be more interesting.

You can do multiple readings before sending the SMS to be more precise.

Send error SMS in case the sensor is not working properly.

Check the code and if you have a better method for this share it with us, Thanks.

That's all folks.

Sim800l Delete All Sms

Code

With comments to help you.
With comments to help you

Schematics

Author

SurtrTech
  • 20 projects
  • 103 followers

Published on

January 18, 2020
Write a comment

Members who respect this project

and 2 others

See similar projects
you might like

Table of contents

Write a comment

Whether you want to listen to what happens in your house that’s miles away from you or activate sprinkler system in your garden just with a silent call; Then SIM800L GSM/GPRS module serves as a solid launching point for you to get you started with IoT!

SIM800L GSM/GPRS module is a miniature GSM modem, which can be integrated into a great number of IoT projects. You can use this module to accomplish almost anything a normal cell phone can; SMS text messages, Make or receive phone calls, connecting to internet through GPRS, TCP/IP, and more! To top it off, the module supports quad-band GSM/GPRS network, meaning it works pretty much anywhere in the world.

Hardware Overview of SIM800L GSM/GPRS module

At the heart of the module is a SIM800L GSM cellular chip from SimCom. The operating voltage of the chip is from 3.4V to 4.4V, which makes it an ideal candidate for direct LiPo battery supply. This makes it a good choice for embedding into projects without a lot of space.

All the necessary data pins of SIM800L GSM chip are broken out to a 0.1″ pitch headers. This includes pins required for communication with a microcontroller over UART. The module supports baud rate from 1200bps to 115200bps with Auto-Baud detection.

The module needs an external antenna to connect to a network. The module usually comes with a Helical Antenna and solders directly to NET pin on PCB. The board also has a U.FL connector facility in case you want to keep the antenna away from the board.

There’s a SIM socket on the back! Any activated, 2G micro SIM card would work perfectly. Correct direction for inserting SIM card is normally engraved on the surface of the SIM socket.

This module measures only 1 inch² but packs a surprising amount of features into its little frame. Some of them are listed below:

  • Supports Quad-band: GSM850, EGSM900, DCS1800 and PCS1900
  • Connect onto any global GSM network with any 2G SIM
  • Make and receive voice calls using an external 8Ω speaker & electret microphone
  • Send and receive SMS messages
  • Send and receive GPRS data (TCP/IP, HTTP, etc.)
  • Scan and receive FM radio broadcasts
  • Transmit Power:
    • Class 4 (2W) for GSM850
    • Class 1 (1W) for DCS1800
  • Serial-based AT Command Set
  • FL connectors for cell antennae
  • Accepts Micro SIM Card

LED Status Indicators

There is an LED on the top right side of the SIM800L Cellular Module which indicates the status of your cellular network. It’ll blink at various rates to show what state it’s in:

Blink every 1s

The module is running but hasn’t made connection to the cellular network yet.

Blink every 2s

The GPRS data connection you requested is active.

Blink every 3s

The module has made contact with the cellular network & can send/receive voice and SMS.

Selecting Antenna

An antenna is required to use the module for any kind of voice or data communications as well as some SIM commands. So, selecting an antenna could be a crucial thing. There are two ways you can add an antenna to your SIM800L module.

The first one is a Helical GSM antenna which usually comes with the module and solders directly to NET pin on PCB. This antenna is very useful for projects that need to save space but struggles in getting connectivity especially if your project is indoors.

The second one is any 3dBi GSM antenna along with a U.FL to SMA adapter which can be obtained online for less than $3. You can snap-fit this antenna to small u.fl connector located on the top-left corner of the module. This type of antenna has a better performance and allows putting your module inside a metal case – as long the antenna is outside.

Supplying Power for SIM800L module

One of the most important parts of getting the SIM800L module working is supplying it with enough power.

Depending on which state it’s in, the SIM800L can be a relatively power-hungry device. The maximum current draw of the module is around 2A during transmission burst. It usually won’t pull that much, but may require around 216mA during phone calls or 80mA during network transmissions. This chart from the datasheet summarizes what you may expect:

ModesFrequencyCurrent Consumption
Power down60 uA
Sleep mode1 mA
Stand by18 mA
CallGSM850199 mA
EGSM900216 mA
DCS1800146 mA
PCS1900131 mA
GPRS453 mA
Transmission burst2 A

Since SIM800L module doesn’t come with onboard voltage regulator, an external power supply adjusted to voltage between 3.4V to 4.4V (Ideal 4.1V) is required. The power supply should also be able to source 2A of surge current, otherwise the module will keep shutting down. Here are some options you can consider to correctly power your GSM module.

3.7v Li-Po Battery (Recommended)

One of the cool things about Li-Po batteries is that their voltage is generally in the range of 3.7V – 4.2V, perfect for SIM800L Module. Any 1200mAh or larger sized Lithium ion/polymer battery is best since it can provide the correct voltage range even during 2 Amp spikes.

DC-DC Buck Converter

Any 2A-rated DC-DC buck converter like LM2596 would work. These are much more efficient than a liner voltage regulator like LM317 or LM338.

Warning:

You should be very careful to not to disconnect the GND before the VCC and always connect GND before VCC. Otherwise the module can use the low voltage serial pins as ground and can get destroyed instantly.

SIM800L GSM Module Pinout

The SIM800L module has total 12 pins that interface it to the outside world. The connections are as follows:

NET is a pin where you can solder Helical Antenna provided along with the module.

VCC supplies power for the module. This can be anywhere from 3.4V to 4.4 volts. Remember connecting it to 5V pin will likely destroy your module! It doesn’t even run on 3.3 V! An external power source like Li-Po battery or DC-DC buck converters rated 3.7V 2A would work.

RST (Reset) is a hard reset pin. If you absolutely got the module in a bad space, pull this pin low for 100ms to perform a hard reset.

RxD (Receiver) pin is used for serial communication.

TxD (Transmitter) pin is used for serial communication.

GND is the Ground Pin and needs to be connected to GND pin on the Arduino.

RING pin acts as a Ring Indicator. It is basically the ‘interrupt’ out pin from the module. It is by default high and will pulse low for 120ms when a call is received. It can also be configured to pulse when an SMS is received.

DTR pin activates/deactivates sleep mode. Pulling it HIGH will put module in sleep mode, disabling serial communication. Pulling it LOW will wake the module up.

MIC± is a differential microphone input. The two microphone pins can be connected directly to these pins.

SPK± is a differential speaker interface. The two pins of a speaker can be tied directly to these two pins.

Wiring – Connecting SIM800L GSM module to Arduino UNO

Now that we know everything about the module, we can begin hooking it up to our Arduino!

Start by soldering/connecting the antenna, insert fully activated Micro SIM card in the socket. Now, connect Tx pin on module to digital pin#3 on Arduino as we’ll be using software serial to talk to the module.

We cannot directly connect Rx pin on module to Arduino’s digital pin as Arduino Uno uses 5V GPIO whereas the SIM800L module uses 3.3V level logic and is NOT 5V tolerant. This means the Tx signal coming from the Arduino Uno must be stepped down to 3.3V so as not to damage the SIM800L module. There are several ways to do this but the easiest way is to use a simple resistor divider. A 10K resistor between SIM800L Rx and Arduino D2, and 20K between SIM800L Rx and GND would work fine.

Now we are remaining with the pins that are used to supply power for the module. As you have multiple choices for powering up the module, we have provided two example schematics. The one uses 1200mAh Li-Po battery and other one uses LM2596 DC-DC buck converter.

TIP

In case you are using LM2596 buck converter to power up the module, remember to common all the ground in the circuit.

Once you have everything hooked up you are ready to go!

Arduino Code – Testing AT Commands

For sending AT commands and communicating with the SIM800L module, we will use the serial monitor. The sketch below will enable the Arduino to communicate with the SIM800L module on serial monitor. Before we proceed with detailed breakdown of code, connect your Arduino to PC, compile below code and upload it to the Arduino.

Once you open a serial monitor, make sure that ‘Both NL & CR’ option is selected!

The sketch starts by including a SoftwareSerial.h library and initializing it with the Arduino pins to which Tx and Rx of SIM800L module is connected.

In setup function: we initialize a serial communication link between Arduino, Arduino IDE and SIM800L module at a baud rate of 9600.

Now that we have established a basic connection, we will try to communicate with the SIM800L module by sending AT commands.

Sim800l Delete All Sms

AT – It is the most basic AT command. It also initializes Auto-baud’er. If it works you should see the AT characters echo and then OK, telling you it’s OK and it’s understanding you correctly! You can then send some commands to query the module and get information about it such as

AT+CSQ – Check the ‘signal strength’ – the first # is dB strength, it should be higher than around 5. Higher is better. Of course it depends on your antenna and location!

AT+CCID – get the SIM card number – this tests that the SIM card is found OK and you can verify the number is written on the card.

AT+CREG? Check that you’re registered on the network. The second # should be 1 or 5. 1 indicates you are registered to home network and 5 indicates roaming network. Other than these two numbers indicate you are not registered to any network.

In the looping part of the code, we call custom function called updateSerial() which continuously waits for any inputs from the serial monitor and send it to the SIM800L module through the D2 pin (Rx of module). It also continuously reads the D3 pin (Tx of module) if the SIM800L module has any responses.

You should see below output on serial monitor.

You are now free to send any commands through serial monitor like below which gives more information about network connection & battery status:

ATI – Get the module name and revision

AT+COPS? – Check that you’re connected to the network, in this case BSNL

AT+COPS=? – Return the list of operators present in the network.

AT+CBC – will return the lipo battery state. The second number is the % full (in this case its 93%) and the third number is the actual voltage in mV (in this case, 3.877 V)

Arduino Code – Sending SMS

Let’s move on to the interesting stuff. Let’s program our Arduino to send an SMS to any phone number you wish. Before trying the sketch out, you need to enter the phone number. Search for the string ZZxxxxxxxxxx and replace ZZ with county code and xxxxxxxxxx with the 10 digit phone number.

The sketch is almost same as earlier except below code snippet. Once the connection is established, we send below AT commands:

AT+CMGF=1 – Selects SMS message format as text. Default format is Protocol Data Unit (PDU)

AT+CMGS=+ZZxxxxxxxxxx – Sends SMS to the phone number specified. The text message entered followed by a ‘Ctrl+z’ character is treated as SMS. ‘Ctrl+z’ is actually a 26th non-printing character described as ‘substitute’ in ASCII table. So, we need to send 26DEC (1AHEX) once we send a message.

The loop is kept empty as we want to send SMS only once. If you wish to send SMS one more time, just hit the RESET key on your Arduino. Below screenshot shows SMS sent from SIM800L GSM module.

Arduino Code – Reading SMS

Now let’s program our Arduino to read incoming messages. This sketch is very useful when you need to trigger an action when a specific SMS is received. For example, when the Arduino receives an SMS, you can instruct it to turn on or off a relay. You got the idea!

The sketch is similar as earlier except below code snippet. Once the connection is established, we send below AT commands:

AT+CMGF=1 – Selects SMS message format as text. Default format is Protocol Data Unit (PDU)

AT+CNMI=1,2,0,0,0 – specifies how newly arrived SMS messages should be handled. This way you can tell the SIM800L module either to forward newly arrived SMS messages directly to the PC, or to save them in message storage and then notify the PC about their locations in message storage.

Its response starts with +CMT: All the fields in the response are comma-separated with first field being phone number. The second field is the name of person sending SMS. Third field is a timestamp while forth field is the actual message.

Note that this time we have NOT kept the loop function empty as we are polling for newly arrived SMS messages. Once you send the SMS to SIM800L GSM module, you will see below output on serial monitor.

Sim800l

Expanding Arduino SoftwareSerial Buffer Size

If your message is long enough just like ours, then you’ll probably receive it with some missing characters. This is not because of a faulty code. Your SoftwareSerial receive buffer is getting filled up and discarding characters. You are not reading fast enough from the buffer.

The simplest solution to this is to increase the size of the SoftwareSerial buffer from its default size of 64 bytes to 256 bytes (or smaller, depending on what works for you).

On a Windows PC, go to C:Program Files (x86) -> Arduino -> hardware -> Arduino -> avr -> libraries -> SoftwareSerial (-> src for newer version of Arduino IDE) Open SoftwareSerial.h and change the line:

to

Save the file and try your sketch again.

Arduino Code – Making Call

Now let’s program our Arduino to make call. This sketch is very useful when you want your Arduino to make an SOS/distress call in case of emergency like temperature being exceeded or someone breaks into your house. You got the idea!

Before trying the sketch out, you need to enter the phone number. Search for the string ZZxxxxxxxxxx and replace ZZ with county code and xxxxxxxxxx with the 10 digit phone number.

To place a call following AT commands are used:

Sim800l Delete All Sms Free

ATD+ +ZZxxxxxxxxxx; – Dials a specified number. The semicolon (;) modifier at the end separates the dial string into multiple dial commands. All but the last command must end with the semicolon (;) modifier.

ATH – Hangs up the call

Below screenshot shows call made from SIM800L GSM module.

Arduino Code – Receiving Call

Sim800l Delete All Sms Messages

Receiving call doesn’t require any special code; you just have to keep listening to the SIM800L module. Yet, you may find this sketch very useful, when you need to trigger an action when a call from specific phone number is received.

Incoming call is usually indicated by ‘RING’ on serial monitor followed by phone number and caller ID. To accept/hang a call following AT commands are used:

Sim800l Delete All Sms Messages

ATA – Accepts incoming call.

ATH – Hangs up the call. On hanging up the call it sends NO CARRIER on the serial monitor indicating call couldn’t connect.

Sim800l Delete All Sms In Hindi

Below output on serial monitor shows call received by SIM800L GSM module.