Safe Sprinkler
Master/slave irrigation system (ESP-NOW + LoRaWAN)
Loading...
Searching...
No Matches
Data Structures | Macros | Functions
adc.h File Reference
#include "esp_adc/adc_oneshot.h"
Include dependency graph for adc.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  adc_sensor
 

Macros

#define TARGET_UNIT   ADC_UNIT_1
 
#define TARGET_ATTEN   ADC_ATTEN_DB_12
 
#define TARGET_WIDTH   ADC_BITWIDTH_DEFAULT
 
#define TIME_BETWEEN_SHOT_MS   3
 

Functions

int adc_sensor_init (adc_sensor *sensor)
 Initialize an ADC sensor for one-shot readings.
 
int adc_sensor_read (adc_sensor *sensor)
 Read voltage from the ADC sensor.
 

Macro Definition Documentation

◆ TARGET_ATTEN

#define TARGET_ATTEN   ADC_ATTEN_DB_12

◆ TARGET_UNIT

#define TARGET_UNIT   ADC_UNIT_1

◆ TARGET_WIDTH

#define TARGET_WIDTH   ADC_BITWIDTH_DEFAULT

◆ TIME_BETWEEN_SHOT_MS

#define TIME_BETWEEN_SHOT_MS   3

Function Documentation

◆ adc_sensor_init()

int adc_sensor_init ( adc_sensor sensor)

Initialize an ADC sensor for one-shot readings.

Configures the ADC channel, attenuation, and calibration. Call once before using adc_sensor_read().

Parameters
sensorPointer to adc_sensor to initialize (channel and num_samples must be set)
Returns
ESP_OK on success, error code otherwise

◆ adc_sensor_read()

int adc_sensor_read ( adc_sensor sensor)

Read voltage from the ADC sensor.

Performs a one-shot conversion and updates sensor->voltage_mv. Uses the configured number of samples and calibration.

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