New GPRS module for Arduino (Hilo - Sagem)

From SquidBee

Jump to: navigation, search

Contents

Basic tutorial GPRS Module for Arduino

The shield (hardware)

The board (shield) we are going to use in this tutorial is the GPRS module for Arduino from Libelium

The board:

GPRS module for Arduino
GPRS module for Arduino
u.fl antenna connection

Description of the components
Old verssion

GPRS module for Arduino

Current verssion

GPRS module for Arduino

The GPRS shield is fully compatible with Arduino Diecimila, Duemilanove and Mega

Important issues

  • Use capital letters for AT commands and CR (Carriage return) at the end
  • Place the serial communication jumpers in the right possition
  • Use an external power supply and place the power jumpers in the right possition. If the shield is powered from the Arduino, the power jumper must be in Arduino 5V possition. It the shield is powered from the Vin input (in the shield), the power jumper must be in Vext possition

Using Hilo module (Basic AT commands)

The first thing we are going to do with the module is to connect the module to a PC directly (using an arduino as gateway) and check the basic AT commands. In this case, serial communication jumpers have to be set on USB gateway possition.

Remember take out the ATmega microcontroller from the Arduino gateway

Basic configuration

Connect the shield to the arduino gateway:



Then connect the USB cable and the SIM card



Finally plug the USB cable to the computer and open a serial port terminal to communicate via the usb port (e.g: hyperterminal (win), cutecom / gtkterm (linux)).

Do not use Arduino IDE serial monitor for sending AT commands - It does not send CR (Carriage return)

Set the baudrate to 19200 bps and open the serial port, then press the ON button for two seconds and you'll get a PSSTK message (as a "welcome"). Then if you type AT you'll get OK, this means that the communication with the module is working fine.

Now, with the module working you can check some AT commands to control the module, the basic commands are:
Important type commands in capital letters and with CR (carriage return) and LF (line feed)!!! (see the above screen capture of cutecom and the CR,LF setting)

