http://docs.micropython.org/en/v1.9.3/p ... b.ADC.html
example from bottom of the page
overdischarge protection
Re: overdischarge protection
The stm constants are automatically generated from the CMSIS headers, and I'm going to guess that the CMSIS headers changed along the way.
I'm pretty sure that the new name for 'ADC' is now 'ADC123_COMMON'
I'm pretty sure that the new name for 'ADC' is now 'ADC123_COMMON'
Re: overdischarge protection
Assuming you are using a pyboard I would suggest the following as a first trial.
This will give you the actual Vref which is the operation voltage of the MCU.
Code: Select all
import pyb
adc = pyb.ADCAll(12, 0x70000)
print('%.2f' % adc.read_vref())
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: overdischarge protection
I have a PR awaiting attention which extends the ADC functionality and replaces this outdated example code. At some point the firmware has improved so you can read individual channels without using ADCAll. And, as @chuckbook has pointed out, a mask parameter for the ADCAll object can also be used to modify its default of turning on all the ADC's.
So we now have two ways of reading voltage without needing the stm library. As so often happens the docs lag the code.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.