ina219 more Resolution

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
ingoiot
Normal user
Posts: 87
Joined: 15 Aug 2019, 22:09

ina219 more Resolution

#1 Post by ingoiot » 11 Feb 2025, 20:22

hi,

how to get the most resolution out of the ina219?

(and what are the options Hide/ Axis?

regards

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

Re: ina219 more Resolution

#2 Post by TD-er » 11 Feb 2025, 21:21

Hide and Axis are for the chart when you have 'stats' enabled.

Hide means the data from that variable will not be shown when you load the page.
However there will be a legend field of that value which you can click to show the data anyway.

Axis means on which axis to show the value.
You have L1 ... L4 and R1...R4 for "Left" and "Right" and the number indicates the axis count.

For example if you like to show free memory and system temperature, then it doesn't make sense to show those on the same scale/axis as the free memory is often in the order of 200k (on ESP32) and the temperature will be about 50-ish when it is about the system temperature.



The most resolution of any ADC is when you try to match the range as much as possible with the range of the expected values.
For example if your input voltage is between 0...1 Volt, it does not make sense to set the range to 5V.

So maybe you can use some resistors to map the analog input voltage to be within 80-ish % of the max. input range.
And if your voltage doesn't change much, you can also add some 100 nF capacitor over the input pin and GND as it will filter out the noise.

ingoiot
Normal user
Posts: 87
Joined: 15 Aug 2019, 22:09

Re: ina219 more Resolution

#3 Post by ingoiot » 11 Feb 2025, 22:27

tnx for the explanation,

i want to read 4-20mA

at 16V/0,4A setting it seems to have resolution of about 0,15mA

Maybe i've to change the shunt from 0,1 ohms to 1 ohm if there is no software option.

or maybe someone knows a better current sensor for 4-20mA.

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

Re: ina219 more Resolution

#4 Post by TD-er » 11 Feb 2025, 22:54

Keep an eye on the GND level between the ESP (and INA219) and the shunt resistor you're placing to measure the 4 ... 20 mA current.
The full scale current sense input voltage range when measuring current can be switched from 0 .. +/- 40mV (PGA = 1) to 0 .. +/- 320 mV (PGA = /8)

See page 5 of the datasheet: https://www.ti.com/lit/ds/symlink/ina21 ... 9260057625

Thus with a shunt resistor of 2 Ohm you can match the 20 mA to 40 mV.
Using an 1.8 Ohm resistor is perhaps the best as you will end up with 36 mV for 20 mA.

Maybe you will see less noise when aiming for a higher voltage range, so if you go for 0... 320 mV, a shunt of 16 Ohm would result in 320 mV for 20 mA.
So maybe go for 12 or 15 Ohm to get 240 mV, resp. 300 mV.

Then use the formula field to convert the value into whatever unit of measure you need.

ingoiot
Normal user
Posts: 87
Joined: 15 Aug 2019, 22:09

Re: ina219 more Resolution

#5 Post by ingoiot » 11 Feb 2025, 23:13

i have only 10 and 20 ohm resistors here,
so i'll try 10ohm.

will the ina219 get damaged when the wrong range is set in espeasy?

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

Re: ina219 more Resolution

#6 Post by TD-er » 12 Feb 2025, 00:17

Well the voltages on the analog inputs must not be lower than GND.
See note 2) on page 4 of the datasheet the "Absolute maximum ratings"
2) VIN+ and VIN– may have a differential voltage of –26 to 26 V; however, the voltage at these pins must not exceed the range –0.3 to 26 V.
So that's why I mentioned to take the GND level into account.

ingoiot
Normal user
Posts: 87
Joined: 15 Aug 2019, 22:09

Re: ina219 more Resolution

#7 Post by ingoiot » 12 Feb 2025, 22:21

tnx,

i don't know which setting correspondent to what gain/mV range.

I've used 10ohms and the 26V/8A settings
which gives me a reading in mA at about 0,01mA resolution and accuracy with a correction factor of 1,0089.



(note to myself: %value%*1.0089 - not %Current%* 1.089)
Last edited by ingoiot on 12 Feb 2025, 22:50, edited 1 time in total.

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

Re: ina219 more Resolution

#8 Post by TD-er » 12 Feb 2025, 22:46

Looked at the source and "26V/8A" seems to set the 'current gain' such that 320mV is full range.
So that should be the right setting indeed.

However most settings seem to set it.
- 32V/2A
- 32V/1A
- 26V/8A

So I guess there is some room for explaining which resistor/shunt values are assumed when using these presets in the docs :(

Post Reply

Who is online

Users browsing this forum: No registered users and 14 guests