Browse Source

internal temp sensor

ir
Hendrik Langer 5 years ago
parent
commit
a6e77cc5dc
  1. 16
      src/main.cpp

16
src/main.cpp

@ -31,6 +31,10 @@
#include "icons.h" #include "icons.h"
extern "C" {
uint8_t temprature_sens_read();
}
static const char* TAG = "MAIN"; static const char* TAG = "MAIN";
WiFiMulti wifiMulti; WiFiMulti wifiMulti;
@ -156,7 +160,12 @@ void sendValues() {
mqtt.publish(topic_temperature.c_str(), temperature, strlen(temperature)); mqtt.publish(topic_temperature.c_str(), temperature, strlen(temperature));
mqtt.publish(topic_humidity.c_str(), humidity, strlen(humidity)); mqtt.publish(topic_humidity.c_str(), humidity, strlen(humidity));
mqtt.publish(topic_pressure.c_str(), pressure, strlen(pressure)); 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) { if (uv_active) {
String topic_uvi = String("thomas/sensor/") + ota.getMAC() + String("/uvi"); String topic_uvi = String("thomas/sensor/") + ota.getMAC() + String("/uvi");
@ -288,7 +297,7 @@ void loop()
ESP_LOGD(TAG, "loop()"); ESP_LOGD(TAG, "loop()");
/* Do an e-paper display refresh every 2 minutes */ /* Do an e-paper display refresh every 2 minutes */
if (millis() - lastDisplayUpdate >= 2*60*1000) { if (millis() - lastDisplayUpdate >= 1*60*1000) {
lastDisplayUpdate = millis(); lastDisplayUpdate = millis();
display.setFullWindow(); display.setFullWindow();
display.setRotation(1); display.setRotation(1);
@ -314,6 +323,9 @@ void loop()
display.print(bme.readPressure() / 100.0F); display.print(bme.readPressure() / 100.0F);
display.println(" hPa"); display.println(" hPa");
} else { } else {
display.print("Temperatur: ");
float esp32_temperature = (temprature_sens_read() - 32) / 1.8;
display.println(esp32_temperature-29.40);
display.println("kein BME280"); display.println("kein BME280");
} }

Loading…
Cancel
Save