My Cart

New Videotutorial: 3G/GPRS Shield for Arduino (3G+GPS)August 28, 2012

This new video-tutorial will show how to use our 3G/GPRS Shield for Arduino (3G+GPS) with basic examples of communication. Now you can learn how to set the Audio/Video Kit, send a SMS or an email with a photo and the GPS location, or use it like a 3G modem with your laptop.

The new 3G shield for Arduino enables the connectivity to high speed WCDMA and HSPA cellular networks in order to make possible the creation of the next level of worldwide interactivity projects inside the new "Internet of Things" era. It supports: photo and video recording, HTTP, FTP, POP3, SMTP, TCP/IP, UDP/IP connections among other features such as assisted-mobile (A-GPS) and mobile-based (S-GPS) modes.

Check the SMS Example Code here:

/*
*  Copyright (C) 2012 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 .
*
*  Version 0.1
*  Author: Alejandro Gállego
*/


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;

char phone_number[]="*********";     // ********* is the number to call

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

void setup(){

    Serial.begin(115200);                // UART baud rate
    delay(2000);
    pinMode(led, OUTPUT);
    pinMode(onModulePin, OUTPUT);
    switchModule();                    // switches the module ON

    for (int i=0;i<5;i++){
        delay(5000);
    } 

    Serial.println("AT+CMGF=1");         // sets the SMS mode to text
    delay(100);
}

void loop(){

    while (count < timesToSend){
        delay(1500);
        Serial.print("AT+CMGS=\"");		// send the SMS number
        Serial.print(phone_number);
	Serial.println("\""); 
        delay(1500);      
        Serial.print("Hello world!!");     // the SMS body
        delay(500);
        Serial.write(0x1A);       //sends ++
        Serial.write(0x0D);
        Serial.write(0x0A);

        delay(5000);

        count++;
    }

}

Check the GPS+PIC Code here:

int led = 13;
int onModulePin = 2;        // the pin to switch on the module (without press on button) 
int x=0,y=0,z=0;
char response[255];
long previous;
char picture_name[25];

//GPS 
char data[255];
char latitude[12],longitude[13];
char date[7],UTC_time[9];
char speed_OG[7],altitude[7];

//server and account data
char server[ ]="";              // SMTP server
char user_name[ ]="";      // SMTP user name
char password[ ]="";                 // SMTP password
char port[ ]="";                              // SMTP server port

//information about sender, direcctions and names
char sender_add[ ]="";     // Sender address
char sender_name[ ]="3G shield";                 // Sender name

char to_add[ ]="";         // Recipient address
char to_name[ ]="Cooking Hacks";                 // Recipient name

char subject[ ]="GPS+PICTURE";


void setup(){

    Serial.begin(115200);                // UART baud rate
    delay(2000);
    pinMode(led, OUTPUT);
    pinMode(onModulePin, OUTPUT);
    Serial.println("start setup");
    
    switchModule();    // Switches the module ON

    get_GPS();        // Waits for GPS data

    take_picture();    // Takes a picture

    send_email();    // Sends an email with coordinates and picture
}


void loop(){

}


void switchModule(){
    digitalWrite(onModulePin,HIGH);
    delay(2000);
    digitalWrite(onModulePin,LOW);
    for (int i=0;i < 10; i++){
        delay(5000);
    }
}


void get_GPS(){

    do{        //Cleans the input buffer
        Serial.read();
    }while (Serial.available()!=0);

    Serial.println("AT+CGPS=1,1");         // Starts GPS session in stand-alone mode
    x=0;
    do{
        while(Serial.available()==0);
        response[x]=Serial.read();  
        x++;                        
    }while (!(((response[x-1] == 'K') && (response[x-2] == 'O'))));


    do{    //Cleans the input buffer
        Serial.read();
    }while (Serial.available()!=0);


    do{
        delay(1000);
        Serial.println("AT+CGPSINFO"); // Request GPS info
        Serial.flush();

        x=0;
        do{
            while(Serial.available()==0);
            data[x]=Serial.read();  
            x++;                        
        }while ((!(((data[x-1] == 'K') && (data[x-2] == 'O')))) && (x < 255));

        data[x]='\0';

        x=0;

        while (data[x]!=':'){
            x++;
        }
        x++;
    }while (data[x]==',');

    //  Serial.print(data);

    Serial.print("Latitude: ");    // Shows actual latitude
    do{
        latitude[y]=data[x];
        Serial.print(data[x]);
        y++;
        x++;        
    }while(data[x]!=',');
    
    latitude[y]='\0';
    x++;
    Serial.print(" ");
    Serial.println(data[x]);    // North or south

    x+=2;
    y=0;
    Serial.print("Longitude: ");    // Shows actual longitude
    do{
        longitude[y]=data[x];
        Serial.print(data[x]);
        y++;
        x++; 
    }while(data[x]!=',');
    
    longitude[y]='\0';
    x++;
    Serial.print(" ");
    Serial.println(data[x]);    // West or east

    x+=2;
    y=0;
    Serial.print("Date: ");    // Shows date
    do{
        date[y]=data[x];
        Serial.print(data[x]);
        y++;
        x++;        
    }while(data[x]!=',');
    
    x++;

    y=0;
    Serial.print("\r\nUTC time: ");    // Shows UTC time
    do{
        UTC_time[y]=data[x];
        Serial.print(data[x]);
        y++;
        x++;        
    }while(data[x]!=',');
    
    x++;

    y=0;
    Serial.print("\r\nAltitude: ");    // Shows altitude
    do{
        UTC_time[y]=data[x];
        Serial.print(data[x]);
        y++;
        x++;        
    }while(data[x]!=',');
    Serial.println(" m");
    
    x++; 

    y=0;
    Serial.print("Speed: ");        // Shows speed over the ground
    do{
        speed_OG[y]=data[x];
        Serial.print(data[x]);
        y++;
        x++;        
    }while(data[x]!=0x0D);
    Serial.println(" knots");


}

