INA219 Calibrate external shunt

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
boxhi
New user
Posts: 5
Joined: 27 Apr 2020, 01:17

INA219 Calibrate external shunt

#1 Post by boxhi » 27 Apr 2020, 20:44

Hello everybody

I am brand new here in the forum.
And find Espeasy a nice thing.

Unfortunately, I do not have to find any understandable solution to include a certain shunt over the INA219 in order to measure larger loads.
Unfortunately I haven't quite got that with the calibration of the new resistance value.
Have looked at the Adafruit_INA219 ut don't really understand it yet

My goal is to be able to measure in the range of 15-20A and 23-25V.

A little test:
Wemos with mega-20200410
INA219 /INA219B breakout board
12V / 5W lamp
Laboratory power supply read the following values : 11.30V 0.321A 3.61W

without an external shunt:
Screenshot_10.png
Screenshot_10.png (25.33 KiB) Viewed 15206 times
The values ​​are correct so far, when I get only 10.72V at the sensor

now with shunt:
Screenshot_12.png
Screenshot_12.png (12.01 KiB) Viewed 15206 times

My external resistance is a 50A 75mV shunt.


how do I have to calibrate this now and what does the formula look like, and where do I have to enter the values?

User avatar
ThomasB
Normal user
Posts: 1064
Joined: 17 Jun 2018, 20:41
Location: USA

Re: INA219 Calibrate external shunt

#2 Post by ThomasB » 28 Apr 2020, 04:10

Some basic concepts that may help out are discussed here: https://www.letscontrolit.com/forum/vie ... f=5&t=3334

- Thomas

boxhi
New user
Posts: 5
Joined: 27 Apr 2020, 01:17

Re: INA219 Calibrate external shunt

#3 Post by boxhi » 28 Apr 2020, 12:46

many thanks ThomasB I have already read this posts.

in my version (mega-20200410) i can also do that set measuring range.
Screenshot_14.png
Screenshot_14.png (4.17 KiB) Viewed 15158 times
it is possible to calibrate the resistance with my version EspEasy ? or do I have to use a sketch?
how do i do it


