File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change 4040#include "esp32/rom/rtc.h"
4141#elif CONFIG_IDF_TARGET_ESP32S2
4242#include "esp32s2/rom/rtc.h"
43+ #include "driver/temp_sensor.h"
4344#elif CONFIG_IDF_TARGET_ESP32C3
4445#include "esp32c3/rom/rtc.h"
46+ #include "driver/temp_sensor.h"
4547#else
4648#error Target CONFIG_IDF_TARGET is not supported
4749#endif
5153
5254//Undocumented!!! Get chip temperature in Farenheit
5355//Source: https://github.com/pcbreflux/espressif/blob/master/esp32/arduino/sketchbook/ESP32_int_temp_sensor/ESP32_int_temp_sensor.ino
56+ #ifdef CONFIG_IDF_TARGET_ESP32
5457uint8_t temprature_sens_read ();
5558
5659float temperatureRead ()
5760{
5861 return (temprature_sens_read () - 32 ) / 1.8 ;
5962}
63+ #else
64+ float temperatureRead ()
65+ {
66+ float result = NAN ;
67+ temp_sensor_config_t tsens = TSENS_CONFIG_DEFAULT ();
68+ temp_sensor_set_config (tsens );
69+ temp_sensor_start ();
70+ temp_sensor_read_celsius (& result );
71+ temp_sensor_stop ();
72+ return result ;
73+ }
74+ #endif
6075
6176void __yield ()
6277{
You can’t perform that action at this time.
0 commit comments