Skip to content

feat(tools): add ESP32 ADC calibration and LUT linearization utility - #150

Merged
PaulBouchier merged 1 commit into
linorobot:jazzyfrom
hippo5329:upstream-pr/adc-calibrate
Aug 21, 2026
Merged

feat(tools): add ESP32 ADC calibration and LUT linearization utility#150
PaulBouchier merged 1 commit into
linorobot:jazzyfrom
hippo5329:upstream-pr/adc-calibrate

Conversation

@hippo5329

@hippo5329 hippo5329 commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds the adc_calibrate standalone diagnostic firmware utility:

  • Sweeps the internal ESP32 DAC Channel 1 (GPIO 25) against BATTERY_PIN across 500 calibration iterations.
  • Interpolates nonlinearities and outputs a formatted 4096-entry C Look-Up Table (ADC_LUT[4096]) over serial (115200 baud).
  • Uses standard extra_configs = ../firmware/platformio.ini sourcing matching test_sensors, test_motors, and test_acc.

Verification

  • 100% build pass across esp32, esp32s2, esp32s3, gendrv.

@mergify

mergify Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

hippo5329 pushed a commit to hippo5329/linorobot2_hardware that referenced this pull request Aug 20, 2026
@hippo5329
hippo5329 force-pushed the upstream-pr/adc-calibrate branch 2 times, most recently from 286cc78 to 029f703 Compare August 21, 2026 04:34
@hippo5329
hippo5329 force-pushed the upstream-pr/adc-calibrate branch from 029f703 to f4f9316 Compare August 21, 2026 11:27
@PaulBouchier

Copy link
Copy Markdown
Collaborator

Thanks for this.

I tested it on a Sparkfun Thing Plus with ESP32 WROOM. It seems to work as expected.

This is an "expert" tool - you need to have a good hardware understanding. You need to connect pin 25 to whatever your battery pin is, and either disconnect the battery sense electronics, or be confident that the DAC pin can overdrive the battery sense electronics, or else you may get erroneous results. In order to use the results, you need to insert the generated table into the LUT section of the config file. These are the sorts of in-depth documentation notes that really need to be in a documentation section that describes how to use the config file. I have in mind what that should look like, but at some point I want to organize the lower section of the config files a bit better by separating and commenting the sections like "syslog config" and I2C config and Lidar config. But I think that should be done in concert with documentation that tells how to customize the config file for your robot - which is something that doesn't really exist at the moment - what's in your wiki is the closest thing to that, but it doesn't go to this level of detail.

@PaulBouchier
PaulBouchier merged commit 5368dce into linorobot:jazzy Aug 21, 2026
16 of 18 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.

2 participants