or can i do it with a formula? (https://www.letscontrolit.com/wiki/inde ... asyFormula)
Screenshot_15.png
Screenshot_15.png (8.68 KiB) Viewed 15158 times

Thanks a lot

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: INA219 Calibrate external shunt

#4 Post by TD-er » 28 Apr 2020, 13:24

This plugin does not seem to have a calibration option in the plugin, so you should then use the formula field.
For example if you need to apply a correction factor of 2, you fill in:

Code: Select all

%value%*2
Just make sure to calibrate voltage without any load (or else you will have a voltage drop over de cables from the power supply to the INA219).
The current must be calibrated separately.

The power output is computed based on the uncorrected voltage and current, so you must use both corrections in the formula field of the power.
For example voltage correction is x1.1 and current is x2.1. Then P = (U*1.1) x (I*2.1) => so the power correction is: %value%*1.1*2.1

Regarding the used setting for the INA219.
This setting changes a gain in the INA219.
The best gain is where you have the max. reading at the max. value you will encounter. (+ some margin)

boxhi
New user
Posts: 5
Joined: 27 Apr 2020, 01:17

Re: INA219 Calibrate external shunt

#5 Post by boxhi » 28 Apr 2020, 20:04

Thank you very much TD-er for your explanation.

I was able to calibrate the voltage across the formula field
The current field doesn't seem to work. Or I'm doing something wrong no matter what I enter the value goes to 0,000

boxhi
New user
Posts: 5
Joined: 27 Apr 2020, 01:17

Re: INA219 Calibrate external shunt

#6 Post by boxhi » 28 Apr 2020, 21:23

i test without shunt the formula field works. Can shift the decimal places, for example.

with shunt I always get 0,00000
can it be that the plugin does not count with 4 digits behind the decimal point?

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: INA219 Calibrate external shunt

#7 Post by TD-er » 29 Apr 2020, 01:50

I guess the shunt is then incorrectly wired or you simply are using the wrong A/D range for the current measurement.

A typical 50A shunt has a resistance of a few mOhm (75 mOhm typical)
So that means the voltage over the shunt is a few mV per amp current.
The shunt often has 2 terminals to connect the power lines and 2 smaller terminals to connect the current sensing lines.

I guess it would be best to show how you wired the shunt to the INA219.

Wiki
Normal user
Posts: 413
Joined: 23 Apr 2018, 17:55
Location: Germany

Re: INA219 Calibrate external shunt

#8 Post by Wiki » 29 Apr 2020, 11:21

...and don't forget to unsolder the R100 on the INA219 board.

Code: Select all

pi@raspberrypi:~ $ man woman
No manual entry for woman
pi@raspberrypi:~ $

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: INA219 Calibrate external shunt

#9 Post by TD-er » 29 Apr 2020, 11:31

Wiki wrote: 29 Apr 2020, 11:21 ...and don't forget to unsolder the R100 on the INA219 board.
That's for sure a good thing to do, but still if it is parallel to the big shunt there should be some reading.
The present shunt has a larger resistance, so it should make the total resistance a little less than it should be.
If it were the same value, the total resistance is halved.

boxhi
New user
Posts: 5
Joined: 27 Apr 2020, 01:17

Re: INA219 Calibrate external shunt

#10 Post by boxhi » 29 Apr 2020, 13:12

Hello friends

yesterday I connected it like this
Screenshot_16.png
Screenshot_16.png (118.31 KiB) Viewed 15075 times
now like this
Screenshot_17.png
Screenshot_17.png (114.31 KiB) Viewed 15075 times
Screenshot_18.png
Screenshot_18.png (12.56 KiB) Viewed 15075 times
the current field reacts like yesterday 0.0000 A
if i add or subtract it sets a fixed value (without sensor data)
if I multiply or differentiate I get 0.00000

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: INA219 Calibrate external shunt

#11 Post by TD-er » 29 Apr 2020, 13:25

You should not wire that shunt to Vin, but parallel to the existing big shunt.
Or like mentioned by Wiki, replace the existing shunt.

So that means soldering and not wiring it via a screw terminal on the INA219 board you have.

That's the only way you can use it, as the voltage drop over the shunt is very low.
So the ADC in the INA219 only expects a range of less than a volt.

See datasheet page 5: https://www.ti.com/lit/ds/symlink/ina21 ... 8159302471

Soldering on the existing shunt may be hard as it is probably connected to rather large PCB traces which have vias to the other side, also connected to big PCB traces.

CHL-6135
New user
Posts: 4
Joined: 05 Aug 2021, 02:02

Re: INA219 Calibrate external shunt

#12 Post by CHL-6135 » 05 Aug 2021, 02:22

Hello, i have to capture this thread and have a question. ESP Easy Beginner and not that great with english, so sorry in advance...

I want to measure DC current with my external Shunt 100A/75mV and a INA219 with the R100 (internal shunt) desolderd... The Shunt is connectet to the Pins on the INA219 Board.
The Board is a D1 Mini Clone flashed with the ESP Easy 20210802 normal esp8266 4m1m.

When i´m adding a new INA219 device on the website the only thing i can change is the "Measure range".

I already read some other threads, but something is missing for me, i´m stuck....

Do i have to change anything else? If i´m getting it right in my brain, the shunt resistance is different now, it changed from R100 (0.1Ohm) to 0,00075Ohm (75mV/100A=0,00075Ohm), so i have to change something somewere to get the right measured output value. But where and what? Or am i wrong and it works with the 32V 2A setting and i only have to fine adjust it with a formular?

Please help me, i´m starting to get confused...

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: INA219 Calibrate external shunt

#13 Post by TD-er » 05 Aug 2021, 21:47

Have you tried the "formula" field?

CHL-6135
New user
Posts: 4
Joined: 05 Aug 2021, 02:02

Re: INA219 Calibrate external shunt

#14 Post by CHL-6135 » 05 Aug 2021, 22:40

Not yet, i´m still in the Breadboard-Phase and theory... Can i just add a factor on the formular side and everything works out of the box with the Voltage up to 32V DC and a current over the external 100A/75mV Shunt with the desolderd R100 Onboard-Shunt? That would be great.

Thanks in advance

Andy

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: INA219 Calibrate external shunt

#15 Post by TD-er » 05 Aug 2021, 22:57

Yep, you can make quite complex formula if you want.
See here an example to convert from Celsius to Fahrenheit: https://espeasy.readthedocs.io/en/lates ... ula#values
Refer to the value in the formula with %value%

CHL-6135
New user
Posts: 4
Joined: 05 Aug 2021, 02:02

Re: INA219 Calibrate external shunt

#16 Post by CHL-6135 » 07 Aug 2021, 17:04

Alright, that sounds great.

I only have to make the formular fitting for my 100A/75mV Shunt instead of the SMD R100 0.1Ω original Shunt and i don´t have to change anything in the sources and the plugin ino´s?

If that is the case and when i get it right from your earlier Post on this thread:

viewtopic.php?p=29199#p29199

I get the shunt resistance of U/I = 0.075V/100A = 0.00075Ω = 0.75mΩ

The INA219 original Shunt is a R100 SMD Resistor with 0.1Ω = 100mΩ and the max. Current is 3.2A.

Max. Voltage for the Original Shunt is then R*I = 0.1Ω * 3.2A = 0.32V = 320mV.

For me it would mean that i have a expected range of U/R = 0.32V / 0.00075Ω = 426,66A

The Factor for my Formular would then be 0.1 / 0.00075 = 133.33

So in my Formular field i would insert %value%*133.33 and it would work with the original Resistor desolderd and the new Shunt connected?
One more.... is this then only for the Current formular field or does it also affect the Voltage and or Power ??

thanks and best regards

Andy

User avatar
Ath
Normal user
Posts: 3418
Joined: 10 Jun 2018, 12:06
Location: NL

Re: INA219 Calibrate external shunt

#17 Post by Ath » 07 Aug 2021, 17:13

I'm not such a math buff, but that does look quite plausible.

You could, of course, do a calibration, by using a calibrated amps meter in series with this one. Maybe it needs a small adjustment.

With a next release of ESPEasy (the PR is still pending), there is a change in the resolution of calculations in those formulas, where then the number of decimals set for the Value will be used. Currently that's fixed at 2 decimals for formulas, so that may now give somewhat less accurate results then expected.
/Ton (PayPal.me)

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: INA219 Calibrate external shunt

#18 Post by TD-er » 07 Aug 2021, 23:44

Yep, the formula is for that task value.
So the input (%value%) is from that task value and the output is also stored instead of what would otherwise be the %value%

Some examples I documented yesterday: https://espeasy.readthedocs.io/en/lates ... k-formulas

The formula part will indeed not have the full resolution mathematically speaking, which is fixed in the next build that will be made.
Also the more elaborate formula stuff documented there (using standard conversions and referring to other variables) is then also possible.
But just multiplying a factor is already possible for years, so that's no problem.

CHL-6135
New user
Posts: 4
Joined: 05 Aug 2021, 02:02

Re: INA219 Calibrate external shunt

#19 Post by CHL-6135 » 08 Aug 2021, 01:27

Thank you so much for sorting it out, getting it right and point me in the right direction. I thought i was on the right track, what i was, but i was unsure and had something in mind that was missing... That i only have to adjust it with a "multiplier" was too easy for me, that´s what got me confused...

I think i will wire it up tomorrow and test it with the Batteries...


@TD-er Thank you ;)

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 28 guests