AdafruitIna219

master
javadoc

This service to support the Adafruit INA219 board. It can be used to measure Voltage, Current and Power. 

Adafruit INA219 product page

Steps to use the INA219

1. Connect the GND, VCC, SCL and SDA pins to the corresponding i2c pins on the Arduino or Raspberry PI. 

2. Connect the GND to GND on the source that you want to measure.

3. Connctect V- and V+ in the circuit that you want to measure. For example you can connect V+ to the battery + and V- to the cable that you normally would have connected to the battery.

4. Start MyrobotLab and test the AdafruitIna219 service using the example script.


#file : /service/AdafruitIna219.py edit raw
#########################################
# AdafruitIna219.py
# description: Adafruit INA219 Voltage and Current sensor Service
# categories: [sensor]
#########################################
# This script shows how to use the AdafruitIna219 service
#
# This section shows is if you use the Arduino i2c pins
arduino = Runtime.createAndStart("Arduino","Arduino")
arduino.connect("COM3")
raspi = Runtime.createAndStart("RasPi","RasPi")
ina219 = Runtime.createAndStart("AdafruitIna219","AdafruitIna219")
# From version 1.0.2316 use attach instead of setController
ina219.setController(arduino,"1","0x40")'
ina219.attach(arduino,"1","0x40")
# 
# This section shows is if you use the GPIO i2c pins on the RaspBerry Pi directly
raspi = Runtime.createAndStart("RasPi","RasPi")
ina219 = Runtime.createAndStart("AdafruitIna219","AdafruitIna219")
# From version 1.0.2316 use attach instead of setController
# ina219.setController(raspi,"1","0x40")
ina219.attach(raspi,"1","0x40")
#
# This sections shows how to get the values from the service
ina219.refresh()
print ina219.busVoltage," mV bus voltage"
print ina219.shuntResistance, "Ohms shunt resistance"
print ina219.shuntVoltage ," mV accross the shunt resistor"
print ina219.current, " mA current"
print ina219.power, " mW power"