File espos_adc.h¶
FileList > espos_sensors > include > espos_adc.h
Go to the source code of this file
#include <stdbool.h>#include <stdint.h>#include "esp_err.h"
Classes¶
| Type | Name |
|---|---|
| struct | espos_adc_cfg_t |
Public Types¶
| Type | Name |
|---|---|
| enum | espos_adc_atten_t Attenuation, which sets the input range. |
| typedef struct espos_adc * | espos_adc_handle_t Opaque handle; one per channel. |
Public Functions¶
| Type | Name |
|---|---|
| bool | espos_adc_calibrated (espos_adc_handle_t h) Whether eFuse calibration is in use for this channel. |
| void | espos_adc_close (espos_adc_handle_t h) |
| esp_err_t | espos_adc_open (const espos_adc_cfg_t * cfg, espos_adc_handle_t * out) Open one ADC channel. |
| esp_err_t | espos_adc_read_raw (espos_adc_handle_t h, int * out_raw) The averaged raw count, for a caller doing its own conversion. |
| esp_err_t | espos_adc_read_volts (espos_adc_handle_t h, float * out_volts) Averaged, calibrated reading in volts. |
Public Types Documentation¶
enum espos_adc_atten_t¶
Attenuation, which sets the input range.
enum espos_adc_atten_t {
ESPOS_ADC_ATTEN_0DB = 0,
ESPOS_ADC_ATTEN_2_5DB,
ESPOS_ADC_ATTEN_6DB,
ESPOS_ADC_ATTEN_12DB
};
The names are the IDF's without the driver header, so a public espOS header stays free of IDF includes. 12 dB reaches roughly 3.1 V and is what a 3.3 V divider wants; the smaller settings clip well below the top of that range.
typedef espos_adc_handle_t¶
Opaque handle; one per channel.
Public Functions Documentation¶
function espos_adc_calibrated¶
Whether eFuse calibration is in use for this channel.
function espos_adc_close¶
function espos_adc_open¶
Open one ADC channel.
Use an ADC1 pin. ADC2 shares hardware with the radio on several chips and a oneshot read fails while WiFi is up which is every moment that matters on a Signal K device, and it fails intermittently rather than at boot.
Per-target ADC1 pins, for reference: ESP32-C6 GPIO 0..6 ESP32-P4 GPIO 16..23 (but 14..19 carry the SDIO link to the co-processor on the Waveshare panels use 20..23 there) ESP32-C3 GPIO 0..4 ESP32-S3 GPIO 1..10
Returns ESP_ERR_NOT_FOUND when the GPIO is not an ADC pin on this chip.
function espos_adc_read_raw¶
The averaged raw count, for a caller doing its own conversion.
function espos_adc_read_volts¶
Averaged, calibrated reading in volts.
Without eFuse calibration data the result falls back to the nominal full scale for the attenuation, which is accurate to a few percent rather than a few millivolts. espos_adc_calibrated() says which you are getting; it is worth logging once at boot, because a device that is quietly uncalibrated looks exactly like one whose divider is slightly wrong.
Blocks for the conversion (microseconds). Safe to call from the flow task.
The documentation for this class was generated from the following file espos_sensors/include/espos_adc.h