16 lines
341 B
Python
Executable file
16 lines
341 B
Python
Executable file
# SPDX-FileCopyrightText: 2018 Kattni Rembor for Adafruit Industries
|
|
#
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
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))
|