uint32_t Core2ForAWS_Port_B_ADC_ReadMilliVolts(void)
Read the calibrated ADC voltage from GPIO36.
Definition: core2forAWS.c:538
Read the calibrated ADC voltage from GPIO36.
- Note
- Uses the etched eFuse VRef calibration.
-
pin_mode_t for PORT_B_ADC_PIN must be set to ADC before using Core2ForAWS_Port_B_ADC_ReadMilliVolts.
This function reads the raw ADC value from Port B's Analog-to-Digital-Converter (ADC) on GPIO36 and converts it to millivolts using the VRef calibration. GPIO36 is the only pin on the external ports with access to the ADC. Read more about using ADCs with the ESP-IDF.
The example code sets the ADC pin mode for the PORT_B_ADC_PIN, creates a FreeRTOS task which periodically (1s) reads the ADC voltage of the M5Stack EARTH moisture sensor connected on Port B. It prints out the value to the serial output.
Example:
#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_log.h"
static const char *
TAG =
"ADC_VOLTAGE_READ_DEMO";
void read_moisture_task(){
for(;;){
vTaskDelay(pdMS_TO_TICKS(1000));
}
}
void app_main(void){
if(err == ESP_OK){
xTaskCreatePinnedToCore(read_moisture_task, "moisture_voltage", 1024*4, NULL, 1, NULL, 1);
}
}
esp_err_t Core2ForAWS_Port_PinMode(gpio_num_t pin, pin_mode_t mode)
Sets the pin mode of the specified pin.
Definition: core2forAWS.c:431
void Core2ForAWS_Init(void)
Initializes the power chip with default values, enables battery charging, and initializes all enabled...
Definition: core2forAWS.c:32
Functions to initialize and access Core2 for AWS IoT EduKit hardware features.
@ ADC
Enable ADC mode. Only available on Port B—GPIO 36.
Definition: core2forAWS.h:218
#define PORT_B_ADC_PIN
The ADC pin on expansion port B.
Definition: core2forAWS.h:137
#define TAG
Definition: i2c_device.c:10
- Returns
- the voltage reading from the ADC in millivolts.