summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaditya Dhruv <[email protected]>2025-08-14 20:02:01 -0500
committerAaditya Dhruv <[email protected]>2025-08-14 20:03:18 -0500
commit3d0fbbfe9f5c683028f37e06bc720a74811e30fe (patch)
tree011b48ad1d315ab22194477dfb75c3bd1dcc83fc
parentae92286baf2ec538984eb3ca186aea1619ac4b59 (diff)
Update documentation
-rw-r--r--main/sprayduck.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/main/sprayduck.c b/main/sprayduck.c
index 29f4461..60935b1 100644
--- a/main/sprayduck.c
+++ b/main/sprayduck.c
@@ -4,7 +4,6 @@
#include "esp_log.h"
#include "hal/gpio_types.h"
#include <driver/gpio.h>
-#include <stdlib.h>
#include "hal/adc_types.h"
#include "esp_adc/adc_oneshot.h"
@@ -15,6 +14,14 @@
#define TAG "sprayduck"
+/**
+ * @brief Read the value from the soil sensor and return the average over 5
+ * consectuive readings
+ *
+ * @param[in] handler The adc_oneshot_unit_handle_t handler responsible for
+ * reading the value from the sensor
+ * @return Average of 5 oneshot readings, attuned by ADC_UNIT_1
+ */
int read_sensor(adc_oneshot_unit_handle_t handler) {
int sum = 0;
int i = 0;
@@ -56,7 +63,7 @@ void app_main(void)
while (1) {
//Turn on sensor
- gpio_set_level((gpio_num_t) SENSOR_GPIO_PIN, 1);
+ // gpio_set_level((gpio_num_t) SENSOR_GPIO_PIN, 1);
int value = read_sensor(handler);
ESP_LOGI("sprayduck", "Checking sensor value average %d", value);
if (value > THRESHOLD) {
@@ -69,7 +76,7 @@ void app_main(void)
}
// Turn off Sensor
gpio_set_level((gpio_num_t) SENSOR_GPIO_PIN, 0);
- vTaskDelay(43200000 / portTICK_PERIOD_MS);
+ vTaskDelay(1000 / portTICK_PERIOD_MS);
}
}