GPRS SHIELD v1.0 Test

Hello, I bought seeedstudio.com/wiki/GPRS_Shield_V1.0 with arduino uno and I tried to use the source code of that link (send2pachube) and give me a +CME ERROR: 3, so i decide to try another source code

/*
  This code is refer to the example of PachubeClientString of Arduino 
  libraries and example of GPRS Shield, it is only a test code for the place 
  with stable GPRS signal.
  
  Different countries may use different APN name, this example is work in China,
  we use APN name of CMNET, please do not use it in your country.
  
  Circuit:
  * Battery positive port attached to analog in 0
  * Temperature&Humidity sensor attached to analog in 5
  * GPRS Shield attached to digital 7,8 
  
  Cosm API for TCP : https://cosm.com/docs/beta/socket_server/
*/

#include <SoftwareSerial.h>
#include "DHT.h"

#define APIKEY         "1HxJIs8IcwN45Lj3RbViMbXUw-ySAKxNNm91amRLNU9BZz0g" // replace your pachube api key here
#define FEEDID         91687   // replace your feed ID
#define DHTPIN A5            // Temperature&Humidity sensor port 

// Uncomment whatever type you're using!
//#define DHTTYPE DHT11   // DHT 11 
#define DHTTYPE DHT22   // DHT 22  (AM2302)
//#define DHTTYPE DHT21   // DHT 21 (AM2301)
int buttonState = 0;         // current state of the button
const int  buttonPin = 2;

SoftwareSerial GPRS(7,8);
DHT dht(DHTPIN, DHTTYPE);

float humidity,temperature;
long previousMillis = 0;        // will store last time data was updated
long interval = 300000;          // interval at which to upload data (milliseconds)

void setup()
{
    pinMode(buttonPin, INPUT);
  // initialize the LED as an output:
//  pinMode(ledPin, OUTPUT);
//  pinMode(ledpinsim,OUTPUT);
  GPRS.begin(19200);
  Serial.begin(19200);
  dht.begin();
  TcpSettings();        // Setting network connection
}

void loop()
{
 buttonState = digitalRead(buttonPin);
  if (buttonState == HIGH)
   {
    DataSend2Cosm();
    delay(100);
   }
}

void TcpSettings()
{
  GPRS.println("AT+CSQ"); // Attach from GPRS serivce
  Response();
  GPRS.println("AT+CGATT=1"); // Attach from GPRS serivce
  delay(3000);
  Response();
  GPRS.println("AT+CSTT=\"internet.ideasclaro\""); // Start task and set APN
  delay(4000);
  Response();
  GPRS.println("AT+CIICR"); // Bring up wireless connection with GPRS
  delay(4000);
  Response();
  GPRS.println("AT+CIFSR"); // Get local IP address
  delay(4000);
  Response();
  GPRS.println("AT+CIPSPRT=1"); // Set its prompt echo '>'and shows "send ok" when sending is successful
  delay(4000);
  Response();
  GPRS.println("AT+CIPQSEND=0"); // Set normal data transmitting mode
  delay(4000);
  Response();
}

void DataSend2Cosm()
{
  GPRS.println("AT+CIPSTART=\"TCP\",\"api.cosm.com\",\"8081\""); //Start up TCP connection
  delay(4000);
  Response();
  GPRS.println("AT+CIPSEND"); // Begin send data to Pachube through TCP connection
  delay(4000);  
  Response();
  // Request Syntax for TCP Socket Connection Type
  GPRS.print("{");
  GPRS.print("\"method\" : \"put\",");
  GPRS.print("\"resource\" : \"/feeds/");
  GPRS.print(FEEDID);
  GPRS.print("\",");
  GPRS.print("\"params\" : {},");
  GPRS.print("\"headers\" : {\"X-ApiKey\":\"");
  GPRS.print(APIKEY);
  GPRS.print("\"},");
  GPRS.print("\"body\" : ");
  GPRS.print("{\"version\" : \"1.0.0\",");
  GPRS.print("\"datastreams\" : [");
  GPRS.print("{\"id\" : \"Temperature\",");
  GPRS.print("\"current_value\" : \"");
  GPRS.print(temperature,1);
  GPRS.print("\"},");
  GPRS.print("{\"id\" : \"Humidity\",");
  GPRS.print("\"current_value\" : \"");
  GPRS.print(humidity,1);
  GPRS.println("\"}]},");
  GPRS.print("\"token\" : \"123\"}");
  // End of Request Syntax
  GPRS.println((char)26); // After sending AT+CIPSEND ,tap CTRL+Z to send data
  delay(3000);
  Response();
  GPRS.println("AT+CIPCLOSE"); // Close TCP connection
  Response();
}

void Response()
{
  delay(100);
  while(!GPRS.available());
  if(GPRS.available()){
    while(GPRS.available()){
      Serial.write(GPRS.read());
    }
  }
}

and the serial monitor data here

AT+CSQ

+CSQ: 23,0

OK
AT+CGATT=1

OK
AT+CSTT="internet.ideasclaro"

+CME ERROR: 3
AT+CIICR

+CME ERROR: 3
AT+CIFSR

10.14.65.46
AT+CIPSPRT=1

OK
AT+CIPQSEND=0

OK
AT+CIPSTART="TCP","api.cosm.com","8081"

OK
AT+CIPSEND

