Uploading_Sensor_Data_to_Pachube.com_using_GPRS

Hello..i am new to the arduino world.. I just want to know , right now i'm working on data logging to pachube.com using GPRS .For the moment I only want to submit temperature data to my pachube.com , and I read about this at http://seeedstudio.com/wiki/GPRS_Shield#Uploading_Sensor_Data_to_Pachube.com_using_GPRS ..I try adjust the codes there , as I want to submit only one data per time I will not use any SD card to store the data,so I adjust the code like below:

my equipment is:
1 lm35
1 arduino duemilanove
1 SIM900 GSM/GPRS MODULE

really, it is a simple project,but ,I'm new to this,and I cant detect any error to the following code,so please guys I am eager to know, why I cant get any reading at my pachube account.The serial terminal said my data succesfully sent,but I dont receive anything at all at my pachube account here https://pachube.com/feeds/55223 . If you have any alternative code,do you mind sharing.Because I keep looking on the internet , and no one write a good code based on GPRS module to pachube.com . I nearly giveup because not a lot of people know pachube.com . I might consider to offer $us10 for helping me ,with the code.I am no programmer,so I got dizzy when something like this happen. I study myself the AT command but I dont understand half of it. I do not know any expert.Help me please :slight_smile:

my circuit connection as below :
and LM35 is at analog input 0

#include <NewSoftSerial.h>
#include "FileLogger.h"

float tempC;
int tempPin = 0;

NewSoftSerial GPRS_Serial(6, 4);

void setup()
{
GPRS_Serial.begin(9600); //GPRS Shield baud rate
Serial.begin(9600);

setup_start:

Serial.println("Turn on GPRS Modem and wait for 1 minute.");
Serial.println("and then press a key");
Serial.println("Press c for power on configuration");
Serial.println("press any other key for uploading");
Serial.flush();
while(Serial.available() == 0);
if(Serial.read()=='c')
{
Serial.println("Executing AT Commands for one time power on configuration");

GPRS_Serial.flush();

GPRS_Serial.println("ATE0"); //Command echo off
Serial.println("ATE0 Sent");
if(GPRS_Serial_wait_for_bytes(4,10) == 0)
{
Serial.println("Timeout");
goto setup_start;
}
else
{
Serial.print("Received:");
while(GPRS_Serial.available()!=0)
{
Serial.print((unsigned char)GPRS_Serial.read());
Serial.print("\n");
}
}

GPRS_Serial.println("AT+CIPMUX=0"); //We only want a single IP Connection at a time.
Serial.println("AT+CIPMUX=0 Sent");
if(GPRS_Serial_wait_for_bytes(4,10) == 0)
{
Serial.println("Timeout");
goto setup_start;
}
else
{
Serial.print("Received:");
while(GPRS_Serial.available()!=0)
{
Serial.print((unsigned char)GPRS_Serial.read());
Serial.print("\n");
}
}

GPRS_Serial.println("AT+CIPMODE=0"); //Selecting "Normal Mode" and NOT "Transparent Mode" as the TCP/IP Application Mode
Serial.println("AT+CIPMODE=0 Sent!");
if(GPRS_Serial_wait_for_bytes(4,10) == 0)
{
Serial.println("Timeout");
goto setup_start;
}
else
{
Serial.print("Received:");
while(GPRS_Serial.available()!=0)
{
Serial.print((unsigned char)GPRS_Serial.read());
Serial.print("\n");
}
}

GPRS_Serial.println("AT+CGDCONT=1,"192.168.1.23","celcom3g","203.82.64.41",0,0"); //Defining the Packet Data
//Protocol Context - i.e. the Protocol Type, Access Point Name and IP Address
Serial.println("AT+CGDCONT=1,"192.168.1.23","celcom3g","203.82.64.41",0,0 Sent!");
if(GPRS_Serial_wait_for_bytes(4,10) == 0)
{
Serial.println("Timeout");
goto setup_start;
}
else
{
Serial.print("Received:");
while(GPRS_Serial.available()!=0)
{
Serial.print((unsigned char)GPRS_Serial.read());
Serial.print("\n");
}
}

GPRS_Serial.println("AT+CSTT="celcom3g""); //Start Task and set Access Point Name (and username and password if any)
Serial.println("AT+CSTT="celcom3g" Sent!");
if(GPRS_Serial_wait_for_bytes(4,10) == 0)
{
Serial.println("Timeout");
goto setup_start;
}
else
{
Serial.print("Received:");
while(GPRS_Serial.available()!=0)
{
Serial.print((unsigned char)GPRS_Serial.read());
Serial.print("\n");
}
}

GPRS_Serial.println("AT+CIPSHUT"); //Close any GPRS Connection if open
Serial.println("AT+CIPSHUT Sent!");
if(GPRS_Serial_wait_for_bytes(7,10) == 0)
{
Serial.println("Timeout");
goto setup_start;
}
else
{
Serial.print("Received:");
while(GPRS_Serial.available()!=0)
{
Serial.print((unsigned char)GPRS_Serial.read());
Serial.print("\n");
}
}
}
}

