uint32_t Core2ForAWS_Port_B_ADC_ReadRaw(void)
Read the raw ADC value from GPIO36.
Definition: core2forAWS.c:534
Read the raw ADC value 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_ReadRaw.
This function reads the raw ADC value from Port B's Analog-to-Digital-Converter (ADC) on GPIO36. 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 raw ADC value 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 =
"RAW_ADC_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_raw", 4096*2, NULL, 1, NULL, 1);
}
}
@
return The raw
ADC reading.
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