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

Go to the source code of this file.

Data Structures

struct  battery_sensor
 

Macros

#define VOLTAGE_MULTIPLIER   2.0f
 
#define BATTERY_SERIES_COUNT   3
 
#define BATTERY_DURACELL_AA   1
 

Functions

int battery_sensor_init (battery_sensor *sensor)
 Initialize the battery voltage sensor.
 
int battery_sensor_read (battery_sensor *sensor)
 Read battery voltage and percentage.
 

Macro Definition Documentation

◆ BATTERY_DURACELL_AA

#define BATTERY_DURACELL_AA   1

◆ BATTERY_SERIES_COUNT

#define BATTERY_SERIES_COUNT   3

◆ VOLTAGE_MULTIPLIER

#define VOLTAGE_MULTIPLIER   2.0f

Function Documentation

◆ battery_sensor_init()

int battery_sensor_init ( battery_sensor sensor)

Initialize the battery voltage sensor.

Sets up ADC channel and calibration. Call once before battery_sensor_read().

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

◆ battery_sensor_read()

int battery_sensor_read ( battery_sensor sensor)

Read battery voltage and percentage.

Updates sensor->voltage_v and sensor->percentage.

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