Safe Sprinkler
Master/slave irrigation system (ESP-NOW + LoRaWAN)
Loading...
Searching...
No Matches
Data Structures | Macros | Functions
soil_sensor.h File Reference
#include "driver/gpio.h"
#include "esp_err.h"
#include "general/adc.h"
Include dependency graph for soil_sensor.h:

Go to the source code of this file.

Data Structures

struct  soil_sensor
 

Macros

#define SOIL_CALIB_DRY_MV   2700
 
#define SOIL_CALIB_WET_MV   1100
 
#define ADC_SAMPLE_NUM   10
 

Functions

int soil_sensor_init (soil_sensor *sensor)
 Initialize the soil moisture sensor.
 
int soil_sensor_read (soil_sensor *sensor)
 Read soil moisture percentage.
 

Macro Definition Documentation

◆ 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

Function Documentation

◆ soil_sensor_init()

int soil_sensor_init ( soil_sensor sensor)

Initialize the soil moisture sensor.

Configures ADC channel and power GPIO. Call once before soil_sensor_read().

Parameters
sensorPointer to soil_sensor (channel_pin, power_pin must be set)
Returns
ESP_OK on success, error code otherwise

◆ soil_sensor_read()

int soil_sensor_read ( soil_sensor sensor)

Read soil moisture percentage.

Powers sensor, samples ADC, and updates sensor->percentage (0–100).

Parameters
sensorPointer to initialized soil_sensor
Returns
ESP_OK on success, error code otherwise