micropython version: >= v1.19.1-777-g129032941.uf2 due to the new bytearray.fromhex() function micropython ssd1306 library (only if using display)
import time
from machine import I2C,Pin
import ssd1306
from micropython import const
from math import trunc
- upload INA219.py to the lib location: /lib/INA219.py on the pico
- configure the button PIN (default: GP16)
- enter the mv_voltage bus resolution if different from the default (4 mV)
- enter the max expected amperage (default 2.0)
button_pin = const(16) # <int> any GPIO pin on the rpico, the pin is kept low through a 100kΩ resistor and pulsed high to change display modes
...
mv_voltage_bus_resolution = const(4) # <int> change if different from 4 mV
max_expected_amperage = 2.0 # <float> from 0.0 <--> 3.2 with the default 2.0