Uploading_Sensor_Data_to_Pachube.com_using_GPRS
hello..i new arduino world.. want know , right i'm working on data logging pachube.com using gprs .for moment want submit temperature data pachube.com , , read @ http://seeedstudio.com/wiki/gprs_shield#uploading_sensor_data_to_pachube.com_using_gprs ..i try adjust codes there , want submit 1 data per time not use sd card store data,so adjust code below:
my equipment is:
1 lm35
1 arduino duemilanove
1 sim900 gsm/gprs module
really, simple project,but ,i'm new this,and cant detect error following code,so please guys eager know, why cant reading @ pachube account.the serial terminal said data succesfully sent,but dont receive @ @ pachube account here https://pachube.com/feeds/55223 . if have alternative code,do mind sharing.because keep looking on internet , , no 1 write code based on gprs module pachube.com . giveup because not lot of people know pachube.com . might consider offer $us10 helping me ,with code.i no programmer,so got dizzy when happen. study myself @ command dont understand half of it. not know expert.help me please
my circuit connection below :
, lm35 @ analog input 0
my equipment is:
1 lm35
1 arduino duemilanove
1 sim900 gsm/gprs module
really, simple project,but ,i'm new this,and cant detect error following code,so please guys eager know, why cant reading @ pachube account.the serial terminal said data succesfully sent,but dont receive @ @ pachube account here https://pachube.com/feeds/55223 . if have alternative code,do mind sharing.because keep looking on internet , , no 1 write code based on gprs module pachube.com . giveup because not lot of people know pachube.com . might consider offer $us10 helping me ,with code.i no programmer,so got dizzy when happen. study myself @ command dont understand half of it. not know expert.help me please

my circuit connection below :
quote
#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 , wait 1 minute.");
serial.println("and press key");
serial.println("press c power on configuration");
serial.println("press other key uploading");
serial.flush();
while(serial.available() == 0);
if(serial.read()=='c')
{
serial.println("executing @ commands 1 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 want single ip connection @ 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" , not "transparent mode" 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 packet data
//protocol context - i.e. protocol type, access point name , 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 , set access point name (and username , 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 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 value sensor
tempc = (5.0 * tempc * 100.0)/1024.0; //convert analog data temperature
serial.print((byte)tempc); //send data computer
delay(1000);
loop_start:
serial.println("press key read temperature , 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 connection 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 , use put command 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: api key \r\n"); //replace key own pachube api key
serial.println("x-pachubeapikey: api key sent!"); //replace key 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 stream name "tmp102" other string 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 send data , 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 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 30 years. i've used, in time, 1 goto statement, in parser. code unnecessarily riddled them. simple do/while statement if blocks eliminate need of them.
some functions useful, too.
you need explain why throwing away random amounts of unread data (serial.flush()) or why necessary @ point block until output buffer empty, depending on version of ide using. if can't, it's time employ delete key.
you seem have forgotten include output seeing.
and, you've forgotten mention whether can send data server other pachube.
some functions useful, too.
you need explain why throwing away random amounts of unread data (serial.flush()) or why necessary @ point block until output buffer empty, depending on version of ide using. if can't, it's time employ delete key.
you seem have forgotten include output seeing.
and, you've forgotten mention whether can send data server other pachube.
Arduino Forum > Using Arduino > Project Guidance > Uploading_Sensor_Data_to_Pachube.com_using_GPRS
arduino
Comments
Post a Comment