arduino / arduino/ArduinoCore-avr
support measure battery‘s voltage when powered by it
- Dominant language
- C
- Stars
- 1.5k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
>when arduino is powered by a out battery, it very likely that we need to konw the remain capacity of the battery.
We can't directly measure it voltage from the Ax pin by ADC because the Vref is not constant in this situation. One possible method is to "measure" the internal 1.1v voltage refenrece and set the Vcc as Vref.
Thus the out baterry voltage is 1.1 * 1024/ADC which measure range is from 1.1v to a large value.
**But**Arduino core does not supply a API for the function from what I see in wiring_analog.c. The function need to modify the ADCMUX register.
**So I want to add a API name like readBatteryVoltage() to implement it. **
>I have test the method and it work well
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in wiring_analog.c and inspect how the ADCMUX register is configured for analog reads. Evaluate the proposed internal 1.1V reference method and the readBatteryVoltage() API for battery-powered boards. Done means the core exposes the requested measurement and the reported voltage works with the described ADC range.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- embedded-iot
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100