From 83741e013a16f47d1b7c7c1a823b41f5aa541639 Mon Sep 17 00:00:00 2001 From: Alexandre B Date: Mon, 12 Aug 2024 08:46:34 -0400 Subject: [PATCH] . --- ESP32-Rainmaker-Switch/main/app_driver.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ESP32-Rainmaker-Switch/main/app_driver.c b/ESP32-Rainmaker-Switch/main/app_driver.c index e1963baec..32373c12a 100644 --- a/ESP32-Rainmaker-Switch/main/app_driver.c +++ b/ESP32-Rainmaker-Switch/main/app_driver.c @@ -50,10 +50,11 @@ static bool g_power_state = DEFAULT_POWER; // Define the name of app for logs. static const char *TAG = "ESP32-Nodes Rainmaker Switch"; static float a_light; +static float tsens_value; static int a_light_raw; static TimerHandle_t sensor_timer; static temperature_sensor_handle_t temp_sensor = NULL; -static temperature_sensor_config_t temp_sensor_config = TEMPERATURE_SENSOR_CONFIG_DEFAULT; +static temperature_sensor_config_t temp_sensor_config = TEMPERATURE_SENSOR_CONFIG_DEFAULT(10, 50); esp_adc_cal_characteristics_t adc1_chars; /* @@ -76,6 +77,8 @@ static void light_sensor_update(TimerHandle_t handle) { esp_rmaker_float((float)a_light_raw)); ESP_LOGI(TAG, "\nSensor value: %i", a_light_raw); + ESP_ERROR_CHECK(temperature_sensor_get_celsius(temp_sensor, &tsens_value)); + ESP_LOGI(TAG, "Temperature sensor: %0.2f", tsens_value); } void app_sensor_init(void) { //esp_err_t app_sensor_init(void) { @@ -184,6 +187,9 @@ void app_driver_init() gpio_config(&sensor_io_conf);*/ app_sensor_init(); + + ESP_ERROR_CHECK(temperature_sensor_install(&temp_sensor_config, &temp_sensor)); + ESP_ERROR_CHECK(temperature_sensor_enable(temp_sensor)); } int IRAM_ATTR app_driver_set_state(bool state)