void loop()
{
tempC = analogRead(tempPin); //read the value from the sensor
tempC = (5.0 * tempC * 100.0)/1024.0; //convert the analog data to temperature
Serial.print((byte)tempC); //send the data to the computer
delay(1000);

loop_start:

Serial.println("Press a key to read temperature and upload it");
Serial.flush();
while(Serial.available() == 0);
Serial.read();

Serial.print("Temperature = ");
Serial.println(tempC);

GPRS_Serial.println("AT+CIPSTART="TCP","api.pachube.com","80""); //Open a connection to Pachube.com
Serial.println("AT+CIPSTART="TCP","api.pachube.com","80" Sent!");
if(GPRS_Serial_wait_for_bytes(12,255) == 0)
{
Serial.println("Timeout");
goto loop_start;
}
else
{
Serial.print("Received:");
while(GPRS_Serial.available()!=0)
{
Serial.print((unsigned char)GPRS_Serial.read());
Serial.print("\n");
}
}

GPRS_Serial.flush();
GPRS_Serial.println("AT+CIPSEND"); //Start data through TCP connection
Serial.println("AT+CIPSEND Sent!");
if(GPRS_Serial_wait_for_bytes(1,100) == 0)
{
Serial.println("Timeout");
goto loop_start;
}
else
{
Serial.print("Received:");
while(GPRS_Serial.available()!=0)
{
Serial.print((unsigned char)GPRS_Serial.read());
Serial.print("\n");
}
}

GPRS_Serial.flush();

//Emulate HTTP and use PUT command to upload temperature datapoint using Comma Seperate Value Method
GPRS_Serial.print("PUT /v2/feeds/55223.csv .csv HTTP/1.1\r\n");
Serial.println("PUT /v2/feeds/55223.csv HTTP/1.1 Sent!");
delay(300);

GPRS_Serial.print("Host: api.pachube.com\r\n");
Serial.println("Host: api.pachube.com Sent!");
delay(300);

GPRS_Serial.print("X-PachubeApiKey: my api key \r\n"); //REPLACE THIS KEY WITH YOUR OWN PACHUBE API KEY
Serial.println("X-PachubeApiKey: my Api key Sent!"); //REPLACE THIS KEY WITH YOUR OWN PACHUBE API KEY
delay(300);

GPRS_Serial.print("Content-Length: 12\r\n");
Serial.print("Content-Length: 12 Sent!");
delay(300);

GPRS_Serial.print("Connection: close\r\n\r\n");
Serial.print("Connection: close Sent!");
delay(300);
GPRS_Serial.print("TEMP,"); //You may replace the stream name "TMP102" to any other string that you have choosen.
delay(300);
GPRS_Serial.print(tempC);
delay(300);
GPRS_Serial.print("\r\n");
delay(300);
GPRS_Serial.print("\r\n");
delay(300);
GPRS_Serial.print(0x1A,BYTE);
delay(300); //Send End Of Line Character to send all the data and close connection
if(GPRS_Serial_wait_for_bytes(20,255) == 0)
{
Serial.println("Timeout");
goto loop_start;
}
else
{
Serial.print("Received:");
while(GPRS_Serial.available()!=0)
{
Serial.print((unsigned char)GPRS_Serial.read());
Serial.print("\n");
}
}

GPRS_Serial.flush();
GPRS_Serial.println("AT+CIPSHUT"); //Close the GPRS Connection
Serial.println("AT+CIPSHUT Sent!");
if(GPRS_Serial_wait_for_bytes(4,100) == 0)
{
Serial.println("Timeout");
goto loop_start;
}
else
{
Serial.print("Received:");
while(GPRS_Serial.available()!=0)
{
Serial.print((unsigned char)GPRS_Serial.read());
Serial.print("\n");
}
}
}

char GPRS_Serial_wait_for_bytes(char no_of_bytes, int timeout)
{
while(GPRS_Serial.available() < no_of_bytes)
{
delay(200);
timeout-=1;
if(timeout == 0)
{
return 0;
}
}
return 1;
}

I've been writing C code for 30 years. I've used, in that time, exactly one goto statement, in a parser. Your code is unnecessarily riddled with them. A simple do/while statement with if blocks would eliminate the need for all of them.

Some functions would be useful, too.

You need to explain why you are throwing away random amounts of unread data (Serial.flush()) or why it is necessary at that point to block until the output buffer is empty, depending on which version of the IDE you are using. If you can't, it's time to employ the delete key.

You seem to have forgotten to include the output that you are seeing.

And, you've forgotten to mention whether you can send data to any server other than pachube.

PaulS:
I've been writing C code for 30 years. I've used, in that time, exactly one goto statement, in a parser. Your code is unnecessarily riddled with them. A simple do/while statement with if blocks would eliminate the need for all of them.

Some functions would be useful, too.

You need to explain why you are throwing away random amounts of unread data (Serial.flush()) or why it is necessary at that point to block until the output buffer is empty, depending on which version of the IDE you are using. If you can't, it's time to employ the delete key.

You seem to have forgotten to include the output that you are seeing.

And, you've forgotten to mention whether you can send data to any server other than pachube.

tq sir for replying, as I said earlier sir, I am not a programmer , and it is difficult for myself even to understand the codes.The codes actually from seeduino.com ,and I just copy and delete irrelevant code for me and put necessary info such as my API key and local ISP, because from my understanding , basically the code is design for seeduino stalker module + arduino ,which consist data to be stored to SD card first. but I did not need that as I want just to send one data at a time.so no storing is needed. Actually to be honest sir, I did not understand half of the code.So I dont know which one is need and which one is not need.I am sorry , I really tried my best.I know it's a lot to understand , but the project is due in short time, and I did not have a lot of time to study all of this by myself.I dont know why , my lecturer give me this project.can u help me construct simple AT command for this.and i will try myself to understand it and tweak it for my purpose.