An inductive linear position sensor (specifically a DC-integrated LVDT) translates physical displacement into a proportional DC voltage (typically 0-10V) or current (4-20mA) using electromagnetic induction. For a 3.3V microcontroller like the ESP32, you cannot wire a 0-10V sensor directly to a GPIO pin. You must use a resistive voltage divider to scale the signal down to a safe 0-3.1V range, then apply a linear mapping function in code utilizing the ESP32's factory-calibrated eFuse data to convert the 12-bit ADC reading into precise millimeters.
The Sensing Principle: How Inductive Linear Sensors Work
At the core of an inductive linear position sensor—most commonly a Linear Variable Differential Transformer (LVDT)—is a cylindrical assembly containing one primary coil and two secondary coils wound around a hollow tube. A separate, movable ferromagnetic core slides through the center of this tube without making physical contact. An alternating current (AC) excites the primary coil, generating a magnetic field that induces voltages in the two secondary coils. When the core is perfectly centered (the 'null' position), the induced voltages in both secondaries are equal and opposite, resulting in a net differential output of zero.
As the core moves linearly away from the null position, the magnetic coupling shifts. The voltage in one secondary coil increases while the other decreases, creating a differential AC voltage that is strictly proportional to the core's displacement. Furthermore, the phase of this AC output shifts by exactly 180 degrees depending on which direction the core moves from the center, allowing the sensor's internal electronics to determine both the absolute distance and the direction of travel with sub-micron resolution.
Output Signals: Why Raw AC Fails Microcontrollers
A common and costly mistake makers and junior engineers make is buying a 'raw' LVDT and attempting to read it with an Arduino or ESP32. Raw LVDTs output an AC differential signal (often requiring 3kHz to 10kHz excitation). Microcontrollers cannot read this directly. You have three distinct output categories when shopping for these sensors:
- Raw AC (Differential): Requires an external, dedicated LVDT signal conditioner (demodulator) to convert the AC phase/amplitude into a DC voltage. Avoid this unless you are building custom DIN-rail industrial panels.
- Analog DC (0-5V, 0-10V, 4-20mA): The sensor housing contains the built-in oscillator and demodulator. It accepts a standard DC supply (10-30V) and outputs a clean, single-ended DC signal. This is the correct choice for microcontroller interfacing.
- Digital (SSI, IO-Link, RS-485): Outputs discrete digital packets. While excellent for PLCs, interfacing SSI with an ESP32 requires precise bit-banging or specific hardware SPI configurations that often trip up hobbyists. Stick to analog DC for straightforward ADC integration.
Wiring, Pinout, and Voltage Scaling for ESP32
For this guide, we are using a standard 0-10V DC-output LVDT (such as the Omega LD620 series or Balluff BAW). The ESP32's ADC pins are strictly limited to 3.3V, and pushing 10V into GPIO 34 will instantly destroy the silicon. We use a voltage divider to step the voltage down.
The ESP32 ADC is notoriously non-linear near 0V and near 3.3V. Instead of scaling 10V exactly to 3.3V, we will scale 10V to 3.125V. This keeps the maximum signal safely below the clipping threshold and forces the readings into the highly linear middle-region of the ADC curve.
Spec-Sheet Wiring & Voltage Divider Table
| Sensor Wire / Component | Function | Connection / Value | Notes & Supply Range |
|---|---|---|---|
| Brown (or Pin 1) | Sensor VCC | 12V to 24V DC PSU | Sensor supply range is typically 10-30V DC. Do not power from ESP32 5V. |
| Blue (or Pin 3) | Sensor GND | PSU GND & ESP32 GND | Must share a common ground reference with the microcontroller. |
| Black (or Pin 2) | Signal Out (0-10V) | Resistor R1 (22kΩ) | Connects to one end of R1. The other end of R1 connects to R2 and the ESP32 GPIO. |
| Resistor R1 | High-side Divider | 22kΩ (1% tolerance) | Use 1% metal film. 5% carbon resistors will introduce scaling errors. |
| Resistor R2 | Low-side Divider | 10kΩ (1% tolerance) | Connects between the ESP32 GPIO and GND. |
| ESP32 GPIO | ADC Input | GPIO 34, 35, 36, or 39 | These are input-only pins with no internal pull-ups to interfere with the divider. |
The Math: With R1 = 22kΩ and R2 = 10kΩ, the scaling factor is 10 / (22 + 10) = 0.3125. When the sensor outputs its maximum 10V, the ESP32 sees exactly 3.125V.
Raw ADC Reading to Millimeters: The Exact Math
To convert the raw ADC reading into physical millimeters, we must reverse the voltage divider math and map it to the sensor's physical stroke length. According to the Espressif ESP-IDF ADC documentation, you should always use analogReadMilliVolts() in the modern Arduino core, as it automatically applies the factory eFuse calibration data stored on the ESP32 chip, correcting for silicon-level manufacturing offsets.
Arduino/ESP32 Code Implementation
// Inductive Linear Position Sensor (0-10V) to ESP32
// Voltage Divider: R1 = 22k, R2 = 10k
const int SENSOR_PIN = 34;
const float VCC_SENSOR = 10.0; // Max sensor output voltage
const float R1 = 22000.0; // High-side resistor in ohms
const float R2 = 10000.0; // Low-side resistor in ohms
const float STROKE_MM = 50.0; // Physical stroke length of your specific sensor
// Mechanical restriction: Use only 5% to 95% of stroke to avoid ADC edge non-linearity
const float MIN_VALID_VOLTAGE = 0.5;
const float MAX_VALID_VOLTAGE = 9.5;
void setup() {
Serial.begin(115200);
analogReadResolution(12); // Set ESP32 ADC to 12-bit (0-4095)
analogSetAttenuation(ADC_11db); // Required for 0-3.3V range
}
void loop() {
// Read calibrated millivolts directly from eFuse data
int adc_mV = analogReadMilliVolts(SENSOR_PIN);
float v_esp32 = adc_mV / 1000.0; // Convert to Volts
// Reverse the voltage divider to find the actual sensor output voltage
float v_sensor = v_esp32 * ((R1 + R2) / R2);
// Map voltage to physical position
float position_mm = (v_sensor / VCC_SENSOR) * STROKE_MM;
// Validate reading against mechanical restrictions
if (v_sensor >= MIN_VALID_VOLTAGE && v_sensor <= MAX_VALID_VOLTAGE) {
Serial.print("Position: ");
Serial.print(position_mm, 2);
Serial.println(" mm");
} else {
Serial.println("Error: Core near mechanical limits (ADC non-linear zone)");
}
delay(50);
}
Interference, Ground Loops, and Shielding
Inductive sensors are highly susceptible to electromagnetic interference (EMI), particularly in environments with Variable Frequency Drives (VFDs), large relays, or high-current switching. The Omega Engineering LVDT guide explicitly warns that parasitic capacitance in long, unshielded cables can attenuate high-frequency excitation signals and inject noise into the DC output.
Common Interference Sources & Fixes:
- Ground Loops: If the sensor's 24V PSU ground and the ESP32 USB ground are tied together through multiple paths, 50/60Hz mains hum will superimpose on your ADC reading. Fix: Use a single-point star ground topology. Connect the sensor shield and GND at the ESP32/PSU junction only.
- VFD Switching Noise: High dV/dt spikes from motor drives couple into sensor cables. Fix: You must use Shielded Twisted Pair (STP) cable. Crucially, ground the cable shield at the microcontroller end ONLY. Grounding both ends creates a loop that turns your cable shield into an antenna for VFD noise.
- ADC Jitter: Even with shielding, the ESP32 may show ±2mm of jitter. Fix: Implement a software low-pass filter (Exponential Moving Average) or take 64 rapid samples and average them before calculating the final millimeter value.
Decision Path: Selecting Your Inductive Linear Sensor
Do not default to an LVDT if your application does not demand it. Use this decision matrix to select the correct linear sensing technology for your build, terminating in a concrete recommendation for high-precision prototyping.
| If Your Application Requires... | Then Choose This Technology | Example Part / Series |
|---|---|---|
| Sub-micron resolution, stroke < 100mm, harsh/coolant environment | DC-LVDT (Inductive) | Omega LD620 Series |
| Long stroke (100mm to 2000mm), hydraulic cylinder integration | Magnetostrictive (Time-of-flight) | Temposonics R-Series / Balluff BTL |
| Short stroke (< 25mm), low budget (< $20), clean indoor environment | Hall-Effect Linear | Allegro A1302 / Melexis MLX90242 |
| Extreme temperature (>150°C), no internal electronics allowed in probe | Raw AC LVDT + Remote Conditioner | Sensata LVDT + DRG-LVDT DIN module |
The Default Pick
For 90% of advanced maker, robotics, and industrial-prototyping projects requiring an inductive linear position sensor, the default pick is the Omega LD620 series DC-LVDT (or an equivalent Balluff BAW M12 analog inductive sensor). Priced typically between $250 and $450 depending on stroke length, it integrates the AC demodulator directly into the stainless steel housing, outputs a robust 0-10V DC signal that easily survives 2-meter cable runs, and carries an IP67 rating that ignores dust, oil, and water. Pair it with the 22k/10k voltage divider and the eFuse-calibrated ESP32 code above, and you will achieve reliable, repeatable linear tracking without fighting raw AC phase-demodulation circuitry.






