0

INA219 Sensor for Measuring Short-Circuit Current and Open C
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Re: INA219 Sensor for Measuring Short-Circuit Current and Op

by adafruit_support_bill on Mon Jan 21, 2019 8:53 am

Take a short-circuit reading with the shunt resistor in series. The I-V curve is generally quite steep at that point. So even small changes in the load may have significant impact on the current.

adafruit_support_bill
 
Posts: 72746
Joined: Sat Feb 07, 2009 10:11 am

Re: INA219 Sensor for Measuring Short-Circuit Current and Op

by MagicManBob on Fri Jan 25, 2019 2:56 am

I will give that a go and post the results so that if the current still varies between readings we can try and solve the issue. I will also try and change the code slightly to loop through the readings multiple times to get an average current value to avoid such large changes.

MagicManBob
 
Posts: 16
Joined: Sat Jan 05, 2019 4:57 am

Re: INA219 Sensor for Measuring Short-Circuit Current and Op

by MagicManBob on Wed Jan 30, 2019 11:43 am

I measured the current of the solar cell using the INA219 sensor and a multimeter. The results is as follows:

(INA219) No light shined on the solar cell: 0.1 mA
(INA219) Light shined on the solar cell: -0.5 mA

(Multimeter) No light shined on the solar cell: 0.14 mA
(Multimeter) Light shined on the solar cell: 0.7 mA

As you can see the value goes negative for the INA219 current value when light is shined on the solar cell. As have stated before that it could be a polarity issue so I added a negative to the current section of the code to get the above results:

current_mA = - ina219.getCurrent_mA();

If I take the negative away from the current code then I get the same results except the 0.1 mA get the negative and the 0.5 mA is positive.

Any suggestions as to why this could be? To clarify any other changes I made since my last post, I uncommented the following line of code:

ina219.setCalibration_16V_400mA();

This helped get close to the multimeter values, I am just confused with the negatives.

MagicManBob
 
Posts: 16
Joined: Sat Jan 05, 2019 4:57 am

Re: INA219 Sensor for Measuring Short-Circuit Current and Op

by adafruit_support_bill on Wed Jan 30, 2019 3:23 pm

Not sure what would be causing the negative readings if the panel polarity is correct. Try connecting a known power source and load: e.g. a 5v power supply and a 1K ohm resistor. That should give you a reading close to +5ma.

adafruit_support_bill
 
Posts: 72746
Joined: Sat Feb 07, 2009 10:11 am

Re: INA219 Sensor for Measuring Short-Circuit Current and Op

by MagicManBob on Sat Feb 16, 2019 3:44 am

So I connected a 1k resistor with a 1.5V battery, which should show a current of 1.5mA, which it does. So the INA219 is working as planned (this is without changing the code). Now when I attach the 6V solar cell again, I get the results as shown in the attached image. The voltage is measured when the MOSFET switch is closed and the current is measured when the circuit is open and then both values are displayed (it works perfectly for a resistor and battery as suggested in the previous reply). However, as you can see with the results from the solar cell, I get a voltage of 3.9V in room light and 0.4 mA. When I cover the solar cell with my hand the voltage drops as expected, but the current also drops and turns negative. I am stumped as to why this happens. Perhaps the properties of a solar cell IV curve allow for this to happen or perhaps the current is meant to go to zero but instead, the program doesn't just show zero and shows negative values instead?
Attachments
Screenshot (3).png
Screenshot (3).png (14.25 KiB) Viewed 171 times

MagicManBob
 
Posts: 16
Joined: Sat Jan 05, 2019 4:57 am

Re: INA219 Sensor for Measuring Short-Circuit Current and Op

by adafruit_support_bill on Sat Feb 16, 2019 8:16 am

Is this using the MOSFET for switching? The MOSFET is not a perfect switch. There will be a small Rds-on and some leakage through the device. Since we are trying to measure very small voltages and currents, these small 'imperfections' may be significant.

Do you get these same results with a physical switch (or jumper wire) to open or short the circuit?

adafruit_support_bill
 
Posts: 72746
Joined: Sat Feb 07, 2009 10:11 am

Re: INA219 Sensor for Measuring Short-Circuit Current and Op

by MagicManBob on Sat Feb 16, 2019 11:28 am

