Skip to main content

Analog to Digital Converter ,ESP32

 

Analog to Digital Converter

Overview

The ESP32 integrates two 12-bit SAR (Successive Approximation Register) ADCs, supporting a total of 18 measurement channels (analog enabled pins).

The ADC driver API supports ADC1 (8 channels, attached to GPIOs 32 - 39), and ADC2 (10 channels, attached to GPIOs 0, 2, 4, 12 - 15 and 25 - 27). However, the usage of ADC2 has some restrictions for the application:

  1. ADC2 is used by the Wi-Fi driver. Therefore the application can only use ADC2 when the Wi-Fi driver has not started.

  2. Some of the ADC2 pins are used as strapping pins (GPIO 0, 2, 15) thus cannot be used freely. Such is the case in the following official Development Kits:

  • ESP32 DevKitC: GPIO 0 cannot be used due to external auto program circuits.

  • ESP-WROVER-KIT: GPIO 0, 2, 4 and 15 cannot be used due to external connections for different purposes.

Configuration and Reading ADC

Each ADC unit supports two work modes, ADC-RTC or ADC-DMA mode. ADC-RTC is controlled by the RTC controller and is suitable for low-frequency sampling operations. ADC-DMA is controlled by a digital controller and is suitable for high-frequency continuous sampling actions.

ADC-RTC mode

The ADC should be configured before reading is taken.

Attenuation configuration is done per channel, see adc1_channel_t and adc2_channel_t, set as a parameter of above functions.

Then it is possible to read ADC conversion result with adc1_get_raw() and adc2_get_raw(). Reading width of ADC2 should be set as a parameter of adc2_get_raw() instead of in the configuration functions.

Comments

Popular posts from this blog

cpp and header file example

https://docs.microsoft.com/en-us/cpp/cpp/header-files-cpp

Advanced 1-Wire Master with Memory #DS2485

DS28E18 Setup Guide for Remote I 2 C and SPI Sensors Featuring the DS2485 It is well established that the I 2 C and SPI communication protocols are designed to be used in short-distance, intra-board communication. This application note discusses the I 2 C and SPI bus extending capabilities of the DS28E18 1-Wire ® to I 2 C/SPI Bridge with Command Sequencer. Specifically, it covers important measures for setting up a long line, e.g., 100m communication with multiple I 2 C and SPI sensors and the benefits of using this device. Introduction The I 2 C and SPI communication protocols are well known to have short bus distances that range no more than a couple meters. Although solutions currently exist for extending these ranges, they are often complex and expensive. The DS28E18 , however, is a cost-efficient bridge-chip device that demonstrates the benefits of using the 1-Wire interface to get the most range out of complex I 2 C and SPI devices such as environmental sensors,...
  AK7451 Magnetic Angle Sensor AKM Semiconductor features their AK7451 zero latency magnetic rotary angle sensor for motor-driven applications The AK7455 is a 14-bit angular rotation sensor that detects magnetic fields parallel or perpendicular to the surface of the IC and tracks high speeds up to 25,000 rpm using proprietary technology. A simple configuration of the AK7455 and a small magnet is used to sense the angle of rotation in a non-contact manner. The AK7455 is available in a power supply voltage range of 3.0V to 5.5V and a small package (QFN 24-pin). https://www.akm.com/eu/en/products/rotation-angle-sensor/ Key Features Anomaly magnetic field detection A function to detect magnetic fields other than the sensor magnet as an anomaly magnetic field has been added, contributing to the detection of system anomalies and malfunctions. Increased placement flexibility in Off-Axis configurations In addition to the conventional magnetic field detec...