Data not posting due to format
I have a project that collects data from a CO2 sensor and stored it in these ints:
CO2PPM = (int)data[2] * 256 + (int)data[3];
temperature = (int)data[4] - 40; which are defined as ints. Then just before the http request, they are processed like this:
static char outstr3[15];
static char outstr4[15];
String dataString3 = dtostrf(CO2PPM, 8, 2, outstr3);
String dataString4 = dtostrf(temperature, 8, 2, outstr4);and finally used in the GET request:
wifly.println("GET /update?api_key=apikey&field1="dataString4"&field2="+dataString3+" HTTP/1.1");which fails to successfully register the data into TS. However if I hardcode it like this:
wifly.println("GET /update?api_key=apikey&field1=23.45&field2=67.89 HTTP/1.1");it works, the data is registered.
Any idea how to fix this issue?
5 Comments
Time DescendingHave you outputted the datastring3 and 4 to the serial monitor to ensure they are building correctly? I would consider building the full update string first, possibly with sprintf. sprintf(wholBigString,"GET /update?api_key=apikey&field1=%d&field2=%dHTTP/1.1",value1,value2) Serial.println(wholeBigString"); Then your final command is just wifly.println(wholeBigString);