THREE-CHANNEL CURRENT AND VOLTAGE I²C MONITOR
SwitchDoc Labs (SDL) has introduced a 3-channel current and voltage monitor PCB using a TI INA3221 chip. The PCB is nicely made and comes assembled with male headers and is fully labelled. If you are going to use it upside down on a breadboard, you can print a label for the underside to avoid mistakes when connecting up. A link to the specification in PDF is here.
Please see the note below regarding buying these as you could incur import duty and VAT.
The PCB as supplied will measure two voltages for each of three separate channels. Each pair of voltages comprises (1) the output bus voltage and (2) the voltage across the shunt that is proportional to the current through it. Using these voltages you can calculate the current and power drawn by the load. These voltage values are sent out on the I²C bus to a Raspberry Pi, Arduino or some other microprocessor. The PCB has three R10 (0.1Ω) shunt resistors on-board so that both current and voltage can be measured without any external components. From their physical size, these shunts appear to have a 0.1W rating; this means that their maximum current is 1A. You can calculate this from the power rating (P) and resistance (R) using this formula. If you need to use different shunt values or ones with high power ratings, then you will need to cut the links on the PCB and connect up slightly differently using your own external shunts.
The JP1 output header has the following pins. Unless you want to set up the alarm features, you can ignore the CRT, WRN, TC and PV connections.
|Pin Label||Connect To||What It Does|
|CRT||Critical alert||Refer to specification above|
|WRN||Warning alert||Refer to specification above|
|TC||Timing Control||Refer to specification above|
|PV||Power Valid||Refer to specification above|
|SDA||I²C serial data|
|SCL||I²C serial clock|
|VCC||3V3 or 5V supply for the PCB,||3V3 for Raspberry Pi, 5V for Arduino|
The JP2 input header has three pairs of pins; they are labelled INA1+, INA1-, INA2+, INA2-, INA3+, INA3-. Each channel uses the - pin to measure the absolute voltage supplied to the load and the voltage difference between the + and - pins to measure the voltage drop across a shunt that your program must then convert to measure the current flow. There are two options:
- Option 1: You can use the on-board 0.1Ω shunt
- Option 2: Cut the link to disable the on-board shunt and connect your own
If you're using option 2, the value of your shunt will depend upon the voltage drop that can be tolerated combined with the current flow expected. Remember that the heat to be dissipated will be I²R (Watts) so the shunt needs to have an appropriate rating and possibly a heat sink.
SDL has produced a Python library that you can use to communicate with the INA3221 PCB. The source code is available here and a test program is included. You can use the Python program as a starting point for your own program.
If you wish to program in C, then you'll need the wiringPi library. I wrote a C program that reads, decodes and converts the data from the device into volts and milliamps. This is still a work in progress and there are four projects that I want to complete:
- Build a power supply with three outputs (typically for running Raspberry Pis) with an LCD showing the current drawn by each.
- As 1 above but using an Arduino (Uno or Micro)
- As 1 above but with Internet access for switching the outputs, normal and fault indicators (probably using bi-colour LEDs), setting trip levels and
- displaying a mimic of the front panel (LCD and LEDs) using SVG via a web browser
Project 1 is complete. The power supply, SSRs and Pi are all fitted into a surplus Inmac box - photo to follow. The image here shows the LCD with the bus voltage, the current on each of the three outputs and the sum of these currents.
Project 2 is complete and measuring current and voltage using an Arduino Micro. The LCD is connected and working and the display is exactly the same as the Raspberry Pi version. Because I want to have the power supply web-enabled I'm not going to continue with the Arduino, but develop only the Pi version.
The software for Project 3 is complete and I have added a data logging feature that you can use to collect voltage and current data in a suitable format for importing into Excel. A graph of the current drawn by three different Pis is shown here. The indicator light for any output that draws excess current switches to red and the output is switched off. A button on the back of the unit will reset any outputs that have tripped. This project phase is complete.
Project 4 is underway and I have a good representation of the physical unit using SVG. Keeping the display up-to-date with current readings, without refreshing the whole HTML page, will require some AJAX and I will need to get out the book for that.
Considering what it does, the SDL INA3221 is reasonably priced at $15.95 (July 2015). SDL do not sell these themselves but distribute through Tindie who are based in the US. This means that you'll pay $10 for shipping to the UK and if your order value is over ¬£15 you'll pay duty and VAT on imports from outside the EU. So my order for three cost just over ¬£50.