mirror of
https://github.com/revspace/operame
synced 2024-11-01 05:57:30 +00:00
Merge pull request #9 from SanderVanhove/main
Add temperature and humidity to rest message
This commit is contained in:
commit
f9c3d05ce9
15
operame.ino
15
operame.ino
@ -584,7 +584,6 @@ void loop() {
|
||||
} else {
|
||||
// Check if there is a humidity sensor
|
||||
if (isnan(h) || isnan(t)) {
|
||||
Serial.println("Failed to read from DHT sensor!");
|
||||
// Only display CO2 value (the old way)
|
||||
// some MH-Z19's go to 10000 but the display has space for 4 digits
|
||||
display_ppm(co2 > 9999 ? 9999 : co2);
|
||||
@ -612,10 +611,7 @@ void loop() {
|
||||
|
||||
if(mqtt_temp_hum_enabled) {
|
||||
//temperature
|
||||
if(isnan(t)) {
|
||||
Serial.println("Failed to read from DHT sensor, so no MQTT publish");
|
||||
}
|
||||
else {
|
||||
if(!isnan(t)) {
|
||||
String message;
|
||||
const size_t capacity = JSON_OBJECT_SIZE(3);
|
||||
DynamicJsonDocument doc(capacity);
|
||||
@ -627,10 +623,7 @@ void loop() {
|
||||
}
|
||||
|
||||
//humidity
|
||||
if(isnan(h)) {
|
||||
Serial.println("Failed to read from DHT sensor, so no MQTT publish");
|
||||
}
|
||||
else {
|
||||
if(!isnan(h)) {
|
||||
String message;
|
||||
const size_t capacity = JSON_OBJECT_SIZE(3);
|
||||
DynamicJsonDocument doc(capacity);
|
||||
@ -653,9 +646,11 @@ void loop() {
|
||||
every(rest_interval) {
|
||||
if (co2 <= 0) break;
|
||||
|
||||
const size_t capacity = JSON_OBJECT_SIZE(2);
|
||||
const size_t capacity = JSON_OBJECT_SIZE(4);
|
||||
DynamicJsonDocument message(capacity);
|
||||
message["co2"] = co2;
|
||||
message["temperature"] = t;
|
||||
message["humidity"] = h;
|
||||
message["id"] = rest_resource_id.c_str();
|
||||
|
||||
if (wificlientsecure.connected() || wificlientsecure.connect(&rest_domain[0], rest_port)) {
|
||||
|
Loading…
Reference in New Issue
Block a user