#include "driver/gpio.h"
#include "esp_err.h"
#include "general/adc.h"
Go to the source code of this file.
◆ ADC_SAMPLE_NUM
| #define ADC_SAMPLE_NUM 10 |
◆ SOIL_CALIB_DRY_MV
| #define SOIL_CALIB_DRY_MV 2700 |
◆ SOIL_CALIB_WET_MV
| #define SOIL_CALIB_WET_MV 1100 |
◆ soil_sensor_init()
Initialize the soil moisture sensor.
Configures ADC channel and power GPIO. Call once before soil_sensor_read().
- Parameters
-
| sensor | Pointer to soil_sensor (channel_pin, power_pin must be set) |
- Returns
- ESP_OK on success, error code otherwise
◆ soil_sensor_read()
Read soil moisture percentage.
Powers sensor, samples ADC, and updates sensor->percentage (0–100).
- Parameters
-
- Returns
- ESP_OK on success, error code otherwise