At its core, a sensor is a transducer that converts a physical measurand—such as temperature, pressure, or luminosity—into a proportional electrical signal. This transduction relies on fundamental physical effects: a thermocouple exploits the Seebeck effect to generate millivolts from a thermal gradient, while a MEMS accelerometer uses capacitive changes as microscopic proof masses shift under kinetic force.
Because these raw physical reactions rarely produce microcontroller-ready signals, practical sensors integrate signal conditioning circuitry. This internal stage amplifies microvolt-level signals via operational amplifiers, filters high-frequency noise with passive RC networks, and either outputs a conditioned analog voltage or digitizes the reading via an onboard Analog-to-Digital Converter (ADC) for I2C or SPI transmission.
Sensor Output Architectures: Analog vs. Digital
When asking 'what is the output of a sensor', you must separate analog and digital domains. Conflating the two leads to fried GPIO pins and garbage data.
- Analog Voltage (0-3.3V or 0-5V): The sensor outputs a continuous voltage proportional to the measurand. The microcontroller's internal ADC must sample this. Example: LM35 temperature sensor outputs 10mV per °C.
- Analog Current (4-20mA): Common in industrial environments. The sensor modulates current draw. It requires a shunt resistor (e.g., 250Ω) at the receiver to convert current back to a 1-5V signal for the ADC. It is highly immune to voltage drop over long wire runs.
- Digital (I2C/SPI/UART): The sensor contains its own ADC and microcontroller. It outputs pre-scaled, digitized bytes. The host microcontroller reads registers via clocked protocols. Example: BME280 outputs calibrated 32-bit integers for pressure.
Common Embedded Sensors: Specifications and Interfacing
Selecting the right sensor requires looking past the marketing copy and checking the actual electrical specifications. Below is a data-dense comparison of four ubiquitous sensors used in Arduino and ESP32 projects, detailing their true operating parameters.
| Sensor Model | Measurand | Output Type | Supply Range | Resolution | Typical Cost (2026) |
|---|---|---|---|---|---|
| LM35 | Temperature | Analog Voltage | 4.0V to 30V | 10mV / °C | $1.50 - $2.50 |
| BME280 | Temp / Hum / Press | Digital I2C/SPI | 1.71V to 3.6V | 20-bit (Press) | $4.00 - $7.00 |
| MPU6050 | 6-Axis IMU | Digital I2C | 2.375V to 3.46V | 16-bit ADC | $2.00 - $4.00 |
| SEN0114 | Soil Moisture | Analog Voltage | 3.3V to 5.0V | ~10mV steps | $1.00 - $2.00 |
Wiring and Pinout Reference
Correct wiring prevents ground loops and logic-level mismatches. The table below maps standard breakout board pins to both the 5V Arduino Uno and the 3.3V ESP32 DevKit V1. Always verify the breakout board's onboard voltage regulator; many cheap BME280 modules include a 3.3V LDO and can tolerate 5V on the VIN pin, but raw chips will fry.
| Sensor Pin | Arduino Uno (5V) | ESP32 DevKit (3.3V) | Function & Notes |
|---|---|---|---|
| VCC / VIN | 5V | 3V3 | Power supply. Use 3V3 for raw I2C chips. |
| GND | GND | GND | Common ground. Mandatory for analog refs. |
| SDA / OUT | A4 (SDA) or A0 | GPIO 21 or GPIO 34 | I2C Data or Analog Out. ESP32 GPIO 34 is input-only. |
| SCL | A5 (SCL) | GPIO 22 | I2C Clock. Requires 4.7kΩ pull-ups if not on board. |
Output Signal Math: Raw ADC to Physical Units
Reading a sensor is only half the battle; converting the raw integer into a meaningful physical unit requires precise math. The formula depends entirely on your microcontroller's ADC resolution and reference voltage.
Analog Math: LM35 on Arduino Uno
The Arduino Uno features a 10-bit ADC with a default 5.0V reference. The LM35 outputs 10mV (0.01V) per degree Celsius.
- Calculate Voltage:
Voltage = (ADC_Raw * 5.0) / 1024.0 - Calculate Temperature:
Temp_C = Voltage / 0.01(orVoltage * 100) - Combined C++ Code:
float tempC = (analogRead(A0) * 5.0 / 1024.0) * 100.0;
Analog Math: Generic Pressure Sensor on ESP32
The original ESP32 has a 12-bit ADC (0-4095) and a 3.3V logic level, but its internal ADC is notoriously non-linear near the rails. For a 0-500kPa pressure sensor that outputs 0.5V to 4.5V, you must use a voltage divider to map 4.5V down to ~3.1V (keeping it out of the ESP32's non-linear saturation zone above 3.15V).
- Scaling Factor: The sensor spans 4.0V (4.5V - 0.5V) for 500kPa. That is 125 kPa per Volt.
- Voltage Divider: Using 10kΩ and 22kΩ,
V_esp = V_sensor * (22 / 32). - Reconstruction Math:
V_sensor = V_esp * (32 / 22). - Final Equation:
Pressure_kPa = (((ADC_Raw * 3.3 / 4095.0) * (32.0 / 22.0)) - 0.5) * 125.0;
Calibration, Scaling, and Interference Mitigation
No sensor is perfect out of the box. Understanding what calibration is needed and how to fight electrical interference separates functional prototypes from reliable deployments.
Calibration and Scaling Requirements
- Digital Sensors (BME280, MPU6050): These contain factory-calibrated trimming parameters stored in ROM. The Adafruit BME280 library automatically reads these registers and applies the compensation algorithms. No manual scaling is required.
- Analog Sensors (LM35, Soil Moisture): Require a two-point calibration. For a soil moisture sensor, read the raw ADC value in completely dry air (0% moisture) and submerged in water (100% moisture). Use the
map()function to scale all intermediate readings between these two anchors.
Common Interference Sources and Fixes
Sensors operating in the millivolt range act as antennas for environmental noise.
- Electromagnetic Interference (EMI): Brushed DC motors and switching power supplies inject high-frequency noise into analog traces. Fix: Use twisted-pair wire for analog signals and place a 100nF ceramic bypass capacitor directly across the sensor's VCC and GND pins at the breakout board.
- Ground Loops: If your sensor and microcontroller are powered by different supplies, slight differences in ground potential will manifest as an offset voltage in your analog reading. Fix: Star-ground your system. Connect all sensor grounds to a single physical point on the microcontroller's GND pin.
- Thermal Drift: Precision analog sensors drift as ambient temperature changes. Fix: Keep heat-generating components (like voltage regulators or WiFi antennas) physically separated from the sensor element, or use a digital sensor with onboard temperature compensation.






