Hi,
I am puzzled why data is not arriving with this script.
Any help is highly appropriated…
Thanks
// Assemble the data into the required format, then send it to the
// Tago.io cloud as an HTTP POST request.
void http_POST_data_Tago_cloud(void) {
// close any connection before send a new request.
// This will free the socket on the WiFi shield
client.stop();
Serial.println("\nStarting connection to server...");
if (client.connect("api.tago.io", 80)) {
Serial.println("connected to server tago");
client.println("POST api.tago.io/data? HTTP/1.1");
client.println("HOST: api.tago.io");
client.println("Content-Type: application/json");
client.println("Device-Token: " TAGO_DEVICE_TOKEN_STRING);
client.println("_ssl: false");
uint8_t T_positive_integer = airData.T_C_int_with_sign & TEMPERATURE_VALUE_MASK;
// If the most-significant bit is set, the temperature is negative (below 0 C)
if ((airData.T_C_int_with_sign & TEMPERATURE_SIGN_MASK) != 0) {
// The bit is set: celsius temperature is negative
sprintf(postBuffer,"[{\"variable\":\"temperature\",\"value\":-%u.%u}",
T_positive_integer, airData.T_C_fr_1dp);
}
else {
// The bit is not set: celsius temperature is positive
sprintf(postBuffer,"[{\"variable\":\"temperature\",\"value\":%u.%u}",
T_positive_integer, airData.T_C_fr_1dp);
}
sprintf(fieldBuffer,",{\"variable\":\"pressure\",\"value\":%lu}", airData.P_Pa);
strcat(postBuffer, fieldBuffer);
sprintf(fieldBuffer,",{\"variable\":\"humidity\",\"value\":%u.%u}",
airData.H_pc_int, airData.H_pc_fr_1dp);
strcat(postBuffer, fieldBuffer);
sprintf(fieldBuffer,",{\"variable\":\"aqi\",\"value\":%u.%u}",
airQualityData.AQI_int, airQualityData.AQI_fr_1dp);
strcat(postBuffer, fieldBuffer);
sprintf(fieldBuffer,",{\"variable\":\"aqi_string\",\"value\":\"%s\"}",
interpret_AQI_value(airQualityData.AQI_int));
strcat(postBuffer, fieldBuffer);
sprintf(fieldBuffer,",{\"variable\":\"bvoc\",\"value\":%u.%02u}",
airQualityData.bVOC_int, airQualityData.bVOC_fr_2dp);
strcat(postBuffer, fieldBuffer);
sprintf(fieldBuffer,",{\"variable\":\"spl\",\"value\":%u.%u}",
soundData.SPL_dBA_int, soundData.SPL_dBA_fr_1dp);
strcat(postBuffer, fieldBuffer);
sprintf(fieldBuffer,",{\"variable\":\"peak_amp\",\"value\":%u.%02u}",
soundData.peak_amp_mPa_int, soundData.peak_amp_mPa_fr_2dp);
strcat(postBuffer, fieldBuffer);
sprintf(fieldBuffer,",{\"variable\":\"particulates\",\"value\":%u.%02u}",
particleData.concentration_int, particleData.concentration_fr_2dp);
strcat(postBuffer, fieldBuffer);
sprintf(fieldBuffer,",{\"variable\":\"illuminance\",\"value\":%u.%02u}]",
lightData.illum_lux_int, lightData.illum_lux_fr_2dp);
strcat(postBuffer, fieldBuffer);
int len = strlen(postBuffer);
sprintf(fieldBuffer,"Content-Length: %u",len);
client.println(fieldBuffer);
client.println();
client.println(postBuffer);
Serial.println(postBuffer);
}
else {
Serial.println(“Connection failed”);
}
}