Javadoc link

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.

 

 

Example code (from branch develop):
#########################################
# AdafruitIna219.py
# description: Adafruit INA219 Voltage and Current sensor Service
# categories: [sensor]
#########################################
# This script shows how to use the AdafruitIna219 service
#
# config
port = "COM3"
# Code to be able to use this script with virtalArduino
if ('virtual' in globals() and virtual):
    virtualArduino = runtime.start("virtualArduino", "VirtualArduino")
    virtualArduino.connect(port)
# 
ina219 = runtime.start("AdafruitIna219","AdafruitIna219")
#
# This section shows is if you use the Arduino i2c pins
# Comment three lines if you don't use the Arduino
arduino = runtime.start("Arduino","Arduino")
arduino.connect(port)
ina219.attach(arduino,"1","0x40")
# 
# This section shows is if you use the GPIO i2c pins on the RaspBerry Pi directly
# Uncomment two lines if you use the RasPi
# raspi = runtime.start("RasPi","RasPi")
# 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"
Example configuration (from branch develop):
!!org.myrobotlab.service.config.ServiceConfig
listeners: null
peers: null
type: AdafruitIna219