+CME ERROR: 3
{"method" : "put","resource" : "/feeds/91687","params" : {},"heAT+CIPCLOSE

+CME ERROR: 3

The error i’m getting crazy because i read about in several forums and shoudn’t be problem, some times after power down and power on several time no givme error, this is very frustrating i hope anybody can help me, thanks in advance.

Hi,

Here is the step by step procedure to troubleshoot your issue

1.Check the APN name.
2.Upload the code.
3.Open the serial monitor(Error will appear).
4.Switch off the GPRS shield(In this state only the Green LED will glow).
5.Switch on the GPRS shield after some time(In this state Green and Red LED’S will glow).
6.Check the serial monitor again(The error would have disappeared now).

Let us know if it works.

Thanks and Regards

Hi , I did the procedure that you indicate but this is the results

AT+CSQ

+CSQ: 22,0

OK
AT+CGATT=1

OK
AT+CSTT="internet.ideasclaro"

OK
AT+CIICR

OK
AT+CIFSR

10.65.50.114
AT+CIPSPRT=1

OK
AT+CIPQSEND=0

OK
AT+CIPSTART="TCP","api.cosm.com","8081"

OK

+PDP: DEACT
AT+CIPSEND

+CME ERROR: 3
{"method" : "put","resource" : "/feeds/91687","params" : {},"heAT+CIPCLOSE

+CME ERROR: 3

Do you have another source which can I try? thanks in advance.

Hi,

Please use the following code and the procedure mentioned in the previous reply.

[code]/*
This code is refer to the example of PachubeClientString of Arduino
libraries and example of GPRS Shield, it is only a test code for the place
with stable GPRS signal.

  Different countries may use different APN name, this example is work in China,
  we use APN name of CMNET, please do not use it in your country.

  Circuit:
  * Battery positive port attached to analog in 0
  * Temperature&Humidity sensor attached to analog in 5
  * GPRS Shield attached to digital 7,8

  Cosm API for TCP : https://cosm.com/docs/beta/socket_server/
*/

#include <SoftwareSerial.h>
#include “DHT.h”

#define APIKEY “0iHlHslbzfGsOnJ63aftwLGXHZL8O33aAR1” // replace your pachube api key here
#define FEEDID 0186303 // replace your feed ID
#define DHTPIN A5 // Temperature&Humidity sensor port

// Uncomment whatever type you’re using!
//#define DHTTYPE DHT11 // DHT 11
#define DHTTYPE DHT22 // DHT 22 (AM2302)
//#define DHTTYPE DHT21 // DHT 21 (AM2301)
int buttonState = 0; // current state of the button
const int buttonPin = 2;

SoftwareSerial GPRS(7, 8);
DHT dht(DHTPIN, DHTTYPE);

float humidity, temperature;
long previousMillis = 0; // will store last time data was updated
long interval = 300000; // interval at which to upload data (milliseconds)

void setup()
{
pinMode(buttonPin, INPUT);
// initialize the LED as an output:
// pinMode(ledPin, OUTPUT);
// pinMode(ledpinsim,OUTPUT);
GPRS.begin(19200);
Serial.begin(19200);
dht.begin();
delay(4000);
TcpSettings(); // Setting network connection
}

void loop()
{
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH)
{
humidity = dht.readHumidity();
temperature = dht.readTemperature();
DataSend2Cosm();
delay(500);
}
}

void TcpSettings()
{
GPRS.println(“AT+CGATT=1”); // Attach from GPRS serivce
delay(1000);
Response();
GPRS.println(“AT+CSTT=“internet.ideasclaro””); // Start task and set APN
delay(1000);
Response();
GPRS.println(“AT+CIICR”); // Bring up wireless connection with GPRS
delay(3000);
Response();
GPRS.println(“AT+CIFSR”); // Get local IP address
delay(2000);
Response();
GPRS.println(“AT+CIPSPRT=0”); // Set its prompt echo '>'and shows “send ok” when sending is successful
delay(3000);
Response();

}

void DataSend2Cosm()
{

GPRS.println("AT+CIPSTART=“tcp”,“api.cosm.com”,“8081"”);//start up the connection
delay(2000);

Response();

GPRS.println(“AT+CIPSEND”);//begin send data to remote server
delay(4000);
Response();

GPRS.print("{“method”: “put”,“resource”: “/feeds/”);
GPRS.print(FEEDID);
GPRS.print("",“params”");
delay(500);
Response();
GPRS.print(": {},“headers”: {“X-PachubeApiKey”:");
delay(500);
Response();
GPRS.print(""");
GPRS.print(APIKEY);
GPRS.print(""},");
GPRS.print("“body”:");
delay(500);
Response();
GPRS.print(" {“version”: “1.0.0”,“datastreams”: “);
delay(500);
Response();
GPRS.println(”[{“id”: “Temperature”,“current_value”: “);
GPRS.print(temperature);
GPRS.print( “},”);
delay(500);
Response();
GPRS.println(”{“id”: “Humidity”,“current_value”:");
GPRS.print(humidity);
GPRS.print("}]},“token”: “lee”}");
delay(500);
Response();

GPRS.println((char)26);//sending
delay(5000);//waitting for reply, important! the time is base on the condition of internet
GPRS.println();

Response();

GPRS.println(“AT+CIPCLOSE”);//close the connection
delay(100);
Response();

}

void Response()
{
delay(100);
while (!GPRS.available());
if (GPRS.available()) {
while (GPRS.available()) {
Serial.write(GPRS.read());
}
}
}
[/code]

Note:Modify the APIKEY and the FEEDID to yours.

Thanks and Regards