UART, PWM, RS485, 4 to 20 mA: choosing a sensor output

, 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

OutputSignalTypical cableUse it for
UART (TTL)Digital serial framesUnder 1 to 2 mMicrocontrollers, single sensor
I²CDigital, addressed busUnder 1 mSeveral sensors on one board
PWMPulse width encodes valueA few metresSimple timer input
RS485 Modbus RTUDifferential digital busUp to about 1,200 mMany sensors, long runs, diagnostics
4 to 20 mAAnalogue current loopHundreds of metresPLCs, noisy sites, loop power
0 to 10 VAnalogue voltageShort runsOEM controllers
LIN / CANVehicle busesIn-vehicleAutomotive 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.

Sensors in this guide