GPRS SHIELD v1.0 Test

Post Reply
pinkic81
Posts: 3
Joined: Sun Jan 17, 2016 3:15 am

GPRS SHIELD v1.0 Test

Post by pinkic81 » Sun Jan 17, 2016 3:19 am

Hello, I boughthttp://www.geeetech.com/wiki/index.php/Arduino ... e_Examples 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

Code: Select all

/*
  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

Code: Select all

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

Post Reply