4-20mA Current Loop Sensors for Makers: Wiring, Loop Power, and Reading Them with an ESP32 or Raspberry Pi
Most maker sensor wiring assumes a voltage signal — an analog voltage that droops with wire resistance and picks up noise over any real distance. Industrial process instrumentation solved this problem decades ago with the 4-20mA current loop, a signaling standard that's immune to voltage drop over long cable runs and inherently resistant to a whole class of noise problems that plague voltage-based analog sensing. This site already covers Modbus RTU and PLC basics for makers working with industrial-adjacent equipment; 4-20mA loops are the other extremely common industrial signaling standard worth understanding, and they show up more often than expected on surplus and used industrial sensors — pressure transducers, flow meters, level sensors, and temperature transmitters — that are cheap and plentiful on the used market but assume a current-loop receiver that most maker projects don't have.
Why Current Instead of Voltage?
A voltage signal sent down a long cable run drops in proportion to the cable's resistance and the current drawn — a sensor reading calibrated for 0-5V at the source can measure meaningfully lower at the far end of 100 feet of thin wire, and that error scales with cable length and gauge. A current loop sidesteps this entirely: in a series current loop, the same current flows through every point in the circuit regardless of wire resistance (within the loop's voltage compliance budget), so a receiver measuring that current at the far end of a long cable run sees exactly the same value the transmitter sent, with no cable-length-dependent error. The 4mA "live zero" baseline (rather than starting the scale at 0mA) is a deliberate design choice too — it lets a receiver distinguish a genuine "sensor reading zero" condition (4mA) from a broken wire or disconnected sensor (0mA), which a 0-20mA or 0-5V scale can't do on its own.
Two-Wire (Loop-Powered) vs Four-Wire Transmitters
TypeWiringNotes Two-wire (loop-powered)Same two wires carry both the DC supply voltage to the sensor and the 4-20mA return signalThe most common industrial transmitter format; the sensor itself draws its operating power from the loop's own supply current, so the loop power supply (commonly 24VDC in industrial settings) has to be sized to actually power the sensor electronics as well as drive the loop Four-wireSeparate pair for sensor power, separate pair for the 4-20mA signalUsed when the sensor needs more power than a loop can practically supply, or when the sensor and signal need to be electrically isolated from each otherMost cheap surplus and used sensors a maker is likely to find — pressure transducers, industrial temperature transmitters, and level sensors — are loop-powered two-wire devices, which simplifies wiring but means the power supply and the receiving circuit share the same two conductors.
Reading a 4-20mA Loop With a Microcontroller
An ESP32 or Raspberry Pi's ADC reads voltage, not current, so a current loop needs to be converted to a voltage the ADC can measure before it's useful — and that conversion needs to happen without disrupting the loop's actual current value.
- Insert a precision shunt resistor in series with the loop. A common choice is a 250Ω 0.1% precision resistor, which converts the 4-20mA range into a clean 1-5V range (I × R) that maps well onto a 3.3V-referenced ADC after appropriate scaling, or a lower-value resistor (100Ω giving 0.4-2V) to stay comfortably within an ESP32 ADC's usable input range without needing extra scaling.
- Buffer or scale the voltage across the shunt before feeding it to the ADC. A simple voltage divider can bring the shunt voltage into range for a 3.3V ADC, but a dedicated instrumentation amplifier or even a simple op-amp buffer (covered in this site's op-amp guide) gives cleaner, more accurate results than a passive divider alone, especially if the ADC's input impedance would otherwise load down the measurement.
- Calibrate against the sensor's actual documented range, not just the loop's electrical range. The 4-20mA loop is just the transport — the actual physical quantity it represents (say, 0-100 PSI, or -40°C to 150°C) is defined by the specific transmitter's datasheet, and 4mA = the low end of that physical range while 20mA = the high end, linearly in between for most transmitters.
- For a dedicated, more robust solution, use a purpose-built 4-20mA-to-digital IC or module (several breakout boards built around ICs like the RCV420 or similar current-loop receiver chips exist specifically to handle this conversion cleanly, including isolation in some cases) rather than building the shunt-and-divider approach from scratch for anything beyond a quick prototype.
Powering a Loop-Powered Sensor From a Microcontroller Project
A loop-powered transmitter needs its supply voltage (commonly 12-36VDC depending on the specific sensor's datasheet) applied across the loop, with the microcontroller's shunt resistor and ADC input measuring the resulting current — the microcontroller doesn't supply the loop power directly from its own logic-level rails. A separate DC supply (following the same buck/boost converter principles covered elsewhere on this site) sized to the sensor's voltage and current requirements, wired in series with the shunt resistor and the sensor, is the standard topology: supply positive → sensor → shunt resistor → supply negative, with the microcontroller's ADC reading the voltage across the shunt.
Practical Uses for Makers
- Repurposing surplus industrial sensors. Pressure transducers, level sensors, and process temperature transmitters pulled from decommissioned industrial equipment are common on the surplus market at a fraction of new cost, and understanding 4-20mA wiring is what makes them usable rather than a mystery box with two wires and no obvious way to read them.
- Long-cable-run sensing where voltage sensing isn't reliable. A remote tank level sensor, a well pump pressure sensor, or any sensor placed a genuine distance from the control electronics benefits from current-loop transmission's immunity to cable-length-dependent error.
- Interfacing with existing industrial equipment. A maker project that needs to read a signal from an existing PLC-connected sensor, or feed a signal into industrial equipment expecting a standard 4-20mA input, needs to speak this signaling standard rather than trying to adapt the industrial side to a voltage-based hobby sensor interface.
Practical Notes
- Always verify the loop's supply voltage and current requirements against the sensor's actual datasheet before powering it — industrial sensors vary widely in voltage compliance requirements, and under-supplying voltage can prevent the loop from reaching the full 20mA at the sensor's maximum reading.
- A shunt resistor's tolerance directly affects measurement accuracy — a cheap 5% resistor introduces meaningfully more error into the final reading than a 0.1% precision resistor, and this is a case where the few extra cents for precision genuinely matters.
- Isolate the loop electrically from the microcontroller's own power domain where the sensor and microcontroller might otherwise share a noisy or mismatched ground reference — the optocoupler and digital isolation techniques covered elsewhere on this site apply directly here for a genuinely clean signal path.
4-20mA current loops are unglamorous compared to most of the wireless, I2C, and modern sensor content covered on this site, but they're a genuinely useful skill for the maker who wants access to the enormous world of cheap, robust, long-cable-run-capable industrial sensors that this signaling standard opens up — sensors that would otherwise sit unused in a parts bin for lack of an obvious way to read them.
Related Guides
- RS-485 and Modbus RTU for Makers: Wiring, Termination, and Reading Industrial Sensors
- I2C Wiring and Protocol Guide for Arduino, ESP32, and Raspberry Pi
- Tying It Together: Pi + ESP32 + Flipper Home Automation Hub
- MQTT and Node-RED on Raspberry Pi: Visual Automation for ESP32 Sensor Networks
- Homebridge on Raspberry Pi: Bringing Non-HomeKit Devices and DIY ESP32 Sensors into Apple Home
- FANUC Robot to AutomationDirect Productivity PLC: EtherNet/IP UOP I/O, Custom DI/DO, and Turck Safety Block Cell Integration
- Power over Ethernet for Maker Electronics: Passive vs 802.3af/at/bt, Splitting and Injecting PoE
- ESP32 ADC Explained: Non-Linearity, Attenuation, and Calibrating Analog Readings for Real Accuracy