Can you get the supply voltage?

The official pyboard running MicroPython.
This is the reference design and main target board for MicroPython.
You can buy one at the store.
Target audience: Users with a pyboard.
Gordon_Hardman
Posts: 68
Joined: Sat May 03, 2014 11:31 pm

Re: Can you get the supply voltage?

Post by Gordon_Hardman » Thu Apr 30, 2015 7:02 pm

One more caution- it appears the ADCAll method sets All possible pins to analog inputs. If you just want to get the counts from vref, it is on channel 17. Although the Micropython documentation says the argument for the ADC() method must be a pin, it apparently accepts a channel:

>>>
>>> a = pyb.ADC(17)
>>> a.read()
1459
>>>

This is correct for my supply voltage. So if you see pins change from, say, OUT_PP to ANALOG after the ADCAll method, this is why...

manitou
Posts: 73
Joined: Wed Feb 25, 2015 12:15 am

Re: Can you get the supply voltage?

Post by manitou » Sun May 03, 2015 4:21 pm

thanks, I didn't realize you could directly access the special ADC channels. I edited my whining earlier in this thread.

Code: Select all

#define ADC_CHANNEL_TEMPSENSOR  ((uint32_t)ADC_CHANNEL_16)
#define ADC_CHANNEL_VREFINT     ((uint32_t)ADC_CHANNEL_17)
#define ADC_CHANNEL_VBAT        ((uint32_t)ADC_CHANNEL_18)

Post Reply