Skip to content
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

fix(adc): Always use default read resolution in __analogReadMilliVolts #9006

Merged
merged 1 commit into from Dec 15, 2023

Conversation

bkari02
Copy link
Contributor

@bkari02 bkari02 commented Dec 15, 2023

Description of Change

  1. Add new __analogReadRaw function and move code from __analogRead without mapResolution part to __analogReadRaw.
  2. Refactor __anlogRead to use analogReadRaw (and mapResolution).
  3. Refactor __analogReadMilliVolts to always use default read resolution when reading adc value, as expected input by esp_adc_cal_raw_to_voltage is in default resolution (means replacing all calls of __analogRead with __analogReadRaw).

This shall avoid that a change of the resolution of analog readings leads to incorrect values when using the analogReadMilliVolts function, as this function always expects the resolution to be the default one. For more information see description in #8999.

Tests scenarios

I have tested my Pull Request on Arduino-esp32 core v2.0.14 with UM FeatherS2 (ESP32-S2) board with an analog sensor (Truebner SMT50).

Related links

Related to #8999.

…s to obtain correct milliVolts value.

Add new __analogReadRaw function and move code from __analogRead without mapResolution part to __analogReadRaw.

Refactor __anlogRead to use analogReadRaw (and mapResolution).

Refactor __analogReadMilliVolts to always use default read resolution when reading adc value, as expected input by esp_adc_cal_raw_to_voltage is in default resolution (means replacing all calls of __analogRead with __analogReadRaw).
@bkari02
Copy link
Contributor Author

bkari02 commented Dec 15, 2023

@P-R-O-C-H-Y @me-no-dev
Not sure about this being the best way to solve the issue, just let me know if you have better ideas how to fix it.

@me-no-dev
Copy link
Member

Looks sound to me. @P-R-O-C-H-Y PTAL

Copy link
Member

@P-R-O-C-H-Y P-R-O-C-H-Y left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for the fix :)

@me-no-dev me-no-dev merged commit b87d525 into espressif:release/v2.x Dec 15, 2023
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants