Skip to content

Instantly share code, notes, and snippets.

@unforgiven512
Created July 18, 2019 22:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save unforgiven512/98870d8d66e704aac4577cae3e528600 to your computer and use it in GitHub Desktop.
Save unforgiven512/98870d8d66e704aac4577cae3e528600 to your computer and use it in GitHub Desktop.
INA219 library (example) for MicroPython on ESP8266
from machine import Pin, I2C
from ina219 import INA219
from logging import INFO
SHUNT_OHMS = 0.1
i2c = I2C(-1, Pin(5), Pin(4))
ina = INA219(SHUNT_OHMS, i2c, log_level=INFO)
ina.configure()
print("Bus Voltage: %.3f V" % ina.voltage())
print("Current: %.3f mA" % ina.current())
print("Power: %.3f mW" % ina.power())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment