Advanced GPRS Shield goes online!

Good news!

After weeks of development and testing i am happy to announce the updated Advanced GPRS library that does exactly what this shield was designed for, GPRS internet access!

So now you can go online, communicate with remote servers and exchange data in realtime.
The powerfull SIM900D TCP/IP engine and extended AT commands helped us to do the job.
Download now the new version of the library from our github and let the fun begin!

The possibilities are now endless for our Advanced GPRS Shield, your imagination is the only limit.
Do you want to create an Arduino twitter client? Or maybe a Pachube datastream?
Or why not , that super-duper autonomous high altitude balloon..

OK, you got it..  now you need something to start. Well everyone need a little push on the beginning.

I have included a basic GPRS sketch example that initialize GPRS settings, attach to the GPRS network of your cellular provider, then tries to initiate a TCP connection to a web server on default port 80, (google website for example). On successfully connection, it performs a HTTP GET request and the server responce with HTML data.

After that the sketch close the connection, send some normal AT commands, for example you can check for new SMS messages, then try to connect again to the webserver.

You can for example put a delay on the end of each loop() and perform this check or data sending every some minutes continuously.

Think about it! You can power your Arduino from a li-ion battery, leave the charging to your Advanced GPRS shield, read your favorite sensors and report data back to your remote server over Internet!  That’s so cool!

Unleash the power of your new Advanced GPRS Shield!

Basic GPRS Sketch Source Code
#include "GSM.h"
GSM gsm;

// return variable
signed char ret_val;
uint16_t num_of_rx_bytes;
byte* ptr_to_data;
byte buffer[400];

void setup()
  // initialize the digital pin as an output.
  // Pin 13 has an LED connected on most Arduino boards.
  pinMode(13, OUTPUT);

  // initialization of serial line
  // turn on GSM module

  // wait until a GSM module is registered in the GSM network
  while (!gsm.IsRegistered()) {

  // use GPRS APN "internet" - it is necessary to find out right one for
  // your GSM provider
  ret_val = gsm.InitGPRS("internet", "", "");

  // activate GPRS context - IP address will be assigned
  ret_val = gsm.EnableGPRS(CLOSE_AND_REOPEN);

void loop()
  // try to read data with "GET request" - 3 times
  // between each attempt we will try to use standard AT command
  // to demonstrate a possibility to use AT command interface(call, SMS etc.) and GPRS connection "together"
  // -------------------------------------------------------------------------------------------------------
  for (byte i = 0; i < 3; i++) {
    // open the TCP socket
    ret_val = gsm.OpenSocket(TCP_SOCKET, 80, "");
    if (ret_val == 1) {
      // socket was successfully opened
      // so we can exchange data
      // here we are trying GET request
      // GET request must be finished by sequence  == \r\n\r\n
      gsm.SendData("GET / HTTP/1.1\r\nHost:\r\n\r\n");

      // and wait for first incomming data max. 20sec.
      // receiving will be finished either buffer is full
      // or there is no other incomming byte 1000msec. from last receiving byte
      // !!! Please note that in case buffer is full we have to read again and again
      // not to loose any other incoming data !!!
      do {
        // 20000 means: we will wait max. 20 sec. for first incomming character
        // 1000 means: receiving is finished if there is no other incomming character longer then 1sec.
        num_of_rx_bytes = gsm.RcvData(20000, 1000, &ptr_to_data);
        if (num_of_rx_bytes) {
          // we have received some data
          // we can analyze the data here etc.

          // just now we only copy incomming data to the temporary buffer
          memcpy(buffer, ptr_to_data, num_of_rx_bytes);
        else {
          // no data were received
      } while (num_of_rx_bytes == COMM_BUF_LEN);

      // now close the socket

      // and now we can try standard AT command - e.g. try to check registration
      // or we can check new SMS etc.
      if (REG_REGISTERED == gsm.CheckRegistration()) {
        // we are registered => everything is OK
      else {
        // we are not registered => make something

  // When finished deactivate GPRS context

  // we are finished so stay here forever
  while (1){
    digitalWrite(13, HIGH);   // set the LED on
    delay(400);              // wait for a second
    digitalWrite(13, LOW);    // set the LED off
    delay(400);              // wait for a second


4 Responses to “Advanced GPRS Shield goes online!”

  1. NicolaNovember 26, 2011 at 11:41 pm #

    I temporarily sorted this out by creating the function definitions in the .h files.

    Great module anyway! 20 minutes from unboxing to posting temperature sensor data to my web server :)

  2. NicolaNovember 26, 2011 at 11:43 pm #

    seems my previous message was lost, anyhow I just mentioned that I get a compiler error with your libraries, all the definition of the functions are missing from GSM_GPRS.h

    • KostasNovember 27, 2011 at 1:17 pm #

      Thank you Nicola for mention this, bad syncing with the github. It is fixed now!

      I have also added functions for battery monitoring and charging!

  3. NicolaNovember 27, 2011 at 8:12 pm #

    Thanks, I can confirm the new sources as working perfectly.

    FYI, I had to increase the timeout on the CIICR, sometimes during the day it took in my network 15 seconds to get the GPRS attacched, and the time-out was set to 10s.

    ret_val = SendATCmdWaitResp(“AT+CIICR”, 60000, 1000, “OK”, 1);

    I think others might experience the same problem.

Leave a Reply