Yes, the voltage matches pretty close to the MOSFET switch when using a jumper wire as shown in the attachment to be around 3.9V as before. When measuring current by physically grounding the wire, the current is around 0.7mA and then decreases into the negatives yet again when covering the panel. The fact that the short-circuit current decreases into the negatives doesn't make sense. According to Ohms law, I=V/R...so the resistance of the panel essentially increases when covering it and the voltage decreases, which means current would become a small value right? Perhaps I should write some code that if the current is negative then just show 0mA?
Attachments
Screenshot (5).png
Screenshot (5).png (3.15 KiB) Viewed 159 times
Screenshot (4).png
Screenshot (4).png (4.56 KiB) Viewed 159 times

MagicManBob
 
Posts: 16
Joined: Sat Jan 05, 2019 4:57 am

Re: INA219 Sensor for Measuring Short-Circuit Current and Op

by adafruit_support_bill on Sun Feb 17, 2019 8:07 am

Not sure what is causing the small reverse current. Let me check with some of the other engineers to see if they have any ideas.

adafruit_support_bill
 
Posts: 72746
Joined: Sat Feb 07, 2009 10:11 am

Re: INA219 Sensor for Measuring Short-Circuit Current and Op

by adafruit2 on Sun Feb 17, 2019 1:08 pm

solar panels are Weird - but you can definitely monitor them, here's the project we did a couple yrs ago
https://learn.adafruit.com/portable-sol ... ng-tracker

adafruit2
Site Admin
 
Posts: 18321
Joined: Fri Mar 11, 2005 7:36 pm

Re: INA219 Sensor for Measuring Short-Circuit Current and Op

by MagicManBob on Sun Feb 17, 2019 2:01 pm

This does not, unfortunately, answer the questions I am having issues with. The project you have sent a link to describes a solar charger, which is very easy to measure using an INA219 module. My issue is measuring the "short-circuit" current of a small panel and not the current going to a battery. The open circuit voltage is quite accurate but when closing the MOSFET switch or simply using a jumper wire to ground the panel, the current goes negative when I cast a shadow over the panel. If someone could perhaps test this out using the code for the INA219 project on your side and using a small panel to see if the issue of negative polarity persists then that would be incredibly helpful. Perhaps my INA219 is just faulty if it works for someone else...

MagicManBob
 
Posts: 16
Joined: Sat Jan 05, 2019 4:57 am

Re: INA219 Sensor for Measuring Short-Circuit Current and Op

by adafruit_support_bill on Sun Feb 17, 2019 4:24 pm

If you short VIN- to VIN+ on the INA219, is the current reading 0?

adafruit_support_bill
 
Posts: 72746
Joined: Sat Feb 07, 2009 10:11 am

Re: INA219 Sensor for Measuring Short-Circuit Current and Op

by MagicManBob on Mon Feb 18, 2019 12:29 pm

No, the current reading is -0.20mA...does this mean I just add 20mA (in this case 0.2) to the current formula to calibrate the INA219 properly so that shorting the V+ and V- shows 0mA current?

MagicManBob
 
Posts: 16
Joined: Sat Jan 05, 2019 4:57 am

Re: INA219 Sensor for Measuring Short-Circuit Current and Op

by adafruit_support_bill on Mon Feb 18, 2019 12:37 pm

Sounds like there is a small zero offset error in the ADC on the INA219 which skews the current measurement by -0.2mA. Those kinds of errors are easy enough to address in calibration. A one-point calibration is probably sufficient for the measurements you are taking.

https://learn.adafruit.com/calibrating- ... -calibrate

adafruit_support_bill
 
Posts: 72746
Joined: Sat Feb 07, 2009 10:11 am

Re: INA219 Sensor for Measuring Short-Circuit Current and Op

by MagicManBob on Tue Feb 19, 2019 1:17 pm

Perfect! It works as expected now. How would I adjust the INA219 code to allow for a more accurate current measurement as the decimal places for the current only seems to show the current in increments of 0.1mA?

MagicManBob
 
Posts: 16
Joined: Sat Jan 05, 2019 4:57 am

Re: INA219 Sensor for Measuring Short-Circuit Current and Op

by adafruit_support_bill on Tue Feb 19, 2019 3:01 pm

Serial.print() takes an optional second parameter that specifies the number of decimal places to print for floating point numbers:
https://www.arduino.cc/en/serial/print

adafruit_support_bill
 
Posts: 72746
Joined: Sat Feb 07, 2009 10:11 am

Please be positive and constructive with your questions and comments.