- float temperature = 0;
- float humidity = 0;
- int err = SimpleDHTErrSuccess;
- if ((err = dht22.read2(&temperature, &humidity, NULL)) == SimpleDHTErrSuccess) {
- sendToInfluxDB("temperature,city="+city+",location="+location, "value", String(temperature));
- sendToInfluxDB("humidity,city="+city+",location="+location, "value", String(humidity));
+ delay(POLL_INT);
+
+ sensors_event_t event;
+
+ dht.temperature().getEvent(&event);
+ if (isnan(event.temperature)) {
+ // Error
+ } else {
+ sendToInfluxDB("temperature,city="+city+",location="+location, "value", String(event.temperature));
+ }
+ dht.humidity().getEvent(&event);
+ if (isnan(event.relative_humidity)) {
+ // Error
+ } else {
+ sendToInfluxDB("humidity,city="+city+",location="+location, "value", String(event.relative_humidity));