An LVDT displacement sensor outputs an alternating current (AC) voltage proportional to core position, which a microcontroller cannot read directly. To interface an LVDT with an ESP32 or Arduino, you must use a signal conditioner (like the Analog Devices AD698 or a commercial DC-LVDT transmitter) to convert the raw AC waveform into a 0-3.3V or 4-20mA DC signal. Once conditioned, you can map the DC voltage to physical millimeters using a linear scaling equation and the microcontroller's ADC.
How an LVDT Displacement Sensor Actually Works
An LVDT (Linear Variable Differential Transformer) consists of one primary coil and two secondary coils wound around a hollow cylindrical bobbin. The primary coil is driven by an external AC excitation signal (typically 1 kHz to 10 kHz). The two secondary coils are wired in series opposition, meaning their voltages subtract from one another. A movable ferromagnetic core slides inside the bobbin, altering the magnetic coupling between the primary and secondary coils.
When the core is perfectly centered (the null position), the magnetic flux linking both secondary coils is equal, resulting in a differential output of exactly zero volts. As the core moves off-center, the coupling to one secondary increases while the other decreases. This produces an AC output voltage whose amplitude is proportional to the distance moved, and whose phase (0 or 180 degrees relative to the excitation) indicates the direction of movement. Because the output is an AC waveform that swings positive and negative, it cannot be fed directly into a microcontroller's analog-to-digital converter (ADC).
Signal Conditioning: Bridging the AC-to-DC Gap
The most common mistake hobbyists and junior engineers make when working with LVDTs is attempting to wire the raw sensor outputs directly to an ESP32 GPIO pin. This will fail for two reasons: the ESP32 ADC only reads positive DC voltages (0-3.3V), and the raw LVDT output is an AC wave that swings into negative voltages, which can permanently damage the microcontroller's input circuitry.
To solve this, you need an LVDT signal conditioner IC like the AD698 or AD598, or you must purchase a pre-conditioned "DC-LVDT" module. A signal conditioner performs synchronous demodulation: it multiplies the raw AC output by the excitation frequency, filters out the high-frequency carrier, and outputs a clean, ratiometric DC voltage. For an ESP32, you should configure the conditioner's output range to 0V to 3.3V (or 0.5V to 2.8V to avoid the non-linear edges of the ESP32's internal ADC). If your application demands sub-micron precision, bypass the ESP32's internal ADC entirely and use an external 16-bit I2C ADC like the ADS1115.
Wiring and Interfacing with an ESP32
The following wiring table assumes you are using a commercially available DC-output LVDT signal conditioner (such as a 0-3.3V voltage output module) and an ESP32 DevKit V1. If you are using a raw LVDT, you must first wire the LVDT to the signal conditioner board according to the manufacturer's datasheet.
| Conditioner / Sensor Pin | ESP32 Pin / Power | Notes & Assumptions |
|---|---|---|
| VCC (Excitation/Logic) | External 12V/24V PSU | Do not power industrial conditioners from the ESP32 5V pin; they often require 100mA+ and 12V minimum. |
| GND (Power) | PSU GND & ESP32 GND | Common ground is mandatory. Connect PSU GND to ESP32 GND to establish a shared reference. |
| Signal Out (0-3.3V) | GPIO 34 (ADC1_CH6) | GPIO 34 is input-only and tied to ADC1. Do not use ADC2 (GPIO 0, 2, 4, etc.) if WiFi is active. |
| Shield / Drain Wire | PSU GND (Single Point) | Connect the cable shield at the power supply end only to prevent ground loops. |
The Math: Converting Raw ADC to Millimeters
Once the signal is conditioned into a DC voltage, you must scale the raw ADC reading into a physical unit (millimeters or inches). This requires knowing the sensor's stroke length and the conditioner's voltage output range.
Assumptions for this example:
- Sensor Stroke: ±50 mm (Total 100 mm range)
- Conditioner Output: 0.5V (at -50mm) to 2.8V (at +50mm)
- Null Voltage (0 mm): 1.65V
- ESP32 ADC Resolution: 12-bit (0 to 4095)
Step 1: Calculate Sensitivity (Volts per mm)
Sensitivity = (V_max - V_min) / Total_Stroke
Sensitivity = (2.8V - 0.5V) / 100 mm = 0.023 V/mm
Step 2: Convert ADC Raw to Voltage
Using the ESP-IDF recommended analogReadMilliVolts() function avoids the raw integer math and factory calibration errors inherent in analogRead().
// ESP32 LVDT Reading Code
const int lvdtPin = 34;
const float nullVoltage = 1650.0; // 1.65V in millivolts
const float sensitivity = 0.023; // Volts per mm
void setup() {
Serial.begin(115200);
analogSetAttenuation(ADC_11db); // Full range up to ~3.3V
}
void loop() {
// Read voltage directly in millivolts (ESP-IDF calibrated)
float v_mv = analogReadMilliVolts(lvdtPin);
// Calculate displacement from null position
float displacement_mm = (v_mv - nullVoltage) / (sensitivity * 1000.0);
Serial.print("Voltage (mV): ");
Serial.print(v_mv);
Serial.print(" | Displacement (mm): ");
Serial.println(displacement_mm, 2);
delay(100);
}
If your conditioner outputs a 4-20mA current loop instead of a voltage, you must pass the current through a precision shunt resistor (e.g., 165 ohms to yield 0.66V to 3.3V) before it reaches the ESP32 GPIO.
Interference, Calibration, and Edge Cases
LVDTs are inherently immune to many environmental factors, but the cabling and conditioning circuitry are highly susceptible to electrical noise. According to industry primers on LVDT operation, the most common interference sources include:
- Variable Frequency Drives (VFDs) and AC Mains: High dV/dt switching noise from nearby motors can capacitively couple into the LVDT signal wires. Always use Shielded Twisted Pair (STP) cable for the LVDT connection.
- Ground Loops: If the sensor housing is grounded to a machine chassis, and the signal conditioner is grounded to the ESP32's PC power supply, a ground loop will inject 50/60Hz hum into your reading. Use an isolated DC-DC converter to power the conditioner.
- Temperature Drift: While the LVDT's inductive principle is largely temperature-independent, the signal conditioner's op-amps and resistors will drift. Conditioners with ratiometric outputs (where the output scales with the excitation voltage) cancel out temperature-induced excitation drift.
For calibration, never rely solely on the datasheet's nominal sensitivity. Perform a 2-point calibration using gauge blocks at 10% and 90% of the physical stroke, then calculate the actual slope and intercept for your specific ESP32 and conditioner pairing.
Frequently Asked Questions
Can I wire an LVDT displacement sensor directly to an Arduino analog pin?
No. A raw LVDT outputs an AC voltage that swings both positive and negative relative to its excitation signal. Arduino and ESP32 analog pins can only read positive DC voltages (0-5V or 0-3.3V) and will be damaged by negative voltages. You must use a signal conditioner IC (like the AD598) or buy a pre-conditioned DC-LVDT module that outputs a standard 0-5V or 4-20mA signal.
What is the typical excitation frequency and voltage for an LVDT?
Most industrial LVDTs require an AC excitation voltage between 1V and 10V RMS, at a frequency ranging from 1 kHz to 10 kHz. The exact requirements are printed on the sensor's datasheet. If you use a dedicated signal conditioner IC, the IC generates this high-frequency AC carrier internally, saving you from having to design an external oscillator circuit.
How do I determine the direction of movement from the LVDT output?
In a raw, unconditioned AC signal, direction is determined by the phase angle: moving left yields a 0-degree phase shift relative to the primary excitation, while moving right yields a 180-degree phase shift. However, once the signal passes through a DC signal conditioner, this phase information is translated into a DC voltage level. Typically, a voltage below the null point (e.g., < 1.65V) indicates negative displacement, and a voltage above the null point (e.g., > 1.65V) indicates positive displacement.






