diff options
author | Evgeny Zinoviev <me@ch1p.io> | 2023-05-22 06:31:51 +0300 |
---|---|---|
committer | Evgeny Zinoviev <me@ch1p.io> | 2023-05-22 06:31:51 +0300 |
commit | 7cf9166dcbbd52d72e795a9e764dfe53462bc94b (patch) | |
tree | ab5475d32dee30e80637cb7fddb4e250018ef913 /platformio/temphum/src/main.cpp | |
parent | 786e8078e4802748e7bb60920dffa862135ae946 (diff) |
pio/temphum: add support for multiple sensors, si7021 and dht12 as of now
Diffstat (limited to 'platformio/temphum/src/main.cpp')
-rw-r--r-- | platformio/temphum/src/main.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/platformio/temphum/src/main.cpp b/platformio/temphum/src/main.cpp index 83f35b4..6e878a1 100644 --- a/platformio/temphum/src/main.cpp +++ b/platformio/temphum/src/main.cpp @@ -38,6 +38,7 @@ static volatile enum WiFiConnectionState wifi_state = WiFiConnectionState::WAITI static void* service = nullptr; static WiFiEventHandler wifiConnectHandler, wifiDisconnectHandler; static Ticker wifiTimer; +temphum::BaseSensor* sensor = nullptr; #if MQTT_BLINK static StopWatch blinkStopWatch; @@ -104,7 +105,12 @@ void setup() { Serial.begin(115200); #endif - temphum::setup(); +#if CONFIG_MODULE == HOMEKIT_SI7021 + sensor = new temphum::Si7021(); +#elif CONFIG_MODULE == HOMEKIT_DHT12 + sensor = new temphum::DHT12(); +#endif + sensor->setup(); auto cfg = config::read(); if (config::isDirty(cfg)) { @@ -170,7 +176,7 @@ void loop() { } else if (mqtt->diagnosticsStopWatch.elapsed(10000)) { mqtt->sendDiagnostics(); - auto data = temphum::read(); + auto data = sensor->read(); PRINT("temp:"); PRINT(data.temp); PRINT(", rh: "); |