This section illustrates various approaches to using the INA3221 to create a 3-channel current (and voltage) meter.
Overview
A current and voltage meter is a valuable tool for any lab. It clearly shows the current consumption of devices, and by summing up consumed currents, you can determine the total energy consumption in Ah or Wh. This is particularly useful for testing battery capacities or examining charge and discharge curves.
Multi-Channel Measurements
The INA3221 provides three independent channels, allowing measurement of three separate loads. All loads must share a common ground, but the channels can use different voltages (up to 26V).
Since the channels operate independently, you can leave unused channels disconnected if you only need one or two.
Exploring Solar Panel and Converter Efficiency With 3-Channel Current Meter
Three channels are ideal for exploring solar panel and converter efficiencies:
-
Channel #1: Solar Panel
Measures the raw power input from the solar cell. -
Channel #2: Solar Controller Output
Measures the power output from the solar controller. By comparing this data with Channel #1, you can calculate the solar controller efficiency. -
Channel #3: Charger
Measures the power output used to charge the buffer battery.
Steps For Implementation
Here are the basic steps for building the 3-Channel Current Meter:
- Hardware: Identify and gather the required components, then wire them up according to the INA3221’s specifications.
- Firmware: Develop the firmware for your microcontroller. You can either:
- Write custom firmware using C++ libraries.
- Use ESPHome, which natively supports the INA3221 sensor (documentation here).
1. Hardware
Let’s first assemble the hardware, regardless of how you plan to handle the firmware later.
Parts List
You will need the following components:
-
INA3221:
Ensure you are using a compatible version. Older boards may have a design flaw and are incompatible with the schematics and project guides here. Any board manufactured after 2023 is most likely fine. If uncertain, verify your board. -
Microcontroller:
Any microcontroller with an I2C interface is suitable. This example uses the ESP32-C3 SuperMini due to its compact size, making it ideal for integration into smaller devices. -
Power Connectors:
You need power connectors for the three channels, such as banana jacks. This example uses male and female XT60 connectors. -
Display (optional):
To view measured values directly, an OLED display is a great option. These displays, which use I2C (unlike TFTs that use SPI), are simple to connect and don’t require extra GPIOs or complex wiring. -
Wires:
You’ll need approximately 1 meter of two-pole red-and-black cable with sufficient thickness (AWG 24 or lower) and 2x two wires to connect the peripherals to I2C.
Schematics
Many modern microcontrollers allow arbitrary GPIOs to be assigned for I2C. For the ESP32-C3 used here, GPIO1 (SDA) and GPIO3 (SCL) are utilized. Other microcontrollers might have dedicated or commonly used I2C pins. For instance, ESP32S (classic versions) typically use GPIO21 (SDA) and GPIO22 (SCL). If you’re using a different microcontroller, adjust the schematic to match your I2C pin requirements, and ensure the correct pins are assigned to I2C in your firmware.
2. Firmware
After wiring up your hardware, it’s time to create and upload the firmware to your microcontroller.
Writing C++ Code
For maximum flexibility and control, you can write custom firmware using one of the many INA3221 libraries available for C++. While this gives you fine-grained control over functionality, it also requires more effort:
- You’ll need to manage all programming tasks yourself.
- Additional libraries may be required for features like display interfaces or web servers.
This approach is ideal for advanced users seeking complete customization.
ESPHome
A simpler, more accessible option is using ESPHome, which natively supports the INA3221. This method requires no programming expertise and includes features like:
- WiFi support
- OTA (over-the-air updates)
Additionally, ESPHome seamlessly integrates with Home Assistant, enabling automatic logging of measured values and triggering automations based on those readings.
Slow Website?
This website is very fast, and pages should appear instantly. If this site is slow for you, then your routing may be messed up, and this issue does not only affect done.land, but potentially a few other websites and downloads as well. Here are simple steps to speed up your Internet experience and fix issues with slow websites and downloads..
Comments
Please do leave comments below. I am using utteran.ce, an open-source and ad-free light-weight commenting system.
Here is how your comments are stored
Whenever you leave a comment, a new github issue is created on your behalf.
-
All comments become trackable issues in the Github Issues section, and I (and you) can follow up on them.
-
There is no third-party provider, no disrupting ads, and everything remains transparent inside github.
Github Users Yes, Spammers No
To keep spammers out and comments attributable, all you do is log in using your (free) github account and grant utteranc.es the permission to submit issues on your behalf.
If you don’t have a github account yet, go get yourself one - it’s free and simple.
If for any reason you do not feel comfortable with letting the commenting system submit issues for you, then visit Github Issues directly, i.e. by clicking the red button Submit Issue at the bottom of each page, and submit your issue manually. You control everything.
Discussions
For chit-chat and quick questions, feel free to visit and participate in Discussions. They work much like classic forums or bulletin boards. Just keep in mind: your valued input isn’t equally well trackable there.
(content created Jan 07, 2025)