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

ESP32 SoCs: Offset of 80mV when raw values gotten from adc_read() are passed throug adc_raw_to_millivolts() #86207

Closed
wmrsouza opened this issue Feb 24, 2025 · 1 comment
Assignees
Labels
area: ADC Analog-to-Digital Converter (ADC) bug The issue is a bug, or the PR is fixing a bug platform: ESP32 Espressif ESP32 priority: high High impact/importance bug

Comments

@wmrsouza
Copy link
Collaborator

Describe the bug

Offset of arroud 80mV is observed when raw values gotten from adc_read() are passed through adc_raw_to_millivolts()

  • What target platform are you using?
    This behavior was observed in 3 boards with ESP32 SoCs:

  • esp32_devkitc_wrover

  • esp32s3_devkitc

  • esp32c3_devkitm

  • What have you tried to diagnose or workaround this issue?
    I have applied voltage signals generated with a signal generator, measured the voltage at the analog input and compared with the value reported by running the sample zephyr/samples/drivers/adc_dt. Aparently the value returned by adc_read() is already the voltage applyed to the analog input in mV.

  • Is this a regression? If yes, have you been able to "git bisect" it to a
    specific commit?
    Apparently it is a regression. Using "git bisect" I verified the bug was introduced in the commit f195b35 that whose the commit message is:

  drivers: adc: esp32: Driver update
    
    Driver update to support newer HAL versions.

Before this commit, the values shown by the sample code are coherent with the voltage present at the analog input.

To Reproduce

$ west build -b esp32s3_devkitc/esp32s/procpu esp32s3_devkitc/esp32s3/procpu --pristine
$ west flash
$ west espressif monitor

Expected behavior
It was expect to read values near to the voltage present at the analog input been shown by the sample code

Impact
Incorrect reading from adc_read() and consequently from adc_raw_to_millivolts()

Logs and console output
board: esp32s3_devkitc
gain: 1/4
voltage applied: 992mV

ADC reading[7]:
- adc@60040000, channel 0: 1339 = 1064 mV
ADC reading[8]:
- adc@60040000, channel 0: 1440 = 1065 mV
ADC reading[9]:
- adc@60040000, channel 0: 1355 = 1077 mV
ADC reading[10]:
- adc@60040000, channel 0: 1339 = 1064 mV

Environment (please complete the following information):

  • OS: Linux Ubuntu 22.04
  • Toolchain: Zephyr SDK 0.17.0
  • Commit SHA or Version used:
    • Zephyr version: 4.1.0-rc1
    • SHA: efbe277

Additional context

/ {
	zephyr,user {
		io-channels = <&adc0 0>;
	};
};

&adc0 {
	status = "okay";
	#address-cells = <1>;
	#size-cells = <0>;

	channel@0 {
		reg = <0>;
		zephyr,gain = "ADC_GAIN_1_4";
		zephyr,reference = "ADC_REF_INTERNAL";
		zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
		zephyr,resolution = <12>;
	};
};
@wmrsouza wmrsouza added the bug The issue is a bug, or the PR is fixing a bug label Feb 24, 2025
@wmrsouza wmrsouza changed the title ESP32 SoCs: Offset of 100mV when raw values gotten from adc_read() are passed throug adc_raw_to_millivolts() ESP32 SoCs: Offset of 80mV when raw values gotten from adc_read() are passed throug adc_raw_to_millivolts() Feb 24, 2025
@wmrsouza wmrsouza self-assigned this Feb 24, 2025
@wmrsouza wmrsouza added platform: ESP32 Espressif ESP32 area: ADC Analog-to-Digital Converter (ADC) priority: high High impact/importance bug labels Feb 24, 2025
@fabiobaltieri
Copy link
Member

Fixed by #86113

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: ADC Analog-to-Digital Converter (ADC) bug The issue is a bug, or the PR is fixing a bug platform: ESP32 Espressif ESP32 priority: high High impact/importance bug
Projects
None yet
Development

No branches or pull requests

2 participants