10.1.1 Tension d'alimentation
Il est possible de lire la tension d'alimentation (la tension d'entrée, celle du port USB ou de la broche
VBus).
import
machine
import
time
#Vsys Voltage
#N.B. Can't use ADC(29). it crashes!!!!
#to get around it we need to declare ADC(3),
# getPads, setPads, readADC and then put back the original Pads
#set or get GPIO pads settings. Need on Pin29
conversion_factor
def
setPad(gpio, value):
machine.mem32[0x4001c000
def
getPad(gpio):
return
machine.mem32[0x4001c000
def
readVsys():
oldpad
= getPad(29)
setPad(29,128)
adc_Vsys
= machine.ADC(3)
Vsys
= adc_Vsys.read_u16() *
setPad(29,oldpad)
return
Vsys
while
True:
print(readVsys())
time.sleep(5)
=
3.3
/ (65535)
| (4+
#no pulls, no output, no input
3.0
(4
* gpio))] =
value
| (4+
(4
* gpio))]
*
conversion_factor