[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. |
|
The current readings are stable but unrealistic. I'm testing a current of about 3 A, and the ESP with the current load shows 2732.02 A. |
|
Hmm sounds like a mixup of mA and uA somewhere. (or mV vs uV) |
|
Have you tested this yourself, or has anyone else done it? Maybe the problem is how I do it. |
It's not obvious from either the configuration or the documentation, but this plugin shows the Current values in
The actual current to measure doesn't have to match the capacity of the shunt, then only a part of the 75mV output is being used. |
|
Thanks for the replies. If the plugin is supposed to return measurement results in mA, then it's probably OK. Yesterday, I solved the problem with the formula, dividing the measured value by 1000. You've clarified my doubts about the measurement range selection field. I'll continue testing your results with other settings. |
|
Do you have other chips which are also supported by this plugin? Ton did move quite a lot of code around, so it is possible something got overlooked. |
|
I already have an INA228 at home, but I'm still waiting for the ESP32 from AliExpress. Testing would need to be done on the ESP32. For testing, I need to build a receiver with a more stable current source, preferably a resistor, because as you mentioned earlier, a UPS isn't the best receiver for such tests. But I can still test. |
|
Hello everyone. I started testing the INA228 plug-in today, still with a low voltage of around 14V and a very low current of around 0.2A. The voltage measurements are OK, but the current is significantly off. The value measured by the plug-in fluctuates between 1.86 and 5.37mA. If, as Ton wrote earlier, the plug-in returns a value in mA, this result is outrageous. The board has a standard shunt resistor of 0.002Ω, and I have the Max. Current set to the lowest range, which is 1A. I noticed another problem: in the Tools/Interfaces tab, there's an I2C Scan tool. The Supported Devices field should indicate which module was found on the bus, but it's blank. The same is true for the INA226, so it's probably the plug-in's fault. One more question: INA228 modules have GPIO alerts. Do you plan to support this feature in the plug-in? |
Hm, that's somewhat unexpected. I recently (today) received an INA228. I'll hook that up and see what results I can achieve.
Depending on the build, many known device names are included. For ESP8266 builds these names are not included for space reasons.
That's currently not planned. |
With our voltages, the discrepancies and instability in the reading are similar. It's possible that my INA228 board is of poor quality. How are your tests?
This is not a problem, the found module address is returned and if someone connects the module to the I2C bus, they probably know what they are connecting
this is also not a problem, similar functionality can be achieved using rules and e.g. the ESP GPIO port |
|
Hi, I am also desperately looking for INA226 integration, found this discussion here. Just ordered a ESP32-S3 with 16MB. Wanted to use the Max Firmware, since I have a couple of other sensors that need to be connected as well. However, I guess if I downlad the latest Release build from the Github Releases page, probably the P132 update for the INA 226 will not (yet) be in? |
|
This PR isn't merged yet, so the code isn't included in any of the available builds. |
|
You are right, no coding experience yet. So far I was always quite happy with the official builds. Guess I will have to wait. |
I started a GH Actions build for this: https://github.com/letscontrolit/ESPEasy/actions/runs/21550809663 |
|
@sracing |
|
What if you enable the device (and Submit the page)? NB: ESPEasy does not (in fact: shouldn't) communicate with the device until the plugin is enabled, and for auto-detection, it has to communicate with the device... 🤷♂️ |
|
Same view. No Device Settings. |
|
OK, for reasons whatever, I now managed the PASM version to boot after installation. With the Git Build "feature/P132-add-support-for-other-INA-chips_348c745". Plugin is enabled. I get the same view, no device setting. Plugin is enabled. The issue was that the I2C Adress was not yet configured in the Hardware tab (as this was a brand new board). Now Device Settings are visible. Thanks for all the support, I will start testing phase over the weekend and provide feedback. |
|
FYI N.B. If you try to use addressable LEDs, like NeoPixel LEDs, you should not run an OPI SPI PSRAM build even if you have a matching board, as this PSRAM OPI SPI mode does interfere with how we try to address those LEDs and you cannot use those LEDs. On those boards you need to run a non-PSRAM build. See: https://espeasy.readthedocs.io/en/latest/ESPEasy/ESPchips.html#quad-octal-spi-mode |
|
Thats helpfull information, thanks. I am running the Git Build "feature/P132-add-support-for-other-INA-chips_348c745" from tonhuisman (non PSRAM built) on my ESP32-S3-N16R8 PSRAM since a few days now. The P132 with a INA226 (Standard 0.1 Ohm shunt version, max 0,81A measurement range) works flawless so far. My focus in the application is on the current output for a range of 50mA to 230mA. I made some tests with various sampling and conversion rates, but the standard 1 sample avg. and 1.1 msec already provides stable output under lab conditions. Will continue to do some more tests under field conditions next week, but the additional support for additional INA versions (at least for the INA 226 which I use) is definitively an enrichment. |
|
Just to add on my last post. P132 with a INA226 still runs stable. No issues during configuration or operations. The Sensor is placed in a area with short, but very strong EMI. A first sensor immediately showed a non-linear behaviour. I suspect the calibration register being impacted by EMI. A second sensor placed in a larger distance has no issues. But thats not related to the Plugin. As said, happy to see the extended plugin in the master. |
|
Which part of your measurements is showing non-linear behavior? You may want to check if the shunt is getting warm and also if there may be other currents present. I think it is unlikely the I2C communication is disturbed, otherwise it would show up as highly 'unstable' readings (if any) If the shunt is getting warm and the heat is not equally distributed, you may create some offset in the readings of microVolts (or even more) due to the thermocouple effect. |
|
Appreciate the input. Actually voltage is not connected. Its the current measurement that shows stable, but non-linear outcome since it was placed close to a ignition wiring - before it was showing inconspicuous results. ESP & Sensor and the current to be measured are on different grounds. Not sure its getting warm, but as mentioned a new sensor now placed in bigger distance works fine since 1 week. |
|
It could be that the EMI disturbances wipe some settings/data in the sensor, but then I would expect it to mess with the calibration points which are just a 2-point calibration. The ADC itself is still linear. Or is this ignition wire 'firing' quite often, like from a "benzine" engine? |
|
The inition firing is not constant during operations, just when starting the device - probably 15 impulses over 3 seconds. I am suspecting the calibration settings in the sensor. I tried to re-install and re-configure the plugin, but the linearity only came back instantly with a new sensor. So it seems to me the first sensor got somehow impacted. |
…feature/P132-add-support-for-other-INA-chips




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:
(waiting for hardware to arrive)TODO:
(waiting for hardware to arrive)