mirror of
https://github.com/alexandrebobkov/ESP-Nodes.git
synced 2025-08-16 01:14:16 +00:00
temp sensor
This commit is contained in:
@@ -23,6 +23,24 @@
|
||||
|
||||
#include "joystick.h"
|
||||
|
||||
/*
|
||||
EXP32-C3 Chip built-in temprature sensor
|
||||
Read & display the temperature value
|
||||
*/
|
||||
static void chip_sensor_init () {
|
||||
temp_sensor = NULL;
|
||||
temperature_sensor_config_t temp_sensor_config = TEMPERATURE_SENSOR_CONFIG_DEFAULT(10, 50);
|
||||
ESP_ERROR_CHECK(temperature_sensor_install(&temp_sensor_config, &temp_sensor));
|
||||
|
||||
ESP_LOGI(TAG, "Enable temperature sensor");
|
||||
ESP_ERROR_CHECK(temperature_sensor_enable(temp_sensor));
|
||||
}
|
||||
static void display_chip_temperature () {
|
||||
ESP_LOGI("ESP32-C3", "Reading sensor temperature");
|
||||
ESP_ERROR_CHECK(temperature_sensor_get_celsius(temp_sensor, &tsens_value));
|
||||
ESP_LOGW("ESP32-C3", "Temperature value %.02f ℃", tsens_value);
|
||||
}
|
||||
|
||||
void app_main(void)
|
||||
{
|
||||
// Initialize internal temperature sensor
|
||||
|
Reference in New Issue
Block a user