From a6e77cc5dc289c50ec6e9c5b519ad0da90a3ffed Mon Sep 17 00:00:00 2001 From: Hendrik Langer Date: Fri, 26 Jul 2019 14:58:59 +0200 Subject: [PATCH] internal temp sensor --- src/main.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index df682c9..06d9707 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -31,6 +31,10 @@ #include "icons.h" +extern "C" { +uint8_t temprature_sens_read(); +} + static const char* TAG = "MAIN"; WiFiMulti wifiMulti; @@ -156,7 +160,12 @@ void sendValues() { 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)); -} + } else { + String topic_temperature = String("thomas/sensor/") + ota.getMAC() + String("/temperature"); + float esp32_temperature = (temprature_sens_read() - 32) / 1.8; + char temperature[8]; sprintf(temperature, "%.2f", esp32_temperature-29.40); + mqtt.publish(topic_temperature.c_str(), temperature, strlen(temperature)); + } if (uv_active) { String topic_uvi = String("thomas/sensor/") + ota.getMAC() + String("/uvi"); @@ -288,7 +297,7 @@ void loop() ESP_LOGD(TAG, "loop()"); /* Do an e-paper display refresh every 2 minutes */ - if (millis() - lastDisplayUpdate >= 2*60*1000) { + if (millis() - lastDisplayUpdate >= 1*60*1000) { lastDisplayUpdate = millis(); display.setFullWindow(); display.setRotation(1); @@ -314,6 +323,9 @@ void loop() display.print(bme.readPressure() / 100.0F); display.println(" hPa"); } else { + display.print("Temperatur: "); + float esp32_temperature = (temprature_sens_read() - 32) / 1.8; + display.println(esp32_temperature-29.40); display.println("kein BME280"); }