From ff8888ff38d3c8325d3b24205f4dd09f7fa9b09d Mon Sep 17 00:00:00 2001 From: DanielR92 Date: Fri, 23 Aug 2024 18:02:50 +0200 Subject: [PATCH] Update helper.cpp --- src/utils/helper.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/utils/helper.cpp b/src/utils/helper.cpp index edb9b9b9..a692f9ea 100644 --- a/src/utils/helper.cpp +++ b/src/utils/helper.cpp @@ -3,6 +3,7 @@ // Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/ //----------------------------------------------------------------------------- +#include #include "helper.h" #include "dbg.h" #include "../plugins/plugin_lang.h" @@ -142,4 +143,22 @@ namespace ah { } DBGPRINTLN(""); } + +#if defined(ESP32) + float readTemperature() { + /*// ADC1 channel 0 is GPIO36 + adc1_config_width(ADC_WIDTH_BIT_12); + adc1_config_channel_atten(ADC1_CHANNEL_0, ADC_ATTEN_DB_0); + int adc_reading = adc1_get_raw(ADC1_CHANNEL_0); + // Convert the raw ADC reading to a voltage in mV + esp_adc_cal_characteristics_t characteristics; + esp_adc_cal_value_t val_type = esp_adc_cal_characterize(ADC_UNIT_1, ADC_ATTEN_DB_0, ADC_WIDTH_BIT_12, 1100, &characteristics); + uint32_t voltage = esp_adc_cal_raw_to_voltage(adc_reading, &characteristics); + // Convert the voltage to a temperature in Celsius + // This formula is an approximation and might need to be calibrated for your specific use case. + float temperature = (voltage - 500) / 10.0;*/ + + return temperatureRead(); + } +#endif }