Skip to content

Wrong analogReadMilliVolts() in esp32s2 #4386

Closed
@fabianoriccardi

Description

@fabianoriccardi

#4072 # Hardware:
Board: ESP32-S2 Saola
Core Installation version: esp32s2 branch lates commit
IDE name: Arduino IDE

Description:

Hi, I was trying ESP32-S2 Saola breakout board, I would read analog values. I had used a variable lab bench power supply to test the ADC, but function analogReadMilliVolts() gives values 60% higher than the right value: i.e. if I set 1V, analogReadMilliVolts returns 1.6V. This behavior is constant all over the range (from 0 to 2.5V).

I think that the problem is about the fixed 13bit width in esp32-s2 while in esp32 ranges between 9 and 12.

https://docs.espressif.com/projects/esp-idf/en/latest/esp32s2/api-reference/peripherals/adc.html#_CPPv416adc_bits_width_t

Am I missing something?

Temporarily, I manage to use the following line to read input voltage:

int sensorValueRaw = analogRead(analogInPin);
int sensorValue = map(sensorValueRaw, 0, 8192, 0, 2600);

No other configuration were made to the ADC.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: StaleIssue is stale stage (outdated/stuck)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions