(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
[[category:Arduino Tutorials]]
 
[[category:Arduino Tutorials]]
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.  
+
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.
 
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.
Line 30: Line 30:
 
|-
 
|-
 
|'''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+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'''|| ||  
+
|-
 
+
|'''AT+CIFSR'''||100.73.110.9 || Gets the IP address assigned to the module after successful connection with the above commands
 +
|-
 +
|'''AT+CIPSTART="TCP","exploreembedded.com",80'''||OK <br> CONNECT OK||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.
 +
|-
 +
|'''GET exploreembedded.com/wiki/images/1/15/Hello.txt HTTP/1.0'''||SEND OK<br>HTTP/1.0 200 OK<br>Date: Sat, 09 Jul 2016 06:49:32 GMT<br>Server: Apache/2.4.12<br>Last-Modified: Mon, 04 Jul 2016 08:06:49 GMT<br>ETag: "4721a10-1c-536cad1811830"<br>Accept-Ranges: bytes<br>Content-Length: 28<br>Vary: User-Agent<br>Content-Type: text/plain<br>Connection: Keep-Alive<br>Proxy-Connection:Keep-Alive<br>Proxy-Connection:Keep-A<br>liveProxy-Connection:Keep-Alive<br><br>Welcome to Explore Embedded!<br><br>CLOSED<br>||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!
 +
<html>
 +
<script src="https://gist.github.com/Xplorer001/540d44e7da0e060d63b2e590e03fdae2.js"></script>
 +
</html>
 
=Sample Code=
 
=Sample Code=
 +
Now let us do the same stuff with Arduino Code, will be using the [https://github.com/Seeed-Studio/Seeeduino_GPRS Seeed GPRS library ] to do so. The code is also available in the library example.
 +
<html>
 +
<script src="https://gist.github.com/Xplorer001/974528bcb08fc4c135d66e8731f06bef.js"></script>
 +
</html>
 +
 
=Demo=
 
=Demo=
 +
[[File:Gprs sim800l.PNG|center]]
 +
<br>
 +
<br>
 +
''Making MQTT work with this will enable greater possibilities, what do you think?
 +
''
 +
{{DISQUS}}

Latest revision as of 14:24, 9 July 2016

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="airtelgprs.com","","" 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 100.73.110.9 Gets the IP address assigned to the module after successful connection with the above commands
AT+CIPSTART="TCP","exploreembedded.com",80 OK
CONNECT OK
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.
GET exploreembedded.com/wiki/images/1/15/Hello.txt HTTP/1.0 SEND OK
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
Proxy-Connection:Keep-Alive
Proxy-Connection:Keep-A
liveProxy-Connection:Keep-Alive

Welcome to Explore Embedded!

CLOSED
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.

Demo

Gprs sim800l.PNG



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