SIM800L supports General Packet Radio Service (GPRS) for connecting to the internet with HTTP. The module has built in TCP/IP stack that can be accessed with AT commands. This can be very handy for persistent data logging on low bandwidth networks. We will first use the AT commands to make a HTTP GET request to fetch a simple page and then use the library.

Going further I would also like to explore possibility of running MQTT, which is more suitable for low data rate and seamless logging. So lets get started.

Hook Up

The hook up will remain same as in previous tutorial.

0 Sim800l bb.png

We will also use the same basic code to send and receive commands to the module from the computer. These go through Arduino, so that we are assured that everything is setup properly.

Test AT commands

There are numerous AT commands that the module supports. These aren't well documented in the datasheet. I will list the bare minimum commands to setup and verify data connectivity of the SIM800L. Most of the libraries use these commands to set up the HTTP connection.

Here are a few things that you need to do before going further.

  • Ensure that the SIM800L module and the Arduino Uno are setup exactly as shown above and the basic AT commands work.
  • If it is a brand new SIM card, put it inside a phone first and check the data connectivity by opening up a simple webpage. It is easier to verify on the phone and enable data service if need be. This will eliminate one possibility some thing going wrong.
Command Response Description
AT OK ping the module to see if its up!
AT+CFUN=1 OK This enables full functionality of the modem. You can confirm the state of the modem by typing AT+CFUN? In fact you can do this to every command where you set parameters. Adding a question mark immediately after the command, returns the current value of that command.
AT+CPIN? +CPIN:READY Check if the SIM card is ready to make calls, messages or to start the data packet transmission.
AT+CSTT="","","" OK Access Point Name, User name and Password needs to be set before data connectivity can be established. Please use APN name of your SIM card provider. Note that for most service providers PIN and Password are not set. If your provider or you have set it up please this as well.
AT+CIICR OK Start wireless connection with the GPRS. This sets up the wireless GPRS connection wiht the service provider and obtain a ip address
AT+CIFSR Gets the IP address assigned to the module after successful connection with the above commands
Starts an TCP connection to the website on port 80. The first OK is response to command acceptance and the second for the successful connection.
AT+CIPSEND=63 > This command indicates that we will be making a HTTP request whose length is 63 characters. It will respond with a right array, after which we will send the GET request.
HTTP/1.0 200 OK
Date: Sat, 09 Jul 2016 06:49:32 GMT
Server: Apache/2.4.12
Last-Modified: Mon, 04 Jul 2016 08:06:49 GMT
ETag: "4721a10-1c-536cad1811830"
Accept-Ranges: bytes
Content-Length: 28
Vary: User-Agent
Content-Type: text/plain
Connection: Keep-Alive

Welcome to Explore Embedded!

Make a HTTP GET request.

AT Command Log

I used Bray Terminal to log the commands and their responses in the sequence above to fetch a hello.txt file from our wiki and this is how it looked!

Sample Code

Now let us do the same stuff with Arduino Code, will be using the Seeed GPRS library to do so. The code is also available in the library example.


Gprs sim800l.PNG

Making MQTT work with this will enable greater possibilities, what do you think?