This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

INA226: 4-20mA Current Sensing esp32 Arduino

Part Number: INA226
Other Parts Discussed in Thread: INA238, INA228, SYSCONFIG, INA240, INA190

Hello, 

I'm trying to get a 4-20 mA current to read through the INA226 but am not having success thus far. 

I do get readings, but they dont correlate with applying pressure on the sensor thats connected. 

Details: 

Shunt: .002 ohm 

Max expected amps: <1 as it will be in the 4-20 mA range. 

Sensor will be powered by a 12v source. 

I've used a current to voltage converter module that has worked fine to ensure the problem wasn't with the sensor. 

I think it has to be with the programming but not completely sure. 

So far I've turned off averaging, because right now I'm just looking for a range of values as I apply pressure to the sensor, to verify if anything works. 

Even though I'm using a small current - wondering if I need to set the max amps higher. I'm not sure if its max amps I expect, or a calculated value. 

Anyway - all help is appreciated, thanks! 

  • Hello,

    Thank you for using the TI forum.  For your question about the max expected current for the CALRIBRATION register calculation, the max expected current is a user chosen value for the maximum current you want to be able to measure (ie, the max current you plan to see). The reason you are not seeing the correct current value is because with your specific settings the value calculated that is needed to go into the CALIBRATION register is too large for the register size. To fix this, you will need to either raise the max expected current value (as you noted you may need to do, to about 2.6A) or raise the shunt resistor value (to about 26mΩ).  Changing either of these values will make the calculated value fit into the CALIBRATION register.  

    On a side note, if you are wanting to increase your accuracy, then you may want to consider switching to our newer line of current sensors which can better handle small current measurements.  The ones that you would want to consider that are pin compatible with the INA226 are the INA228 (20bit) or INA238 (16bit) 

  • Mitch, 

    Thanks for following up with me so fast. I do think I'm going to switch to one of the other recommended sensors on the next iteration, as this is just proof of concept. 

    So - after editing the max amp value to 2.6, I'm still seeing irregular values. 

    I've increased the BusConversion and ShuntConversion to 8.5, to hopefully smooth out some of these values but I should be sitting somewhere around 4.3mA  verified by my multimeter. Also - the current value is sitting around 1-2mA, which shouldn't be happening at all. 

    When I do vary the pressure on the sensor, I dont see any correlated change in the current readings, but can can see small changes via multimeter. 

    Still running through different checks, any and all help or things to try are appreciated. 

    Thanks again. 

  • Can you confirm from reading back the registers that the configuration register is set to 32264, and also confirm that you are using an LSB of 0.000079345703125 A?

    Also, could you send me a register dump for a known current value? 

  • I think I managed to get a register dump... Not sure - if you have a link to follow instructions on how to get it in a better way, it would be most appreciated. 

    Heres my current attempt at doing that. 

    CoolTerm Capture 2021-10-04 13-35-46.txt
    2021-10-04 13:35:54	65 74 73 20 4A 75 6E 20 20 38 20 32 30 31 36 20
    2021-10-04 13:35:54	30 30 3A 32 32 3A 35 37 0D 0A 0D 0A 72 73 74 3A
    2021-10-04 13:35:54	30 78 31 20 28 50 4F 57 45 52 4F 4E 5F 52 45 53
    2021-10-04 13:35:54	45 54 29 2C 62 6F 6F 74 3A 30 78 31 33 20 28 53
    2021-10-04 13:35:54	50 49 5F 46 41 53 54 5F 46 4C 41 53 48 5F 42 4F
    2021-10-04 13:35:54	4F 54 29 0D 0A 63 6F 6E 66 69 67 73 69 70 3A 20
    2021-10-04 13:35:54	30 2C 20 53 50 49 57 50 3A 30 78 65 65 0D 0A 63
    2021-10-04 13:35:54	6C 6B 5F 64 72 76 3A 30 78 30 30 2C 71 5F 64 72
    2021-10-04 13:35:54	76 3A 30 78 30 30 2C 64 5F 64 72 76 3A 30 78 30
    2021-10-04 13:35:54	30 2C 63 73 30 5F 64 72 76 3A 30 78 30 30 2C 68
    2021-10-04 13:35:54	64 5F 64 72 76 3A 30 78 30 30 2C 77 70 5F 64 72
    2021-10-04 13:35:54	76 3A 30 78 30 30 0D 0A 6D 6F 64 65 3A 44 49 4F
    2021-10-04 13:35:54	2C 20 63 6C 6F 63 6B 20 64 69 76 3A 31 0D 0A 6C
    2021-10-04 13:35:54	6F 61 64 3A 30 78 33 66 66 66 30 30 31 38 2C 6C
    2021-10-04 13:35:54	65 6E 3A 34 0D 0A 6C 6F 61 64 3A 30 78 33 66 66
    2021-10-04 13:35:54	66 30 30 31 63 2C 6C 65 6E 3A 31 32 31 36 0D 0A
    2021-10-04 13:35:54	68 6F 20 30 20 74 61 69 6C 20 31 32 20 72 6F 6F
    2021-10-04 13:35:54	6D 20 34 0D 0A 6C 6F 61 64 3A 30 78 34 30 30 37
    2021-10-04 13:35:54	38 30 30 30 2C 6C 65 6E 3A 31 30 39 34 34 0D 0A
    2021-10-04 13:35:54	6C 6F 61 64 3A 30 78 34 30 30 38 30 34 30 30 2C
    2021-10-04 13:35:54	6C 65 6E 3A 36 33 38 38 0D 0A 65 6E 74 72 79 20
    2021-10-04 13:35:54	30 78 34 30 30 38 30 36 62 34 0D 0A
    2021-10-04 13:35:54	0A 0A 44 69 73 70 6C 61 79 20 49 4E 41 20 52 65
    2021-10-04 13:35:54	61 64 69 6E 67 73 20 56 31 2E 30 2E 38 0A 20 2D
    2021-10-04 13:35:54	20 53 65 61 72 63 68 69 6E 67 20 26 20 49 6E 69
    2021-10-04 13:35:54	74 69 61 6C 69 7A 69 6E 67 20 49 4E 41 20 64 65
    2021-10-04 13:35:54	76 69 63 65 73 0A 20 2D 20 44 65 74 65 63 74 65
    2021-10-04 13:35:54	64 20 31 20 49 4E 41 20 64 65 76 69 63 65 73 20
    2021-10-04 13:35:54	6F 6E 20 74 68 65 20 49 32 43 20 62 75 73 0D 0A
    2021-10-04 13:35:54	41 66 74 65 72 20 53 65 74 75 70 20 42 75 73 20
    2021-10-04 13:35:54	44 6F 77 6E 6C 6F 61 64 41 FF FF FF FF FF FF FF
    2021-10-04 13:35:54	FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
    2021-10-04 13:35:54	FF FF FF FF FF FF FF FF 41 FF FF FF FF FF FF FF
    2021-10-04 13:35:54	FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
    2021-10-04 13:35:54	FF FF FF FF FF FF FF FF 41 FF FF FF FF FF FF FF
    2021-10-04 13:35:54	FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
    2021-10-04 13:35:54	FF FF FF FF FF FF FF FF 41 FF FF FF FF FF FF FF
    2021-10-04 13:35:54	FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
    2021-10-04 13:35:54	FF FF FF FF FF FF FF FF 41 FF FF FF FF FF FF FF
    2021-10-04 13:35:54	FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
    2021-10-04 13:35:54	FF FF FF FF FF FF FF FF 41 FF FF FF FF FF FF FF
    2021-10-04 13:35:54	FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
    2021-10-04 13:35:54	FF FF FF FF FF FF FF FF 41 FF FF FF FF FF FF FF
    2021-10-04 13:35:54	FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
    2021-10-04 13:35:54	FF FF FF FF FF FF FF FF 41 FF FF FF FF FF FF FF
    2021-10-04 13:35:54	FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
    2021-10-04 13:35:54	FF FF FF FF FF FF FF FF 50 72 6F 63 65 65 64 20
    2021-10-04 13:35:54	74 6F 20 4C 6F 6F 70 20 46 75 6E 63 74 69 6F 6E
    2021-10-04 13:35:54	20 41 66 74 65 72
    2021-10-04 13:35:54	20 42 75 73 20 44 6F 77 6E 6C 6F 61 64
    2021-10-04 13:35:59	4E 72 20 41 64 72 20 54 79 70 65 20 20 20 42 75
    2021-10-04 13:35:59	73 20 20 20 20 20 20 53 68 75 6E 74 20 20 20 20
    2021-10-04 13:35:59	20 20 20 42 75 73 20 20 20 20 20 20 20 20 20 42
    2021-10-04 13:35:59	75 73 0A 3D 3D 20 3D 3D 3D 20 3D 3D 3D 3D
    2021-10-04 13:35:59	3D 3D 20 3D 3D 3D 3D 3D 3D 3D 3D 20 3D 3D 3D 3D
    2021-10-04 13:35:59	3D 3D 3D 3D 3D 3D 3D 20 3D 3D 3D 3D 3D 3D 3D 3D
    2021-10-04 13:35:59	3D 3D 3D 20 3D 3D 3D 3D 3D 3D 3D 3D 3D 3D 3D 0A
    2021-10-04 13:35:59	20 31 20 20 36 34 20 49 4E 41 32 32 36 20 31 32
    2021-10-04 13:35:59	2E 30 36 33 30 56 20 20 20 20 30 2E 30 31 30 30
    2021-10-04 13:35:59	6D 56 20 20 20 20 31 2E 30 39 38 30 6D 41 20 20
    2021-10-04 13:35:59	20 31 32 2E 32 30 37 30 6D 57 0A 0D 0A
    2021-10-04 13:36:00	4C 6F 6F 70 20 69 74 65 72 61 74 69 6F 6E 20 31
    2021-10-04 13:36:00	0A 0A 41 66 74 65 72 20 46 69 72 73 74 20 4C 6F
    2021-10-04 13:36:00	6F 70 20 42 75 73 20 44 6F 77 6E 6C 6F 61 64 41
    2021-10-04 13:36:00	FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
    2021-10-04 13:36:00	FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 41
    2021-10-04 13:36:00	66 74 65 72 20 4C 6F 6F 70 20 2D 20 42 75 73 20
    2021-10-04 13:36:00	44 6F 77 6E 6C 6F 61 64
    2021-10-04 13:36:05	41 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
    2021-10-04 13:36:05	FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
    2021-10-04 13:36:05	41 66 74 65 72 20 4C 6F 6F 70 20 2D 20 42 75 73
    2021-10-04 13:36:05	20 44 6F 77 6E 6C 6F 61 64
    

    that correlates to this ascII output. 

    Theres a reading of registry values after setup - then after the first loop function. 

    Prior to that, a cleaner version is here: 

    But it didn't have any specific programming related to the INA226 in that script. Just checking to see if I could read anything for what the settings were left af on the past run. 

    CoolTerm Capture 2021-10-04 13-13-33.txt
    2021-10-04 13:13:38	11 54 64 8A 24 1D 38 1A B0
    2021-10-04 13:13:38	41 27 FF FF FF FF FF FF
    2021-10-04 13:13:39	FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
    2021-10-04 13:13:39	FF FF FF FF FF FF FF FF 41 27 FF FF FF FF FF FF
    2021-10-04 13:13:39	FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
    2021-10-04 13:13:39	FF FF FF FF FF FF FF FF 41 27 FF FF FF FF FF FF
    2021-10-04 13:13:39	FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
    2021-10-04 13:13:39	FF FF FF FF FF FF FF FF 41 27 FF FF
    2021-10-04 13:13:39	FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
    2021-10-04 13:13:39	FF FF FF FF FF FF FF FF FF FF FF FF 41 27 FF FF
    2021-10-04 13:13:39	FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
    2021-10-04 13:13:39	FF FF FF FF FF FF FF FF FF FF FF FF 41 27 FF FF
    2021-10-04 13:13:39	FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
    2021-10-04 13:13:39	FF FF FF FF FF FF FF FF FF FF FF FF
    2021-10-04 13:13:39	41 27 FF FF FF FF FF FF FF FF FF FF FF FF FF FF
    2021-10-04 13:13:39	FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
    2021-10-04 13:13:39	41 27 FF FF FF FF FF FF FF FF FF FF FF FF FF FF
    2021-10-04 13:13:39	FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
    

    That being said, - going through the programming to make sure its set to transmit the correct LSB and configuration register. 

  • Hello,

    That doesn't quite look like what I was expecting. To be more clear, could you send the value for each register (including id registers). For example, in the format:

    Register: value

    For example, the default values would be:

    0x00: 0x4127

    0x01: 0x0000

    0x02: 0x0000

    0x03: 0x0000

    0x04: 0x0000

    0x05: 0x0000

    0x06: 0x0000

    0x07: 0x0000

    0xFE: 0x5449

    0xFF: 0x2660

    This way I can go over all the values and settings for the device. 

  • took me a while to figure it out. 

    on the multimeter its holding steady at 4.4 mA. 

    The sensor has a constant pressure on it throughout this whole time. 

    Regarding your question above - "configuration register is set to 32264" I couldn't find a reference to that, but its on the continuous mode, no interrupts. Also why I included the binary output. 

    also using 2.6 Amps and .002 ohms. All the calculations are correct from what I can see. 

  • Ok, thank you, this is what I was looking for.  The value of 32264 (0x7E08) was what I was expecting you would put in your calibration register.  Looks like you put 32263 (0x7E07), which should be close enough. Using this to back calculate the CURRENT_LSB, we get: 0.00007934785977745406. If we convert the results register to values, we get:

    Shunt voltage register: 6 * 2.5 µV = 15 µA  

    Bus voltage register: 0x25B0 in decimal is 9648: 9648 * 1.25mV = 12.06 V

    Current register: 0x4F to decimal is 79: 79 * 0.00007934785977745406 = 6.268 mA

    If we look at the expected current, we get:

    I = V/R = 15 µA / 0.002 = 7.5 mA. 

    So, from this, it looks like everything is working fine according to the measured voltage at the input pins.  There is a small difference from expected current to measured, but this is just likely due to a minor delay in between register reads (as you are on continuous conversion).  However, that being said, I think the main problem here is the overall accuracy at such small currents with your specific setup. Funny enough, I just replied to a different thread with this exact same problem.  So, instead of showing all the examples here, I'll just link you to that other thread. Just note that your values will be a little different, but you can go to the product pages and put in your system specific values. Here is the other thread:

    https://e2e.ti.com/support/amplifiers-group/amplifiers/f/amplifiers-forum/1042026/ina226-ina226aidgst

    This info, combined with your system information, tells me that the INA226 really isn't the best part for your specific setup (in terms of accuracy), and I think it would be best to switch to the INA228 (which is pin compatible, so you don't even need new hardware).  Fortunately, we also have SysConfig which can help with the software update: https://dev.ti.com/sysconfig/index.html?product=ascstudio&module=/ti/sensors/currentsensor/INA228

  • Mitch, 

    I've replaced the sensor with the one referenced in the best case scenario on the linked post, also changed the IC out to INA228. Still testing to see how its working. 

    On a side note, would INA240 be an appropriate IC to use for a voltage output 4-20ma current sensor? shunt at 50-100mohm. With a 100mOhm shunt, looking at about 5% error.

  • Ok, sound good.

    Ya, the INA240 could work. Here is the webpage error tool data for those settings:

    So the INA240 could work relatively well.  With that said, if you want analog output, you'll have a little better accuracy for this setup with the INA190: