 # How to Convert 4-20mA Current Loop to Voltage/Digital Conversion

Whats 4-20mA current Loop and How 4-20mA Current Loop Sensor Work and why 4-20mA is a standard. There are few reasons behind this.

1. 4-20mA current loop is a very old technique to read sensors and at that time the chips which are used to read pressures or any other data used to consume 3mA. This is a two-wire protocol so the current has to be greater than 3mA to make it work then the second question comes up in the mind, why they started with 4mA while they could have started with 5,10,20 or something else
1. in this protocol the values change linearly, so they have to have something like this 4-20mA or 5-25mA or 10-30mA or 10-40mA something to make calculation real easy.
2. The human body can take up to 30mA current above that it could damage the heart, so they had to keep it below 30mA.

So now we left with 2 choices either 4-20mA or 5-25mA. according to me, there could be two reasons.

a. in case of 5-25mA the 25mA was still really close to the max limit of 30mA, so they went with 4-20mA standard.

b. or the people who defined this protocol were real 420 friendly, so they made 4-20mA as an industry standard.

4-20mA current loop is one of the most used industrial sensors interface method. Using 4-20mA current loop sensors master can communicate to a device from a long distance without losing any data bits. There are devices which give 4-20mA current output and we can read the 4-20mA value and convert those values into real-world values.

This 4-20mA digital converter can be used with arduino, raspberry pi, windows, Linux and with all kinds of micro controller. To know how to interface this controller with arduino and real world devices checkout this article.

#### Interfacing 4-20mA digital converter with arduino Let’s say there are a 4-20mA current loop output pressure sensors, so when the pressure changes it will change the 4-20mA output and we can use a 4-20mA Current loop receiver to read the sensor output.

4-20mA output sensors are one of the most widely used sensors in industrial application. To read these sensors you will need to do a lot of data conversion.

in this tutorial, we will show you, how you can read any 4-20mA sensor and get the real world values.

Let’s say for an example you have a temp sensor which reads 0-500’F temp and its output is 4-20mA. It means when the temp is 0’F it will give 4mA output and when Temp is 500’F it will give 20mA output.

how to convert these 4-20mA values into real temp value we need to use few linear equation.

eq1 == find the slope.

This is a linear conversion and we have 4 known points, so we can use these 4 known points to calculate the slope of the 4-20mA linear curve.

m = (Y2-Y1)/(X2-X1)

here m is the curve slope

Y2 is the max output of the sensor. in our case its 500’F.

Y1 is the minimum output of the sensor. In our case its 0’F

X2 is the max current output of the sensor. In our case its 20mA

X1 is the minimum current output of the sensor. In our case its 4mA

now we have all the 4 known point we can calculate the slope of the curve.

m= 500-0/20-4

m = 31.25

Now we need to what will be temp when sensor current output is let’s say “x” mA

for that, we need to use this linear equation.

y = mx + c

where y is the final temp, x is the 4-20mA and c is a  linear constant.

to calculate the “c” we will need to use known y and x values

from the sensor datasheet we know that at 4mA sensor will give 0’F. so we can use these two values to calculate the linear constant.

y = mx + c

0 = 31.25*4 + c

c = -125

Now we have known linear constant, so we can use it calculate the sensor output using this equation.

y = mx + c

y = 31.25*x -125

We can test this equation like this, let’s say sensor output is 20mA then the temp will be according to this equation.

y = 31.25*20 – 125

y = 500’F

Microcontrollers and microprocessors have no direct way to read 4-20mA signal, so we need a device which can read the 4-20mA signal and convert it into the digital values which can be read by the microcontroller and computers.

Controleverything.com has a lot of devices which read 4-20mA signal and give digital output.

In this tutorial, I will explain how you can use controleverything.com’s 4-20mA signal reader board to read the 4-20mA sensors and calculate the real world values.

If you are using controleverything.com’s 4-20mA reader board using ADS1115 to read this sensor then you can use this equation to convert those 4-20mA values into real-world values.

First, we need to check what this board reads at 4mA and what it reads at 20mA.

For that, we will use professional loop simulator. this loop simulator will give us output from 4mA to 20mA output. When the loop simulator output was 4mA the ADS1115 will read 2130 ADC value and when the loop simulator is set at 20mA the ADS1115 will read around 10630.( ADS115 gain was set at two third)

Let’s say we have a sensor which gives 4-20mA output @ 0-500’F.

So when the temp is 0’F it will give 4mA or 2130 ADC and when the temp is 500’F it will give 20mA or 10630.

Using these values we can derive a formula to convert ADC values into the real world sensor values.

let’s find out the slope

eq1 == find slope

m = (Y2-Y1)/(X2-X1)

m = (Y2-Y1)/(X2-X1)

here m is the curve slope

Y2 is the max output of the sensor. in our case its 500’F.

Y1 is the minimum output of the sensor. In our case its 0’F

X2 is the max ADC output of the sensor. In our case its 10630

X1 is the minimum ADC output of the sensor. In our case its 2130

now we have all the 4 known point we can calculate the slope of the curve.

m = (500 – 0)/(10630-2130)

m = 0.0589

eq 2 ==

y = mx + c

0 = 0.059*2130 +c

c = 125.6

Now we can calculate the real temp based on these values

y = mx +c