FIX: DHT22 Adafruit: added missing setup call

This commit is contained in:
Patrick Haßel 2025-03-03 10:13:09 +01:00
parent da31e2d40a
commit 528c12c70f
3 changed files with 9 additions and 7 deletions

View File

@ -37,10 +37,10 @@ lib_deps = ${common.lib_deps}
build_flags = ${common.build_flags} -DNODE_GREENHOUSE -DHOSTNAME=\"Greenhouse\" build_flags = ${common.build_flags} -DNODE_GREENHOUSE -DHOSTNAME=\"Greenhouse\"
board_build.filesystem = ${common.board_build.filesystem} board_build.filesystem = ${common.board_build.filesystem}
monitor_speed = ${common.monitor_speed} monitor_speed = ${common.monitor_speed}
;upload_protocol = ${common.upload_protocol} upload_protocol = ${common.upload_protocol}
;upload_port = 10.0.0.160 upload_port = 10.0.0.160
upload_port = ${common.upload_port} ;upload_port = ${common.upload_port}
upload_speed = ${common.upload_speed} ;upload_speed = ${common.upload_speed}
[env:Fermenter] [env:Fermenter]
platform = ${esp12e.platform} platform = ${esp12e.platform}
@ -52,6 +52,6 @@ board_build.filesystem = ${common.board_build.filesystem}
monitor_speed = ${common.monitor_speed} monitor_speed = ${common.monitor_speed}
upload_flags = --auth=OtaAuthPatrixFermenter upload_flags = --auth=OtaAuthPatrixFermenter
upload_protocol = ${common.upload_protocol} upload_protocol = ${common.upload_protocol}
upload_port = 10.0.0.169 upload_port = 10.0.0.164
;upload_port = ${common.upload_port} ;upload_port = ${common.upload_port}
;upload_speed = ${common.upload_speed} ;upload_speed = ${common.upload_speed}

View File

@ -9,6 +9,7 @@ DHT22Sensor greenhouseDHT22("greenhouse", D5);
void patrixSetup() { void patrixSetup() {
greenhouseTSL.setup(); greenhouseTSL.setup();
greenhouseDHT22.setup();
} }
void patrixLoop() { void patrixLoop() {

View File

@ -24,12 +24,13 @@ public:
void setup() { void setup() {
dht.begin(); dht.begin();
last = millis();
} }
void loop() { void loop() {
const auto now = max(1UL, millis()); const auto now = max(1UL, millis());
float temperature = NAN; float temperature = NAN;
if (last == 0 || now - last >= intervalMs) { if (now - last >= intervalMs) {
sensors_event_t event; sensors_event_t event;
dht.temperature().getEvent(&event); dht.temperature().getEvent(&event);
@ -50,7 +51,7 @@ public:
mqttPublishValue(name + "/humidity/absolute", absHumid, "HUMIDITY_ABSOLUTE_GM3"); mqttPublishValue(name + "/humidity/absolute", absHumid, "HUMIDITY_ABSOLUTE_GM3");
} }
} }
last = now; last = now;
} }
} }