HI All,
Hope you can help.
The following works fine to post to PushingBox:
gprsSerial.println("AT+HTTPPARA="URL","http://api.pushingbox.com/pushingbox?devid=v644DEB15F1Annnn&EMP1_Temperature=*23*\"");
How can I replace "23" with a variable?
For instance, the following does not work:
int temp=23;
gprsSerial.println("AT+HTTPPARA="URL","http://api.pushingbox.com/pushingbox?devid=v644DEB15F1Annnn&EMP1_Temperature=[u]temp[/u]\"");
Please help.
Claude
You should be able to accomplish what you want by using sprintf() to format the string. Try out this example:
void setup() {
Serial.begin(9600);
char buffer[120]; // buffer for formatted string
int temp=23; // variable for temperature
// string with formatting specifications
char * msg = "AT+HTTPPARA=\"URL\",\"http://api.pushingbox.com/pushingbox?devid=v644DEB15F1Annnn&EMP1_Temperature=%d\"";
// format buffer
sprintf(buffer,msg,temp);
Serial.println(buffer);
}
void loop() {
}