CircuitPython battery voltage code
This commit is contained in:
parent
306ca74c94
commit
ccae8b2d20
1 changed files with 12 additions and 0 deletions
12
Introducing_Feather_M0_Express/battery_voltage.py
Executable file
12
Introducing_Feather_M0_Express/battery_voltage.py
Executable file
|
|
@ -0,0 +1,12 @@
|
||||||
|
import board
|
||||||
|
import analogio
|
||||||
|
|
||||||
|
vbat_voltage = analogio.AnalogIn(board.D9)
|
||||||
|
|
||||||
|
|
||||||
|
def get_voltage(pin):
|
||||||
|
return (pin.value * 3.3) / 65536 * 2
|
||||||
|
|
||||||
|
|
||||||
|
battery_voltage = get_voltage(vbat_voltage)
|
||||||
|
print("VBat voltage: {:.2f}".format(battery_voltage))
|
||||||
Loading…
Reference in a new issue