-
Notifications
You must be signed in to change notification settings - Fork 2.2k
[P132] Additional support for INA226, INA228, INA230, INA231 and INA260 #5462
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: mega
Are you sure you want to change the base?
[P132] Additional support for INA226, INA228, INA230, INA231 and INA260 #5462
Conversation
|
Great job, thank you very much, I'm interested in INA228 support myself. Will there be binaries available for download for the ESP32? |
Assuming you mean ESP32-Classic, here are the builds that this plugin is included in: ESP_Easy_mega_20251228_energy_ESP32_4M316k-2.zip for ESP32 with 4MB Flash Both include the OTA Edit: Re-uploaded the zip files (appended NB: Possibly the INA228 Power setting might not return the expected result, as the code shows a TODO there... 🤔 |
|
Thanks for the binaries. I loaded the 4M316k.factory module, and it boots up, but I doubt it will work correctly. There's no option to select the shunt value. Without checking the documentation, I'm not entirely sure if all the INA3221/INA226/INA228/INA231/INA260 models have the same registers. At first glance, the INA3221 is a 3-channel model, while the others aren't. So how would this work without selecting the INA model in the plugin? |
Not sure what/how you installed the binary, but the P132 plugin ("Energy (DC) - INA3221/INA226/INA228/INA231/INA260") should show an |
|
Ah, this is a phenomenon we sometimes see when some other firmware (ESPHome, Espruna, Tasmota?) has been used on the esp, and the flash hasn't been wiped before installing ESPEasy. It tries to re-use an existing file system, but if that's too small it fails in writing the configuration file(s), causing weird behavior and/or crashed like you have shown. |
|
Thank you again for your involvement and willingness to help. It's possible this is a hardware issue with my ESP32; none of the methods I know of for clearing the memory have yielded positive results. Since I only have one ESP32 board (I have many, but they're ESP8266s), I've ordered another ESP32, but it will probably take some time for them to arrive. |
I've built you a Custom Energy build with this feature enabled for ESP8266 with 4MB Flash: |
|
Another huge thank you. The ESP8266 binary is better. Almost everything seems to work, but there's a problem with reading data. Admittedly, I've been experimenting with the INA226 for a while now. I have a question: instead of selecting the internal resistor value, there should be an option to select a shunt, e.g., 30A (75mV), etc., because these built-in resistors are intended for small pads. |
|
Selecting a different shunt resistor is mostly a wiring issue, finding the right shunt value (for 30A the 2 mOhm setting should be just right for an INA226), find a 0.002 Ohm resistor that can handle the power dissipation, remove the existing shunt from the board and wire the new shunt to the board. |
|
I don't care about such currents, but this connector allows you to select a current in the range [1-1022 A], but there's still no option to change the shunt, and that's where I see a lack of consistency. A while ago, a similar build for the ESP8266 and INA226 was posted on the forum, with the option to change the shunt to an external one. Again, I don't care about that. |
|
I was referring to shunts like these, of course, for larger currents. Because looking for a resistor for, say, 50A is a bad idea. |
|
Those shunts are for 75mV. Some of the INA chips, like INA219 and INA228, can handle higher shunt voltages, up to 320mV for INA219, and 160mV (fixed) for INA228. But that would still work fine, would just be a resolution-related issue. |
Well, I can limit that max. value to, say, 30A, I just added the max current setting as it is required for the new library I'm using. |
|
These currents don't bother me at all, so they can stay as they are. |
|
I've changed the resolution for the Shunt setting, and added more options for high-current shunts, to better match those to the Max. current setting. |
|
I don't have a shunt at home because I don't measure such high currents. I downloaded your binary; in my opinion, it offers much more options. I'll get myself a shunt, let's say the smallest one, and run some tests. Thanks again. |
|
I've made a few minor adjustments, and built a fresh 2026 build: 😉 |
|
I have a 30A 75mV shunt and an INA226. Either I'm configuring something incorrectly or there's something wrong with the binary. Voltage is OK, but current measurement is a gamble in my opinion. |
|
How is it connected? |
|
If the INA226 is installed on a board, any on-board/other shunt resistors have to be disconnected (or removed), and only the external shunt should be connected. |
Still, even if there is an existing shunt (in parallel), then the reported current should show a correlation to the actual current. Only lower. |
|
It's connected correctly. The original shunt resistor from the board has been removed. I loaded a binary I found on the forum that supports the INA226, and it works fine. |
|
Do you have a link to that binary? |
|
#2622 This is an old link from November 18, 2021. Your request for the source code is also in this thread. |
|
I have used the Zanduino INA library for adding support for the extra INAxxx models, though I haven't compared notes with the wollewald (INA226 explicit) library, as it is quite different. What did you use for |
|
Averaging samples: I tested probably all of them from this list, the closest current readings gave a value of 16. Conversion rate Current: I also tested all values from the selection list, here the closest current consumption readings give a value of 1. Despite all this, the current measurement is unstable and significantly different from the actual one. |
|
Where do you have the shunt? At the GND level or at the + side? In the datasheet on page 14, there is some suggestion of filtering. I'm discussing the code with Ton (via Signal) right now and we already found a few things that can be improved in the code. |
|
Also what current are you trying to measure? I noticed a few places in the code of the library where quite a bit of resolution is lost due to careless calculations or completely illogical stripping of bits. |
|
I can't reach the home-garden.org site from my location (time-out), not sure if it still is available, or blocked for some reason, so there is no source-code available for comparison. |
|
Ok. I'll check with the filtering system. Another question: Has anyone else tested the INA226 with your input? |
|
I tested with the on-board shunt and a quite low current. Haven't payed much attention to stable output, other than it stayed constant, as was to be expected, and changed when I changed the 'load'. |
|
I'm personally not a fan of measuring current on the 'high side', but it should work as the voltage doesn't exceed the max. input of the INA226. There are lots of reasons why the other binary file yielded more stable results. Apart from this, there are still some parts of the code that can be optimized as quite a lot of resolution can be lost how it is done right now. |





Resolves #2622
Resolves #2602
Forum request: https://www.letscontrolit.com/forum/viewtopic.php?t=10746
Forum request: https://www.letscontrolit.com/forum/viewtopic.php?p=74843
Features:
TODO: