|
|
@ -153,9 +153,9 @@ void sendValues() { |
|
|
|
char temperature[8]; sprintf(temperature, "%.2f", bme.readTemperature()); |
|
|
|
char humidity[7]; sprintf(humidity, "%.2f", bme.readHumidity()); |
|
|
|
char pressure[8]; sprintf(pressure, "%.2f", bme.readPressure() / 100.0F); |
|
|
|
mqtt.publish(topic_temperature.c_str(), temperature, sizeof(temperature)); |
|
|
|
mqtt.publish(topic_humidity.c_str(), humidity, sizeof(humidity)); |
|
|
|
mqtt.publish(topic_pressure.c_str(), pressure, sizeof(pressure)); |
|
|
|
mqtt.publish(topic_temperature.c_str(), temperature, strlen(temperature)); |
|
|
|
mqtt.publish(topic_humidity.c_str(), humidity, strlen(humidity)); |
|
|
|
mqtt.publish(topic_pressure.c_str(), pressure, strlen(pressure)); |
|
|
|
} |
|
|
|
|
|
|
|
if (uv_active) { |
|
|
@ -165,9 +165,9 @@ void sendValues() { |
|
|
|
char uvi[10]; sprintf(uvi, "%.2f", uv.readUVI()); |
|
|
|
char uva[10]; sprintf(uva, "%.2f", uv.readUVA()); |
|
|
|
char uvb[10]; sprintf(uvb, "%.2f", uv.readUVB()); |
|
|
|
mqtt.publish(topic_uvi.c_str(), uvi, sizeof(uvi)); |
|
|
|
mqtt.publish(topic_uvi.c_str(), uvi, sizeof(uva)); |
|
|
|
mqtt.publish(topic_uvi.c_str(), uvi, sizeof(uvb)); |
|
|
|
mqtt.publish(topic_uvi.c_str(), uvi, strlen(uvi)); |
|
|
|
mqtt.publish(topic_uvi.c_str(), uvi, strlen(uva)); |
|
|
|
mqtt.publish(topic_uvi.c_str(), uvi, strlen(uvb)); |
|
|
|
} |
|
|
|
|
|
|
|
if (sds_active) { |
|
|
@ -177,8 +177,8 @@ void sendValues() { |
|
|
|
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)); |
|
|
|
mqtt.publish(topic_pm10.c_str(), pm10, strlen(pm10)); |
|
|
|
mqtt.publish(topic_pm25.c_str(), pm25, strlen(pm25)); |
|
|
|
|
|
|
|
// if you want to just print the measured values, you can use toString() method as well
|
|
|
|
Serial.println(pm.toString()); |
|
|
@ -237,7 +237,7 @@ void setup() |
|
|
|
if (sds_fw.isOk()) { |
|
|
|
sds_active = true; |
|
|
|
sds.setActiveReportingMode(); // ensures sensor is in 'active' reporting mode
|
|
|
|
sds.setCustomWorkingPeriod(5); // sensor sends data every 3 minutes
|
|
|
|
// sds.setCustomWorkingPeriod(5); // sensor sends data every 3 minutes
|
|
|
|
} else { |
|
|
|
Serial.println("Failed to communicate with SDS011 sensor, check wiring?"); |
|
|
|
} |
|
|
|