The correct data prints out correctly in the serial monitor, but not in the IO Blocks. Here is the pertinent code of my sketch:
Code: Select all
// NEW!! try to publish temp data ............
Adafruit_MQTT_Publish temperature = Adafruit_MQTT_Publish(&mqtt, AIO_USERNAME "/feeds/mqtt-test.temperature");
// NEW!! try to publish humidty data ............
Adafruit_MQTT_Publish humidity = Adafruit_MQTT_Publish(&mqtt, AIO_USERNAME "/feeds/mqtt-test.humidity");
Code: Select all
Serial.print(F("\nSending sendor data "));
Serial.print(x);
Serial.print("...");
// ====== BEGING PUBLISHING DATA =====================
if (! temperature.publish(x++)) { // Publish temp data ...
Serial.println(F("Failed"));
} else {
Serial.println(F("OK!"));
}
if (! humidity.publish(x++)) { // Publish humidity data ...
Serial.println(F("Failed"));
} else {
Serial.println(F("OK!"));
}
// ======= END OF PUBLISH CODE =======================
// Following is all new unified_dht code ..............
// Get temperature event and print its value.
sensors_event_t event;
dht.temperature().getEvent(&event);
if (isnan(event.temperature)) {
Serial.println(F("Error reading temperature!"));
}
else {
Serial.print(F("Temperature: "));
Serial.print(event.temperature);
Serial.println(F("°C"));
}
// Get humidity event and print its value.
dht.humidity().getEvent(&event);
if (isnan(event.relative_humidity)) {
Serial.println(F("Error reading humidity!"));
}
else {
Serial.print(F("Humidity: "));
Serial.print(event.relative_humidity);
Serial.println(F("%"));
}
Thanks!