Arduino + Sim900/GPRS shield + Send Data Sensor to Xively/Pachube

Hi,

I need you help, I'm trying to send data from an analog sensor, GSM to Xively webserver.

Below the code I am using and the errors:

#include 
#include 

SoftwareSerial mySerial(2, 3);

void setup()
{
  mySerial.begin(19200);               // the GPRS baud rate   
  Serial.begin(19200);    // the GPRS baud rate 
  delay(500);
}

void loop()
{
  //after start up the program, you can using terminal to connect the serial of gprs shield,
  //if you input 't' in the terminal, the program will execute SendTextMessage(), it will show how to send a sms message,
  //if input 'd' in the terminal, it will execute DialVoiceCall(), etc.

  if (Serial.available())
    switch(Serial.read())
   {
     
     case 's':
       Send2Pachube();
       break;
   } 
  if (mySerial.available())
    Serial.write(mySerial.read());
}


///send2Pachube()///
///this function is to send the sensor data to the pachube, you can see the new value in the pachube after execute this function///
void Send2Pachube()
{
  mySerial.println("AT+CGATT?");
  delay(1000);

  ShowSerialData();

  mySerial.println("AT+CSTT=\"net2.vodafone.pt\"");//start task and setting the APN,
  delay(1000);

  ShowSerialData();

  mySerial.println("AT+CIICR");//bring up wireless connection
  delay(3000);

  ShowSerialData();

  mySerial.println("AT+CIFSR");//get local IP adress
  delay(2000);

  ShowSerialData();

  mySerial.println("AT+CIPSPRT=0");
  delay(3000);

  ShowSerialData();

  mySerial.println("AT+CIPSTART=\"tcp\",\"api.pachube.com\",\"8081\"");//start up the connection
  delay(2000);

  ShowSerialData();

  mySerial.println("AT+CIPSEND");//begin send data to remote server
  delay(4000);
  ShowSerialData();
  String humidity = "1031";//these 4 line code are imitate the real sensor data, because the demo did't add other sensor, so using 4 string variable to replace.
  String moisture = "1242";//you can replace these four variable to the real sensor data in your project

  mySerial.print("{\"method\": \"put\",\"resource\": \"/feeds/703024837/\",\"params\"");//here is the feed you apply from pachube
  delay(500);
  ShowSerialData();
  mySerial.print(": {},\"headers\": {\"X-PachubeApiKey\":");//in here, you should replace your pachubeapikey
  delay(500);
  ShowSerialData();
  mySerial.print(" \"mDbE0acjjkSqks6wQXBoxWKyE0XPrBR03h1rNfbQMpTOW1jR\"},\"body\":");
  delay(500);
  ShowSerialData();
  mySerial.print(" {\"version\": \"1.0.0\",\"datastreams\": ");
  delay(500);
  ShowSerialData();
  mySerial.println("[{\"id\": \"sensor1\",\"current_value\": \"" + moisture + "\"},");
  delay(500);
  ShowSerialData();
  mySerial.println("{\"id\": \"sensor2\",\"current_value\": \"" + humidity +"\"}]},\"token\": \"lee\"}");


  delay(500);
  ShowSerialData();

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

  ShowSerialData();

  mySerial.println("AT+CIPCLOSE");//close the connection
  delay(100);
  ShowSerialData();
}

void ShowSerialData()
{
  while(mySerial.available()!=0)
    Serial.write(mySerial.read());
}

and error in terminal:

AT+CGATT?

+CGATT: 1

OK
AT+CSTT="net2.vodafone.pt"

+CME ERROR: 3
AT+CIICR

+CME ERROR: 3
AT+CIFSR

+CME ERROR: 3
AT+CIPSPRT=0

OK
AT+CIPSTART="tcp","api.pachube.com","8081"

+CME ERROR: 3
AT+CIPSEND

