diff --git a/RaspberryPi/main.c b/RaspberryPi/main.c index da9acd2..e0a2eb3 100644 --- a/RaspberryPi/main.c +++ b/RaspberryPi/main.c @@ -63,7 +63,7 @@ int main(void) { nodedata.isoutside = currentNode->isoutside; //copy the boolean value printf("Acquiring rest response\n"); - printf("Temperature: %f, Humidity: %f, NodeID: %i, Outside: %s, AbsoluteHumidity: %f\n", nodedata.temperature, nodedata.humidity, nodedata.node_id, nodedata.isoutside ? "Yes" : "No", absoluteHumidity(nodedata)); + printf("Temperature: %f, Humidity: %f, NodeID: %i, Outside: %s, AbsoluteHumidity: %f\n", nodedata.temperature, nodedata.humidity, nodedata.node_id, nodedata.isoutside ? "Yes" : "No", absoluteHumidity(&nodedata)); //Insert data into database printf("Insert data into stats table\n"); diff --git a/RaspberryPi/restcurl.c b/RaspberryPi/restcurl.c index 60d8452..2149c5a 100644 --- a/RaspberryPi/restcurl.c +++ b/RaspberryPi/restcurl.c @@ -82,10 +82,11 @@ int getRestSensor(sensor *sensor) { //The ID is stored in the JSON root cJSON *id = cJSON_GetObjectItemCaseSensitive(jsondata, "id"); - sensor->temperature = (float)temperature->valuedouble; - sensor->humidity = (float)humidity->valuedouble; - sensor->node_id = atoi(id->valuestring); - + if (temperature != NULL && humidity != NULL && id != NULL) { + sensor->temperature = (float)temperature->valuedouble; + sensor->humidity = (float)humidity->valuedouble; + sensor->node_id = atoi(id->valuestring); + } //free cJSON_Delete(jsondata); free(data);