#Thank you @sam blenny . I was looking
1 messages · Page 1 of 1 (latest)
Have you tried stripping your hardware and software setup down to the bare minimum to rule out stuff like supply voltage fluctuations, EMI, ground loops, and such from being connected to your full system? For example, if you just set up CircuitPython board and the INA228 with a load resistor, does it act the same way? Does anything change if you call time.sleep(2) at the start of your code before trying to initialize the I2C bus (I ask because I've had trouble in the past with sensors getting confused due to bus voltage brownouts after startup transients).
Interestingly, someone just submitted a PR for INA237/238 (not INA228): the power register was 3 bytes, not two. But your issue may be unrelated.
You could try using the Arduino library in the same setup and see what you get.
I tried running the INA228 setup on a Circuit Playground Bluefruit and measured about 15 A running and about twice that when the board does some LED and speaker control. Tried inserting a time.sleep(2) before I2C initialization did not change anything.
Thank you @tiny dust . I will see if I can do an Arduino test.
Also, @paper crag I forgot to mention that I tried to play with the calibration settings with ina228.set_calibration, but this function is not available in the library. Looks like a bug.
hmm... sounds like good odds there's something off with the CURRENT_LSB stuff
Yeah... I think I will poke around in the code and compare to the data sheet to see if there are any inconsistencies with the CURRENT_LSB and CURRENT calculations. I thought it looked ok when I looked at it before, but should probably give it another go. @tiny dust noting the INA237/238 issue with the power register has me wondering...
I would double-check the wiring, looking at https://learn.adafruit.com/adafruit-ina228-i2c-power-monitor/circuitpython-and-python. The example output shows reasonable current values.
Note print(f"Current: {ina228.current*1000:.2f} mA") so the current does look like amps, but it could be a small float.
I mean, we do write guides and test the code in the guides. Maybe your setup wasn't tested, or maybe there's a wiring issue.
I thought I followed the guide correctly to configure a high-side measurement. Here is a picture of the setup.
I can't really tell from the picture, sorry. Maybe take it apart and follow the pics again. https://learn.adafruit.com/adafruit-ina228-i2c-power-monitor/circuitpython-and-python#step-3192129
or try the Arduino lib and see if you get the same large result. If so, I suspect wiring
ok. I have Vin+ connected to the battery (4V; highest project voltage) and Vin- to the board (load's highest potential). Perhaps I have misunderstood.
do you have an ammeter (multimeter) you could insert in the circuit to measure the current yourself?
is the lower left board actually working?
the CPB is not connected to USB. How are you getting the measurement out?
Don't have an ammeter (that I trust). The board on the lower-left is a Pico2 on its side. It is the INA228 host.
do you have a multimeter at all?
Yes
so it should have amps and milliamps
they often have a separate 10A plug
vin- should be going to the +V at the battery plug on the CPB, is that right?
It does. I will give it a try. I am hoping, though, that I have understood the wiring instructions. I use a Pico2 to run the INA228, which is connected to a CPB powered by a battery. This is what is shown (poorly) in the picture.
why is the battery "-" connected to GND on the INA228
Yes, Vin- goes to the +V battery plug on the CPB.
it should not be, I think there should be nothing connected to the GND pin on the INA228 board. You should just tie the battery ground to the CPB ground
I thought that everything should be connected to a common ground.
Then that is the error. Let me tie the ground wires together and give it a try.
the INA228 is measuring current flow between the project voltage and the load. The project and load grounds are not used
If you're doing a high-side measurement, you want to insert the shunt resistor between the positive source and the positive input terminal.
if you were measuring the current with an ammeter, you would break the circuit on the high side (if doing high side) and insert the ammeter in series. Ground would not enter into that. Same here: the INA228 is just a fancy ammeter
I'm not sure what you were measuring, but maybe the battery was dumping a lot of current into something. it might have been getting hot
The ground wire fix (tie battery ground to CPB ground) did not change the measurement.
Nothing was getting hot when I was connecting everything to the INA228 ground.
so go ahead and try measuring the current with your multimeter.
the CPB is working OK, is that right? If you measure the voltage at the battery socket on the CPB, it looks reasonable, right? (only a little lower than the voltage at the battery)
you may want to wire all this up on a breadboard so you can convenient rewire things
I just suggested using the 10A range in case it really is high current. You don't want to blow a fuse on the multimer. That's a nuisance.
Checked the CPB voltage. Looks right (4V) and it is working properly.
also measure the voltage between Vin- and Vin+ on the board. It should be only a few mv
0.2mV between Vin- and Vin+
It is just a variation on the example that Liz Clark provided in the guide.
I am running out of steam so will have to try the current measurement tomorrow. Thanks for your help, as always.
no problem -- it's confusing. you're welcome!
I measured the current with an ammeter. Measured about 10 mA (not flashing LEDs or playing sound) to 30mA (flashing LEDs and playing sound). Note that this is remarkably consistent with my INA228 measurements above if the units are mA rather than Amps. Suggests a simple scaling issue with the adafruit_ina228 library.
Also tried using the Arduino INA228 library and sketch provided in the learn guide (used a PicoW for the host board). Measured about 15mA when the CPB is not flashing any LEDs or using the speaker and about 30-40mA when it flashes the LEDs and/or uses the speaker. Note that the Arduino sketch uses the function ina228.getCurrent_mA(), so exports current readings in mA by default.
I guess this all means that there is a bug in the adafruit_ina228 library?
kinda sounds like maybe the CircuitPython library followed the math from the Arduino library but Amps vs mA difference didn't make it across into the documentation.
Well, as best I can figure the CP library follows the logic provided in the INA228 technical document, but perhaps to your point the Arduino ina228.getCurrent_mA() logic was used in the ina228.current function. I have been looking over the CP code a bit but have not noted any errors, unfortunately.
do the values seem off by a factor of 1000, or is it perhaps more like 1024? Are you working with enough precision to tell the difference? In one case, you might have some math with a rogue multiplication by 1000, in the other you might have a shift by 10
I am not doing anything with the monitor point values read in each case. My suspicion is that there is a scaling error on the CP side, but I have not found it yet. Still digging, though.