+CME ERROR: 3
{"method": "put","resource": "/feeds/703024837/","params": {},"headers": {"X-PachubeApiKey": "mDbE0acjjkSqks6wQXBoxWKyE0XPrBR03h1rNfbQMpTOW1jR"},"body": {"version": "1.0.0","datastreams": 

ERROR



AT+CIPCLOSE

+CME ERROR: 3

You probably know this already, but CME ERROR: 3 = Operation not allowed.

FreshPT: Hi,

I need you help, I'm trying to send data from an analog sensor, GSM to Xively webserver.

Below the code I am using and the errors:

#include 
#include 

SoftwareSerial mySerial(2, 3);

void setup() {   mySerial.begin(19200);               // the GPRS baud rate      Serial.begin(19200);    // the GPRS baud rate   delay(500); }

void loop() {   //after start up the program, you can using terminal to connect the serial of gprs shield,   //if you input 't' in the terminal, the program will execute SendTextMessage(), it will show how to send a sms message,   //if input 'd' in the terminal, it will execute DialVoiceCall(), etc.

  if (Serial.available())     switch(Serial.read())    {            case 's':        Send2Pachube();        break;    }   if (mySerial.available())     Serial.write(mySerial.read()); }

///send2Pachube()/// ///this function is to send the sensor data to the pachube, you can see the new value in the pachube after execute this function/// void Send2Pachube() {   mySerial.println("AT+CGATT?");   delay(1000);

  ShowSerialData();

  mySerial.println("AT+CSTT=\"net2.vodafone.pt\"");//start task and setting the APN,   delay(1000);

  ShowSerialData();

  mySerial.println("AT+CIICR");//bring up wireless connection   delay(3000);

  ShowSerialData();

  mySerial.println("AT+CIFSR");//get local IP adress   delay(2000);

  ShowSerialData();

  mySerial.println("AT+CIPSPRT=0");   delay(3000);

  ShowSerialData();

  mySerial.println("AT+CIPSTART=\"tcp\",\"api.pachube.com\",\"8081\"");//start up the connection   delay(2000);

  ShowSerialData();

  mySerial.println("AT+CIPSEND");//begin send data to remote server   delay(4000);   ShowSerialData();   String humidity = "1031";//these 4 line code are imitate the real sensor data, because the demo did't add other sensor, so using 4 string variable to replace.   String moisture = "1242";//you can replace these four variable to the real sensor data in your project

  mySerial.print("{\"method\": \"put\",\"resource\": \"/feeds/703024837/\",\"params\"");//here is the feed you apply from pachube   delay(500);   ShowSerialData();   mySerial.print(": {},\"headers\": {\"X-PachubeApiKey\":");//in here, you should replace your pachubeapikey   delay(500);   ShowSerialData();   mySerial.print(" \"mDbE0acjjkSqks6wQXBoxWKyE0XPrBR03h1rNfbQMpTOW1jR\"},\"body\":");   delay(500);   ShowSerialData();   mySerial.print(" {\"version\": \"1.0.0\",\"datastreams\": ");   delay(500);   ShowSerialData();   mySerial.println("[{\"id\": \"sensor1\",\"current_value\": \"" + moisture + "\"},");   delay(500);   ShowSerialData();   mySerial.println("{\"id\": \"sensor2\",\"current_value\": \"" + humidity +"\"}]},\"token\": \"lee\"}");

  delay(500);   ShowSerialData();

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

  ShowSerialData();

  mySerial.println("AT+CIPCLOSE");//close the connection   delay(100);   ShowSerialData(); }

void ShowSerialData() {   while(mySerial.available()!=0)     Serial.write(mySerial.read()); }






and error in terminal:



AT+CGATT?

+CGATT: 1

OK AT+CSTT="net2.vodafone.pt"

+CME ERROR: 3 AT+CIICR

+CME ERROR: 3 AT+CIFSR

+CME ERROR: 3 AT+CIPSPRT=0

OK AT+CIPSTART="tcp","api.pachube.com","8081"

+CME ERROR: 3 AT+CIPSEND

+CME ERROR: 3 {"method": "put","resource": "/feeds/703024837/","params": {},"headers": {"X-PachubeApiKey": "mDbE0acjjkSqks6wQXBoxWKyE0XPrBR03h1rNfbQMpTOW1jR"},"body": {"version": "1.0.0","datastreams":

ERROR



AT+CIPCLOSE

+CME ERROR: 3