Maker.io main logo

How to Use the INA219 Power Monitor with Atmosphere IoT Studio

140

2019-12-11 | By Maker.io Staff

Adafruit Feather

Up until now, we have looked at sensors focused on measuring the environment such as air pressure and temperature. In this how-to, we will look at something different — the INA219 Feather Wing power monitor sensor.

BOM

Scheme-It

How to Use the INA219 Power Monitor with DigiKey IoT Studio

Scheme-It

A Power Monitoring System

The INA219 sensor is an all-in-one power monitoring solution that has many IoT and smart device applications. The INA219 incorporates multiple sensors for measuring current, voltage, and power while utilizing an I2C bus for communication. One major advantage of the INA219 is that it uses high-side current sensing, meaning it does not affect ground planes on circuits (which can be very problematic on low-side current sensing circuits).

Typically, high-side sensing circuits require components with wide tolerances and large power supplies, but the INA219 is capable of running from the 3V provided by the Adafruit Huzzah32 while also measuring voltages up to 26V. The INA219 Feather Wing has a current sensing resistor of 0.1, which allows for a current sensing range of ±3.2A. However, this range can be altered (increased or decreased) by replacing the large SMD resistor with a different one. For example, if this resistor is replaced with a 0.01 resistor, then the total sensing current range is increased to ±32A, but the resolution of the sensor is decreased.

Integrating the INA219 Feather Wing

The INA219 provides power, current, and voltage readings that provide valuable information, as well as form the core of potential projects. For example, the INA219 could be integrated into a simple power supply for live monitoring of the voltage and current consumption. This could also be taken a step further by connecting the Huzzah32 to the cloud and plotting all of the data on a graph using the Atmosphere IoT Studio. Such a project could be useful in scenarios where a device under test needs to have its power consumption determined, and devices that include radio links often have pulses of current draw, which can be hard to predict.

The INA219 could also be used to measure battery health and status with the voltage indicating the charge level, while the current indicates short-circuits and potential sources of damage.

The Feather Wing Hardware

The INA219 Feather Wing comes with pin-headers and a screw terminal that need to be soldered. The best method for soldering the pin-headers is to use a breadboard with the headers inserted and then the board placed onto the headers. The pins can then be soldered into place and, once done, the feather board can be removed from the breadboard.

The INA219 has a screw terminal that connects to an external power supply for monitoring, but it is essential that this connector is used correctly. The positive terminal is connected to the incoming supply (such as the + of a battery) and the negative terminal connects to the load that is being powered. The negative terminal is not a ground connection and must never be connected to the power supplies negative terminal. If the negative terminal is connected to the negative terminal of the power supply, the power supply will short circuit through the shunt resistor and risk damaging the INA219 board.

The INA219 in this project is housed on its own breadboard, as well as the Adafruit Huzzah32. Therefore, for the two to be connected, jumper wires will be used to connect them together. It is also very important that all devices including the Huzzah32, the INA219, and the external power supply share the same ground (for reference purposes).

Atmosphere IoT Studio Software

Using the INA219 in the Atmosphere IoT Studio is very simple. With any device, the first task is to add it to our element toolbox, so we can interact with the INA219 element. To add the INA219, click the “Add Element” button at the bottom of the Element Toolbox. In the window that appears, search for “INA219.” The first entry should be the INA219 sensor, so add this by clicking the enable slide button.

How to Use the INA219 Power Monitor with DigiKey IoT Studio

Add the INA219 element to your project window as well as the interval element and two BLE GATT Characteristic elements. The interval element will be connected to the INA219 element, while the INA219 element will connect to the two Bluetooth elements. The interval, which triggers once every second, causes the INA219 element to read the current and bus voltage and these values are sent to their respective Bluetooth elements so it is easier to separate the values in the app.

The INA219 element has many options that can be changed, but if you are using the INA219 Feather Wing, then all of these options should be left unchanged. Some of the options that can be changed include:

  • I2C Address – This is the I2C address of the device, which should be left alone
  • Shunt Resistance – This is the value of the shunt resistor in milliohms. By default, this is 100mΩ
  • Gain – The gain of the internal amplifier, which should be left alone
  • ADC Resolution – This determines the smallest value that can be read

By default, the INA219 provides voltages in mV and current in mA. So, if the voltage from the INA219 is detected as 1000, then this corresponds to 1V (as it is 1000mV).

How to Use the INA219 Power Monitor with DigiKey IoT Studio

The app in this how-to is incredibly simple and consists of an interval connected to the two Bluetooth elements, which then send their data to two different labels. This example does not perform any data processing on the read values, so the numbers shown are absolute (in mV and mA). However, if the Bluetooth element is changed to float, then the numbers can be divided by 1000 to change the units of the values. For example, if readData is replaced with (readData/1000), then the result will be in V and A, respectively.

How to Use the INA219 Power Monitor with DigiKey IoT Studio

The INA219 is just one of many different sensors that takes advantage of the simple, but powerful, set of tools offered by the DK IoT Studio. We’ll continue to expand our library of knowledge with more sensors, more projects, and more blogs in the future!

制造商零件编号 3405
HUZZAH32 ESP32 FEATHER LOOSE HDR
Adafruit Industries LLC
制造商零件编号 3650
INA219 FEATHERWING
Adafruit Industries LLC
制造商零件编号 FIT0096
BREADBRD TERM STRIP 3.20X2.00"
DFRobot
制造商零件编号 12795
JUMPER WIRE M/M 6" 20COND
SparkFun Electronics
Add all DigiKey Parts to Cart
Have questions or comments? Continue the conversation on TechForum, DigiKey's online community and technical resource.