From 02e9fb7e83d6b818b83556ab0a1766e998838219 Mon Sep 17 00:00:00 2001 From: Hendrik Langer Date: Fri, 26 Jul 2019 13:50:28 +0200 Subject: [PATCH] send sds values --- src/main.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 7a1cfd1..f7e9832 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -170,6 +170,23 @@ void sendValues() { mqtt.publish(topic_uvi.c_str(), uvi, sizeof(uvb)); } + if (sds_active) { + PmResult pm = sds.readPm(); + if (pm.isOk()) { + String topic_pm10 = String("thomas/sensor/") + ota.getMAC() + String("/pm10"); + char pm10[10]; sprintf(pm10, "%.2f", pm.pm10); + String topic_pm25 = String("thomas/sensor/") + ota.getMAC() + String("/pm25"); + char pm25[10]; sprintf(pm25, "%.2f", pm.pm25); + mqtt.publish(topic_pm10.c_str(), pm10, sizeof(pm10)); + mqtt.publish(topic_pm25.c_str(), pm25, sizeof(pm25)); + + // if you want to just print the measured values, you can use toString() method as well + Serial.println(pm.toString()); + } + + + } + } /**