Projects / 4–20 mA sensor reader

4–20 mA sensor reader

Intermediate2 hGuided buildReviewed

Build it step by step

0 of 6 done
  1. NANO

    Wire the simulator

    Build the 12 V, resistor and potentiometer loop with the 150 Ω shunt to ground.

  2. NANO

    Measure with a meter

    Put your multimeter in series on the mA range and set the pot to 4 mA, then 12 mA, then 20 mA.

  3. NANOADS1115

    Wire the ADS1115

    Connect A0 to the top of the shunt and the grounds together.

  4. NANOHelloPCF8574

    Upload and compare

    The LCD mA reading should match the meter.

  5. NANO

    Check the scale

    At 4 mA the value should be 0 and at 20 mA it should be 100.

  6. NANO

    Test a break

    Turn the pot to its far end so the current falls under 3.8 mA and see LOOP BROKEN.

In short

How do you build a 4–20 mA sensor reader?

Read a 4–20 mA current loop with a shunt resistor and show the value in percent, with a broken-loop alarm. Practise first with a safe bench simulator. You need Arduino Nano, ADS1115 16-bit ADC module, Resistor 150 Ω, Resistor 330 Ω, Potentiometer 10 kΩ, 12 V 2 A DC adapter and 16x2 LCD with I2C backpack (PCF8574). It takes 6 steps and about 120 minutes.

Level
Intermediate
Time
About 120 min
Parts
7

Parts list

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
ADS1115 VDD, GNDNano 5V, GNDPower
ADS1115 SDA, SCLNano A4, A5I2C
LCD SDA, SCL, VCC, GNDNano A4, A5, 5V, GNDI2C display
12 V adapter +330 Ω resistorLoop supply, current-limited simulator
330 Ω resistor10 kΩ potentiometer (two outer pins)Simulated transmitter, sets current
Potentiometer wiper and one endJoined, then to the 150 Ω shunt top and ADS1115 A0Loop current through the shunt
150 Ω shunt bottom12 V adapter - and Nano GNDCommon ground, shunt voltage read at A0

Code

Arduino IDE, board "Arduino Nano" (processor ATmega328P, or ATmega328P (Old Bootloader) for clones). Install "Adafruit ADS1X15" and "LiquidCrystal I2C". The potentiometer circuit only simulates a transmitter: with the 12 V adapter, 330 Ω and the pot, the current ranges from about 25 mA down to under 1 mA, so you can turn it through 4 mA, 20 mA and a broken loop. Do not connect a real 4–20 mA transmitter or any equipment on a plant until you understand its supply and grounds: real loops usually run on 24 V and may be earthed elsewhere. With a 150 Ω shunt, 20 mA gives 3 V, inside the ADS1115's 4.096 V range.

Runs on a virtual Arduino Nano in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).

#include <Wire.h>
#include <Adafruit_ADS1X15.h>
#include <LiquidCrystal_I2C.h>

Adafruit_ADS1115 ads;
LiquidCrystal_I2C lcd(0x27, 16, 2);
const float SHUNT_OHMS = 150.0;
const float RANGE_LOW = 0.0, RANGE_HIGH = 100.0;      // the sensor's engineering range, e.g. 0 to 100 %

void setup() {
  ads.setGain(GAIN_ONE);                               // +/-4.096 V range
  ads.begin();
  lcd.init(); lcd.backlight();
}

void loop() {
  int16_t raw = ads.readADC_SingleEnded(0);
  float volts = ads.computeVolts(raw);
  float mA = volts / SHUNT_OHMS * 1000.0;
  lcd.setCursor(0, 0);
  if (mA < 3.8) {
    lcd.print("LOOP BROKEN     ");
  } else {
    float value = RANGE_LOW + (mA - 4.0) / 16.0 * (RANGE_HIGH - RANGE_LOW);
    lcd.print(value, 1); lcd.print("          ");
  }
  lcd.setCursor(0, 1);
  lcd.print(mA, 2); lcd.print(" mA     ");
  delay(300);
}

Test checklist

What you should see at each check. If a reading is far off, stop and use the troubleshooting list.

CheckExpected
4 mA0.0 on the display
12 mAAbout 50.0
20 mAAbout 100.0
Under 3.8 mALOOP BROKEN

If it does not work

Always 0 mA

Check the shunt is in the current path and A0 is on its top side.

Reading too high or low

Measure the shunt's actual resistance and put it in the code.

LCD blank

Check I2C address 0x27 or 0x3F and the contrast screw.

ADS1115 not found

Check the I2C wires and VDD.

Still stuck? Find the fault step by step with your multimeter →

Ask Lark AI

Common questions

What parts do I need for the 4–20 mA sensor reader?

Arduino Nano, ADS1115 16-bit ADC module, Resistor 150 Ω, Resistor 330 Ω, Potentiometer 10 kΩ, 12 V 2 A DC adapter and 16x2 LCD with I2C backpack (PCF8574).

How long does the 4–20 mA sensor reader take to build?

About 120 minutes for a intermediate maker, in 6 steps.

How do I know the 4–20 mA sensor reader works?

4 mA: 0.0 on the display. 12 mA: About 50.0. 20 mA: About 100.0.

Always 0 mA: what should I check?

Check the shunt is in the current path and A0 is on its top side.

Reading too high or low: what should I check?

Measure the shunt's actual resistance and put it in the code.

LCD blank: what should I check?

Check I2C address 0x27 or 0x3F and the contrast screw.

ADS1115 not found: what should I check?

Check the I2C wires and VDD.