void take_picture(){
    Serial.println("Taking picture...");
    Serial.println("AT+CCAMS");                     // Starts the camera
    while(Serial.read()!='K');
    Serial.println("AT+CCAMSETD=640,480");         // Sets resolution
    while(Serial.read()!='K');

    Serial.println("AT+FSLOCA=0");
    while(Serial.read()!='K');

    Serial.println("AT+CCAMTP");                   // Takes picture
    while(Serial.read()!='K');
    Serial.println("AT+CCAMEP");                   // Stores the picure 
    Serial.flush();
    while(Serial.read()!='/');                     
    while(Serial.read()!='/');

    //Gets the picture name
    int z=0;
    do{
        while(Serial.available()==0);               // Waits for input data
        picture_name[z]=Serial.read();                      
        z++;
    }while(z < 21);

    while(Serial.read()!='K');
    delay(500);
    Serial.print("Picture name: ");
    Serial.println(picture_name);
    Serial.println("AT+CCAME");     // Stops the camera
    while(Serial.read()!='K');
    
}


void send_email(){

    Serial.print("AT+SMTPSRV=\"");    // Configures the SIM5218E with server name and port
    Serial.print(server);
    Serial.print("\",");
    Serial.println(port);
    Serial.flush();
    x=0;
    do{
        while(Serial.available()==0);
        response[x]=Serial.read();  
        x++;                        
    }while (!(((response[x-1] == 'K') && (response[x-2] == 'O'))));

    Serial.print("AT+SMTPAUTH=1,\"");    // Configures the SIM5218E with user name and password
    Serial.print(user_name);
    Serial.print("\",\"");
    Serial.print(password);
    Serial.println("\"");
    Serial.flush();
    x=0;
    do{
        while(Serial.available()==0);
        response[x]=Serial.read();  
        x++;                        
    }while (!(((response[x-1] == 'K') && (response[x-2] == 'O'))));


    Serial.print("AT+SMTPFROM=\"");    //sender adress and name
    Serial.print(sender_add);
    Serial.print("\",\"");
    Serial.print(sender_name);
    Serial.println("\"");
    Serial.flush();
    x=0;
    do{
        while(Serial.available()==0);
        response[x]=Serial.read();  
        x++;                        
    }while (!(((response[x-1] == 'K') && (response[x-2] == 'O'))));


    Serial.print("AT+SMTPRCPT=0,0,\"");    // Normal recipient address and name
    Serial.print(to_add);
    Serial.print("\",\"");
    Serial.print(to_name);
    Serial.println("\"");
    Serial.flush();
    x=0;
    do{
        while(Serial.available()==0);
        response[x]=Serial.read();  
        x++;                        
    }while (!(((response[x-1] == 'K') && (response[x-2] == 'O'))));

    Serial.print("AT+SMTPSUB=\"");    // Subjec of email
    Serial.print(subject);
    Serial.println("\"");
    Serial.flush();
    x=0;
    do{
        while(Serial.available()==0);
        response[x]=Serial.read();  
        x++;                        
    }while (!(((response[x-1] == 'K') && (response[x-2] == 'O'))));


    Serial.print("AT+SMTPBODY=\"Latitude: ");    // Body of email
    Serial.print(latitude);
    Serial.print("    Longitude: ");    
    Serial.print(longitude);
    Serial.println("\"");
    Serial.flush();
    x=0;
    do{
        while(Serial.available()==0);
        response[x]=Serial.read();
        x++;                        
    }while (!(((response[x-1] == 'K') && (response[x-2] == 'O'))));


    Serial.println("AT+FSCD=Picture");    
    Serial.flush();
    x=0;
    do{
        while(Serial.available()==0);
        response[x]=Serial.read();  
        x++;                        
    }while (!(((response[x-1] == 'K') && (response[x-2] == 'O'))));

    Serial.print("AT+SMTPFILE=1,\"");    // Attachs the picture
    Serial.print(picture_name);
    Serial.println("\"");
    Serial.flush();
    x=0;
    do{
        while(Serial.available()==0);
        response[x]=Serial.read();  
        x++;                        
    }while (!(((response[x-1] == 'K') && (response[x-2] == 'O'))));


    Serial.println("AT+CGSOCKCONT=1,\"IP\",\"internet\"");    
    Serial.flush();
    x=0;
    do{
        while(Serial.available()==0);
        response[x]=Serial.read();  
        x++;                        
    }while (!(((response[x-1] == 'K') && (response[x-2] == 'O'))));


    Serial.println("AT+SMTPSEND");    // Sends the email
    Serial.flush();
    x=0;
    do{
        while(Serial.available()==0);
        response[x]=Serial.read();  
        x++;                        
    }while (!(((response[x-1] == 'K') && (response[x-2] == 'O'))));

    Serial.print("Sending email...");

    x=0;
    do{
        while(Serial.available()==0); 
        response[x]=Serial.read();
        x++;
    }while (!((response[x-1] == 'S') && (response[x-2] == 'S')));    //Waitw for SUCCESS

    Serial.println("Email sended");

}

If you are looking for the entire features of this shield, you can take a look on its wide guide.

Now, the 3G/GPRS Shield (3G+GPS) Audio/Video kit includes a new VGA sensor camera with a best connection to take your photos and follow the example showed in the video.

Check out our Tutorials and Videos

Leave a Reply