*AT (you get OK) => it works
*AT+CPIN="****" (you get OK) => if the SIM card is locked with PIN (**** is the pin number)
AT+COPS? (you get the mobile network name)
AT+CPBR=* (you get the number and name of the * possition in the phonebook
AT*PSCPOF (switch the module off)

Note

If your Hilo module doesn't answer to AT commands, maybe it is configured in a different baudrate. The command for change it is AT+IPR. Try differents baudrates (9600, 19200, 34800, 57600, 115200) until you get to communicate. Once you can communicate, you can configure it in the baudrate you want. We suggest 19200 or autobaudrate (0).

AT+IPR=19200
AT+IPR=0

All the AT commands here

Making a call

Once the module is working, to make a call is very easy. The command to send is

ATD*********; => ********* is the number to call
ATH => disconnect the call

You can even add a speaker and a mic to the board.

Sending SMS

The next step is sending SMS's from the board

AT+CSCA? => you get the SMS service center address
AT+CMGF=1 => select the SMS format (1=text mode)

Sending the SMS

AT+CMGS="*********" => ********* is the number to send the SMS
Text of the message .................
1A(hex) => end of message

Using the shield in standalone mode - Send SMS

We advise to use Arduino-0016 IDE for compiling the code on the Arduino for standalone using since we've detected problems with the lastest verssion (Arduino-0017)

Download IDE here http://arduino.cc/en/Main/Software

Connecting the module to an Arduino Diecimila and using the code below, Arduino sends an SMS. Remember, now the serial communication jumpers have to be set on Arduino possition.


Arduino code:

/*
 *  Sending SMS using GPRS module from Libelium for Arduino
 *  Basic program, just sends an SMS
 *  Copyright (C) 2008 Libelium Comunicaciones Distribuidas S.L.
 *  http://www.libelium.com
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 * 
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 * 
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 *  Version 0.1
 *  Author: Marcos Yarza <m.yarza [at] libelium [dot] com>
 */

int led = 13;
int onModulePin = 2;        // the pin to switch on the module (without press on button) 

int timesToSend = 1;        // Numbers of SMS to send
int count = 0;

void switchModule(){
  digitalWrite(onModulePin,HIGH);
  delay(2000);
  digitalWrite(onModulePin,LOW);
}

void setup(){

  pinMode(led, OUTPUT);
  pinMode(onModulePin, OUTPUT);

  Serial.begin(19200);               // the GPRS baud rate
    
  switchModule();                    // swith the module ON
  
  for (int i=0;i<2;i++){
    delay(5000);                        
  } 
  
   Serial.println("AT+CMGF=1");         // set the SMS mode to text 
}

void loop(){
  
  while (count < timesToSend){
    delay(1500);
    Serial.print("AT+CMGS=");               // send the SMS the number
    Serial.print(34,BYTE);                  // send the " char 
    Serial.print("*********");              // send the number change ********* by the actual number
    Serial.println(34,BYTE);                // send the " char
    delay(1500); 
    Serial.print("Hola caracola...");     // the SMS body
    delay(500);
    Serial.print(0x1A,BYTE);                // end of message command 1A (hex)
       
    delay(5000);        

    count++;    
  }

  if (count == timesToSend){
    Serial.println("AT*PSCPOF");             // switch the module off
    count++;
  }
}

Using the shield in standalone mode - Making lost calls

Making calls is also very easy, here is a code example


Arduino code:

/*
*  Making a call using GPRS module from Libelium for Arduino
*
*  Basic program, just makes a call
*
*
*  25/08/08 Zaragoza (Spain)
*
*  Copyright (C) 2008 M. Yarza 2.008 - 07 - 22 - Zaragoza
*  www.squidbee.org
*  www.sensor-networks.org
*  www.libelium.com
*
*  This program is free software: you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Software Foundation, either version 3 of the License, or
*  (at your option) any later version.
* 
*  This program is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details.
* 
*  You should have received a copy of the GNU General Public License
*  along with this program.  If not, see <http://www.gnu.org/licenses/>.
*
*/

int led = 13;
int onModulePin = 2;        // the pin to switch on the module (without press on button) 

int timesToSend = 1;        // Numbers of calls to make
int count = 0;

void testModule(){
  Serial.flush();
}

void switchModule(){
  digitalWrite(onModulePin,HIGH);
  delay(2000);
  digitalWrite(onModulePin,LOW);
}

void setup(){

  pinMode(led, OUTPUT);
  pinMode(onModulePin, OUTPUT);

  Serial.begin(19200);              // the GPRS baud rate
    
  switchModule();                    // swith the module ON
 
  for (int i=0;i<2;i++){
    delay(5000);                        
  } 
  
   Serial.println("AT+CMGF=1");      // set the SMS mode to text 
}

void loop(){
  
  while (count < timesToSend){
    delay(1500);
    Serial.println("ATD*********;");      // ********* is the number to call 
    delay(12000); 
    Serial.println("ATH");              // disconnect the call
       
    delay(5000);        

    count++;    
  }

  if (count == timesToSend){
    Serial.println("AT*PSCPOF");        // switch the module off
    count++;
  }
}

Important! Powering the board

Some of the USB ports on computers are not able to give all the current the module needs to work, if your module goes down when it tries to connect to the network, you can use an external power supply (12V - 2A) on the arduino.


Remember set the arduino power jumper to EXT!!!


How to set the power jumper in the shield?

300px

300px

If you want the shield takes power from Arduino => Set the jumper to Arduino 5V possition
If you want the shield takes power from an external supply => Set the jumper to V ext. possition
For powering the shield from external supply, you have to use V in ext. connector (Vin + GND).


If you use a power supply with output smaller than 2 A, you should add an extra capacitor for the power.

For example, a 220 uF electrolytic capacitor between 5V and GND.



Connecting Arduino to Internet

It's important to have the lastest firmware version in the GPRS module. Obligatory for sending data via GPRS

We are going to use the TCP connection guide in the Hilo Manual (Page 317)

TCP guide in Hilo Manual

We use Arduino duemilanove in standalone mode, with microcontroller and powerd using a standard power supply (12V - 2A).

Arduino with Hilo shield

As you can see in the picture, we use a second arduino without microcontroller, this Arduino is just used for monitoring the serial output of the Hilo module. Only two wires are nedeed (one for GND and one from TX signal - from one of the jumpers to pin 1) See image below.

Arduino with Hilo shield

Here is the serial output from the Hilo GPRS module

Serial terminal

And here is the code for the Arduino

Arduino code

/* 
 *  ------Arduino connection to the internet using GPRS shield from Libelium------ 
 * 
 * 
 * 
 *  Copyright (C) 2009 Libelium Comunicaciones Distribuidas S.L. 
 *  http://www.libelium.com 
 * 
 *  This program is free software: you can redistribute it and/or modify 
 *  it under the terms of the GNU General Public License as published by 
 *  the Free Software Foundation, either version 2 of the License, or 
 *  (at your option) any later version. 
 * 
 *  This program is distributed in the hope that it will be useful, 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 *  GNU General Public License for more details. 
 * 
 *  You should have received a copy of the GNU General Public License 
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>. 
 * 
 *  Version:           0.1 
 *  Design:            Marcos Yarza
 *  Implementation:    Marcos Yarza
 */ 

  
int onModulePin = 2;                  // the pin to switch on the module (without press on button) 


void switchModule(){                  // Funtion to switch the module ON
  digitalWrite(onModulePin,HIGH);
  delay(2000);
  digitalWrite(onModulePin,LOW);
}


void setup(){

  pinMode(onModulePin, OUTPUT);
  Serial.begin(19200);              // the GPRS baud rate
  switchModule();                    // swith the module ON
 
  for (int i=0;i<2;i++){             // Wait 20 sec for connection
    delay(10000);                        
  } 
  
   Serial.println("AT&k3");
   delay(1000);
   Serial.print("AT+KCNXCFG=0,");
   Serial.print(34,BYTE);
   Serial.print("GPRS");
   Serial.print(34,BYTE);
   Serial.print(",");
   Serial.print(34,BYTE);
   Serial.print("internetmas");
   Serial.print(34,BYTE);
   Serial.print(",");
   Serial.print(34,BYTE);
   Serial.print(34,BYTE);
   Serial.print(",");
   Serial.print(34,BYTE);
   Serial.print(34,BYTE);
   Serial.println();
   delay(1000);
   Serial.println("AT+KCNXTIMER=0,60,2,70");
   delay(1000);
   Serial.println("AT+KCNXPROFILE=0");
   delay(1000);
   Serial.println("AT+CGATT=1");
   delay(1000);
   Serial.print("AT+KTCPCFG=0,0,");
   Serial.print(34,BYTE);
   Serial.print("www.google.com");
   Serial.print(34,BYTE);
   Serial.println(",80");
   delay(1000);
   Serial.println("AT+KTCPCNX=1");
   delay(7000);
   Serial.println("AT+KTCPSND=1,18");
   delay(2000);
   Serial.println("GET / HTTP/1.0");
   Serial.print(10,BYTE);
   Serial.print(13,BYTE);
   Serial.print("--EOF--Pattern--");
   delay(2000);
   Serial.println("AT+KTCPRCV=1,807");
   delay(1000);
   Serial.println("AT+KTCPCLOSE=1,1");
   delay(1000);
   
}

void loop(){
  
 
}

Setting the gprs gateway in windows using hyperterminal







References and downloads

Upgrading the Hilo firmware

Upgrading Hilo firmware tutorial

Personal tools