UART, PWM, RS485, 4 to 20 mA: choosing a sensor output
DWIN Engineering, , 4 min read

Use UART or I²C for a sensor on the same board as a microcontroller, PWM when you only have a timer input, RS485 with Modbus for several sensors on a long cable, 4 to 20 mA for PLCs and noisy industrial sites, and LIN or CAN inside vehicles.
Comparison
| Output | Signal | Typical cable | Use it for |
|---|---|---|---|
| UART (TTL) | Digital serial frames | Under 1 to 2 m | Microcontrollers, single sensor |
| I²C | Digital, addressed bus | Under 1 m | Several sensors on one board |
| PWM | Pulse width encodes value | A few metres | Simple timer input |
| RS485 Modbus RTU | Differential digital bus | Up to about 1,200 m | Many sensors, long runs, diagnostics |
| 4 to 20 mA | Analogue current loop | Hundreds of metres | PLCs, noisy sites, loop power |
| 0 to 10 V | Analogue voltage | Short runs | OEM controllers |
| LIN / CAN | Vehicle buses | In-vehicle | Automotive ECUs |
Why 4 to 20 mA lasts
A current loop is immune to voltage drop along the cable, and 4 mA as zero means a broken wire reads 0 mA and can be detected. Two-wire transmitters draw their power from the same loop.
Why RS485 for many sensors
Differential signalling rejects noise over long cables, and Modbus addresses let up to 32 standard loads share one pair. The sensor can also report diagnostics and accept configuration.
Frequently asked questions
What is the difference between 4-20 mA and 0-10 V?
A 4 to 20 mA signal is a current, so cable resistance and voltage drop do not change it, and 0 mA reveals a broken wire. A 0 to 10 V signal is a voltage, simpler to read but affected by voltage drop and noise on long cables, and 0 V can mean either zero or a fault. Use current for long runs and noisy sites, voltage for short connections.
Is RS485 the same as Modbus?
No. RS485 is the physical layer: the differential wiring and voltage levels. Modbus RTU is a protocol, the message format that carries addresses, registers and checksums. Most industrial sensors with RS485 output, such as DWIN's CS-PT480 submersible level transmitter, use Modbus RTU over it.
What is a ratiometric 0.5-4.5 V output?
A ratiometric output is a fixed fraction of the supply voltage: on a 5 V supply it runs from 10% (0.5 V) to 90% (4.5 V) of supply. If the controller's ADC uses the same 5 V as its reference, supply variations cancel out. The 0.5 V floor and 4.5 V ceiling let the controller detect a short or broken wire.
How do I read a 4-20 mA sensor with a microcontroller?
Pass the loop current through a precision resistor and measure the voltage across it with the ADC. A 250 Ω resistor turns 4 to 20 mA into 1 to 5 V; a 165 Ω resistor gives about 0.66 to 3.3 V for a 3.3 V ADC. The loop still needs its own supply, typically 12 to 24 VDC.
Ultrasonic distance sensors, Pressure and level transmitters, Tilt, inertial and vibration
