Skip to content

Conversation

@bobmoss
Copy link

@bobmoss bobmoss commented Dec 1, 2025

This PR is in response to the issue I raised here: #62

It adds two new functions setShuntADCResolution and setBusADCResolution which use the already defined values for setting the ADC resolution and averaging options, such as INA219_CONFIG_SADCRES_12BIT_128S_69MS

It has been tested on an Adafruit ESP32-S3-TFT Feather connected to an Adafruit INA219 breakout board.

By running a test calling getCurrent_mA 1000 times over 350mS (the fastest speed available by setting the I2C bus speed to 400000) while reading the current of a motor, I was able to prove that the different settings worked. The INA219 chip always gives you the last reading, even if there isn't a new value ready yet.

For example, when running with the default option (INA219_CONFIG_SADCRES_12BIT_1S_532US), you can see every value was different (motors are noisy!). However, when the setting was changed to INA219_CONFIG_SADCRES_12BIT_128S_69MS, you can see it takes nearly 200 readings until the value changes. 350mS / 1000 samples = 0.35ms per reading. 0.35ms x 197 samples = 68.95ms. In addition, the values were obviously "averegaed".

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.

1 participant