ESP-LiveControl
1.99.1
HTTP server, AJAX API backend and Vue.js web application implementing self-contained, zero-install WiFi remote control of hardware modules attached to the Espressif ESP32 SoC
|
ESP32 ADC 1 channel access with configurable averaging. More...
#include <esp32_adc_channel.hpp>
Public Member Functions | |
ESP32ADCChannel (adc1_channel_t channel_num, adc_atten_t attenuation, uint32_t averaged_samples=64, adc_bits_width_t bits_width=ADC_WIDTH_BIT_12, uint32_t default_vref=1100u) | |
Initialize an ESP32 ADC channel. More... | |
uint16_t | get_raw_averaged () |
Get raw ADC channel conversion value. Repeats sampling a number of times, see "averaged_samples" constructor parameter. More... | |
uint16_t | get_voltage_averaged () |
Get channel input voltage in millivolts. Repeats sampling a number of times, see "averaged_samples" constructor parameter. More... | |
int32_t | calculate_raw_from_voltage (uint32_t v_in_mv) |
Calculate backwards the raw ADC reading for given input voltage, based on calibration constants from ADC initialisation, and also based on a ADC resolution setting of 12 bits. | |
void | debug_print_check_efuse () |
void | debug_print_characterisation_val_type (esp_adc_cal_value_t val_type) |
void | test_register_direct () |
Public Attributes | |
adc1_channel_t | channel_num |
adc_atten_t | attenuation |
esp_adc_cal_characteristics_t | calibration_data |
Protected Attributes | |
uint32_t | division_shift |
Static Protected Attributes | |
static auto | _bits_width = adc_bits_width_t{ADC_WIDTH_MAX} |
ESP32 ADC 1 channel access with configurable averaging.
Input voltage can be read raw or as calibrated voltage value in millivolts.
Raw output is always scaled such as if the ADC was set to 12 bits mode, i.e. theoretical full-scale output is 4096 - 1
ESP32ADCChannel::ESP32ADCChannel | ( | adc1_channel_t | channel_num, |
adc_atten_t | attenuation, | ||
uint32_t | averaged_samples = 64 , |
||
adc_bits_width_t | bits_width = ADC_WIDTH_BIT_12 , |
||
uint32_t | default_vref = 1100u |
||
) |
Initialize an ESP32 ADC channel.
channel_num | Analog input channel number |
attenuation | Voltage input scale setting, see ESP-IDF reference |
averaged_samples | Read this many input samples at once for any trigger |
bits_width | Can be less then ADC_WIDTH_BIT_12 for faster speed. |
default_vref | Can be manually set if hardware has no e-fuse calibration |
void ESP32ADCChannel::debug_print_check_efuse | ( | ) |
Debug functions
uint16_t ESP32ADCChannel::get_raw_averaged | ( | ) |
Get raw ADC channel conversion value. Repeats sampling a number of times, see "averaged_samples" constructor parameter.
The output is always scaled such as if the ADC was set to 12 bits mode, i.e. theoretical full-scale output is 4096 - 1
uint16_t ESP32ADCChannel::get_voltage_averaged | ( | ) |
Get channel input voltage in millivolts. Repeats sampling a number of times, see "averaged_samples" constructor parameter.
This takes into account the calibration constants from ADC initialisation. If there is no e-fuse calibration on-chip, this uses the default_vref setting from the constructor, default is 1100 millivolts.