All I do is use a resistor. 0 to 20 mA through a 250 Ohm precision resistor gives me 0 to 5 volts. If you want input protection for your uC place a resistor in series with the input. A Google of "Arduino Analog Input Protection" should give you some ideas. Anyway, as to current to voltage you can do as I suggest and use a simple 250 ohm resistor or get more complex depending on your exact application.
But... OP wants "+-20mA", which sounds like charging/discharging something, like solar/battery.
Not wise to use 250 ohm for a 0-20mA sensor anyway, because that would use the potentially unstable MCU supply as reference. There are plenty of posts using a 51 ohm resistor and the more stable internal 1.1volt Aref.
Leo..
Wawa:
But... OP wants "+-20mA", which sounds like charging/discharging something, like solar/battery.
Not wise to use 250 ohm for a 0-20mA sensor anyway, because that would use the potentially unstable MCU supply as reference. There are plenty of posts using a 51 ohm resistor and the more stable internal 1.1volt Aref.
Leo..
Ah, I see the +/- now that you mentioned it.
I guess years of just putting a resistor in the loop has spoiled me. Also yes as to using 51 ohms and a 1.1 volt ref in the Arduino. So what the thread starter really has is -20 to 20 mA loop. Thanks again for catching my not reading enough into a post.
If the OP can find a "polar relay", the output could be used as a spst switch to connect a pin to ground or not. Such relays used to be common when teletype machines were in use.
im working with hydraulic valves, which have a signal input of +-20mA (picture of the valve documentation attached).
therefore i could use 2x INA219 for "D" and "E" cable (see picture).
now i wanted to try the INA219 with a simple led as load, but it gets hot immediately even when i connect the GND and 3,3V supply of the Arduino. This looks very strange to me ( i tried 2 different INA´s with same result).
i also measured the resistance between GND and VCC of INA219. The result is 30ohms?!
Somebody has experience with INA219?
I didnt wired SDA, SCL, Vin+ Vin- cause it gets hot too much.
You think these parts are damage or is this caused of my fault?
So you are trying to measure the input rated command to your valves as I read it. What you have looks to be a servo valve. What I see in the image is -10 mA to 10 mA so a span of 20 mA but not +/- 20 ma which would be a 40 mA span. A current command which is mid point in the span, in this case 0.0 mA would be a valve spool which is centered.
The INA219 is a current shunt and power monitor. The two analog inputs to the INA219, IN+ and IN–, connect to a shunt resistor in the bus of interest. Have you selected a shunt? Have you programmed the PGA (Programmable Gain Amplifier) of your INA219? If things are set up correctly per the data sheet the chip should not be getting hot.
Additionally your valve body has a 4 to 20 mA current loop out which sends back the valve spool position. Did you plan on using that signal so you can command the valve to a position and know if it is where you command it to?
Seems better to read the actual position/result. The 4-20mA current loop.
Best done with a 51 ohm resistor with some surrounding protection parts and 1.1volt Aref.
Many threads about that on this site.
Do a search for "4-20mA" in the looking glass search field on top of this page.
Leo..