Skip to content

analogReadMilliVolts returns the wrong value in esp32-s2 #6436

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 task done
yangminglong opened this issue Mar 16, 2022 · 3 comments
Closed
1 task done

analogReadMilliVolts returns the wrong value in esp32-s2 #6436

yangminglong opened this issue Mar 16, 2022 · 3 comments
Labels
Area: Peripherals API Relates to peripheral's APIs. Chip: ESP32-S2 Issue is related to support of ESP32-S2 Chip Resolution: Duplicate Issue is a duplicate of another issue

Comments

@yangminglong
Copy link

yangminglong commented Mar 16, 2022

Board

none

Device Description

esp32-s2

Hardware Configuration

none

Version

latest master

IDE Name

none

Operating System

none

Flash frequency

none

PSRAM enabled

no

Upload speed

none

Description

[esp32-s2-adc api-reference:]
(https://docs.espressif.com/projects/esp-idf/en/latest/esp32s2/api-reference/peripherals/adc.html)

Attenuation Measurable input voltage range
ADC_ATTEN_DB_0 0 mV ~ 750 mV
ADC_ATTEN_DB_2_5 0 mV ~ 1050 mV
ADC_ATTEN_DB_6 0 mV ~ 1300 mV
ADC_ATTEN_DB_11 0 mV ~ 2500 mV

arduino-esp32-master code at line 251:

    uint16_t adc_reading = __analogRead(pin);
    uint16_t max_reading = 8191;
    uint16_t max_mv = 1100;
    switch(__analogAttenuation){
        case 3: max_mv = 3900; break;
        case 2: max_mv = 2200; break;
        case 1: max_mv = 1500; break;
        default: break;
    }
    return (adc_reading * max_mv) / max_reading;

#4941
#4386

Sketch

none

Debug Message

none

Other Steps to Reproduce

none

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.
@yangminglong yangminglong added the Status: Awaiting triage Issue is waiting for triage label Mar 16, 2022
@Jason2866
Copy link
Collaborator

#5502 is related. Hardware calibration is not used.

@VojtechBartoska
Copy link
Contributor

Thanks @Jason2866 for linking a relation. @yangminglong Is it okay to move to mentioned issue above. If yes, this issue will be closed as duplicate. Thank you for contributing and your answer.

@VojtechBartoska VojtechBartoska added Chip: ESP32-S2 Issue is related to support of ESP32-S2 Chip Area: Peripherals API Relates to peripheral's APIs. and removed Status: Awaiting triage Issue is waiting for triage labels Mar 16, 2022
@VojtechBartoska VojtechBartoska added the Resolution: Duplicate Issue is a duplicate of another issue label Apr 7, 2022
@VojtechBartoska
Copy link
Contributor

VojtechBartoska commented Apr 7, 2022

Closing as duplicate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Peripherals API Relates to peripheral's APIs. Chip: ESP32-S2 Issue is related to support of ESP32-S2 Chip Resolution: Duplicate Issue is a duplicate of another issue
Projects
None yet
Development

No branches or pull requests

3 participants