top of page
Search

How Does a Sensor Work? From Physical World to Digital Data


Introduction

Every smart device around you your fitness band counting steps, your thermostat adjusting temperature, your car detecting obstacles all of them share one thing in common. They begin with a sensor.


Sensors are the eyes, ears, and skin of every embedded and IoT system. They are the bridge between the messy, analog physical world and the clean, digital world of microcontrollers and software. Without sensors, embedded systems would be blind unable to perceive or respond to anything around them.


But how exactly does a sensor work? How does something as abstract as temperature, pressure, or light become a number inside a microcontroller? That is exactly what we are going to break down in this post step by step, from the physical world all the way to digital data.



The Big Picture: Signal Chain

Before diving into the details, let us look at the complete journey of a sensor signal:

Physical World → Sensor → Analog Signal → Signal Conditioning → ADC → Digital Data → Microcontroller

Every sensor system follows this path, whether it is a simple temperature sensor or a complex MEMS accelerometer. Understanding each stage gives you the full picture.


Stage 1: The Physical World

The physical world is full of quantities that we want to measure:

  • Temperature — how hot or cold something is

  • Pressure — force applied per unit area

  • Light — intensity of electromagnetic radiation

  • Humidity — moisture content in the air

  • Acceleration — rate of change of velocity

  • Sound — pressure waves in air

  • Distance — how far an object is

  • Magnetic field — strength and direction of magnetism


These quantities are all continuous and analog by nature. The real world does not operate in 0s and 1s. Your room temperature does not jump from 25°C to 26°C instantly — it changes smoothly and continuously.


The challenge for embedded systems is to capture, convert, and represent these continuous physical quantities in a form a microcontroller can understand.


Stage 2: The Sensor Element (Transduction)


The first job of a sensor is transduction converting a physical quantity into an electrical signal (voltage or current).


This is done by the sensing element inside the sensor, which exploits a physical or chemical phenomenon to produce an electrical output proportional to the input quantity.


Here are some common examples:

Thermistor (Temperature)

A thermistor is a resistor whose resistance changes predictably with temperature. As temperature rises, its resistance either increases (PTC) or decreases (NTC). By measuring the resistance, you can calculate the temperature.


Photodiode (Light)

A photodiode generates a small current proportional to the intensity of light falling on it. More light → more photons → more electron-hole pairs → more current.


Piezoelectric Sensor (Pressure / Vibration)

Certain materials like quartz generate a voltage when mechanical stress is applied to them. This is the piezoelectric effect. Press on the material — you get a voltage output.


MEMS Accelerometer (Acceleration)

A Micro-Electro-Mechanical System (MEMS) accelerometer contains a tiny mechanical mass suspended on microscopic springs etched into silicon. When the device accelerates, the mass deflects. This deflection changes a capacitance value, which is then measured electronically.


Capacitive Humidity Sensor

A hygroscopic polymer material changes its dielectric constant as it absorbs moisture from the air. This changes the capacitance of a built-in capacitor, which maps directly to relative humidity.


Stage 3: The Raw Analog Signal

After transduction, you have a raw analog signal — typically a small voltage, current, resistance, or capacitance that varies with the physical quantity being measured.


However, this raw signal is often:

  • Very small — a thermocouple may output only a few millivolts per degree Celsius

  • Noisy — electrical noise from the environment corrupts the signal

  • Non-linear — the output may not change proportionally with the input

  • Offset — the signal may have a DC bias that needs to be removed

This is where signal conditioning comes in.


Stage 4: Signal Conditioning

Signal conditioning is the process of cleaning and preparing the raw analog signal before it is converted to digital. It typically involves:


Amplification

Boosting a weak signal to a usable voltage range. An op-amp amplifier takes a millivolt-level thermocouple signal and scales it up to a 0–3.3V range that a microcontroller's ADC can read accurately.


Filtering

Removing unwanted noise using passive or active filters. A low-pass filter removes high-frequency electrical noise while keeping the useful slow-changing signal intact.


Linearization

Some sensors have a non-linear response curve. Signal conditioning circuits or software lookup tables correct this non-linearity so the output is proportional to the input.


Offset and Gain Adjustment

Calibrating the signal so that the zero point and the full-scale range are correctly mapped to the ADC input range.

In modern smart sensors and sensor ICs, much of this signal conditioning is done on-chip, saving external component cost and board space.


Stage 5: Analog to Digital Conversion (ADC)

This is the most critical stage in the chain. The ADC (Analog to Digital Converter) takes the conditioned analog voltage and converts it into a binary number that a microcontroller can process.


How Does an ADC Work?

An ADC samples the analog input at regular intervals — this is called the sampling rate. At each sample, it compares the input voltage against a reference voltage and produces a binary number representing that voltage level.


The precision of this conversion depends on the resolution of the ADC, expressed in bits:

ADC Resolution

Steps

Smallest Detectable Change (0–3.3V)

8-bit

256

~12.9 mV

10-bit

1024

~3.2 mV

12-bit

4096

~0.8 mV

16-bit

65536

~0.05 mV

A 12-bit ADC divides the input voltage range into 4096 discrete steps. If your reference is 3.3V and the input is 1.65V, the ADC output would be approximately 2048 (half of 4096).


The Conversion Formula

Digital Value = (Analog Input Voltage / Reference Voltage) × (2^n - 1)

Where n is the ADC resolution in bits.


Sampling Rate and Nyquist Theorem

The ADC must sample the signal at at least twice the highest frequency present in the signal — this is the Nyquist theorem. For a temperature sensor changing slowly, a sampling rate of a few Hz is more than enough. For an audio signal at 20kHz, you need at least 40kHz sampling rate.


Stage 6: Digital Data in the Microcontroller

Once the ADC produces a digital number, the microcontroller receives it and processes it. This typically involves:


Raw Value to Physical Unit Conversion

The raw ADC number needs to be converted back into a meaningful physical unit. For example, with a temperature sensor:

// Read raw ADC value (0 to 4095 for 12-bit ADC)
uint16_t raw = ADC_read();

// Convert to voltage
float voltage = (raw / 4095.0) * 3.3;

// Convert voltage to temperature (using sensor datasheet formula)
float temperature = (voltage - 0.5) * 100.0;  // for TMP36 sensor

Calibration

Every sensor has manufacturing tolerances. Calibration involves comparing the sensor output against a known reference and applying correction factors to improve accuracy.


Filtering in Software

Even after analog filtering, digital filtering techniques like moving averages or Kalman filters are applied to further smooth noisy readings.

// Simple moving average filter
#define SAMPLES 10
float buffer[SAMPLES];
int index = 0;

float moving_average(float new_value) {
    buffer[index] = new_value;
    index = (index + 1) % SAMPLES;
    float sum = 0;
    for (int i = 0; i < SAMPLES; i++) sum += buffer[i];
    return sum / SAMPLES;
}

Digital Sensors: The Modern Shortcut

So far we have described analog sensors. But many modern sensors are digital sensors — they perform the ADC conversion and signal conditioning internally and communicate the result directly over a digital protocol.

Protocol

Examples

How It Works

I2C

BMP280, MPU6050, SHT31

Two-wire bus, addressed communication

SPI

MAX31855, ADXL345

Four-wire, high-speed full-duplex

UART

GPS modules, CO2 sensors

Serial text or binary data stream

1-Wire

DS18B20 temperature sensor

Single wire, very simple protocol

With a digital sensor like the DHT22, you simply request a reading over a single data line and receive temperature and humidity as ready-to-use values. No external ADC or signal conditioning required.


Real-World Example: Temperature Sensor End to End

Let us trace a complete real-world example with the LM35 analog temperature sensor:

1. Physical World → Room temperature is 27°C

2. Transduction → LM35 outputs 10mV per °C, so it produces 270mV

3. Signal Conditioning → The signal is within ADC range, so minimal conditioning is needed

4. ADC Conversion → 12-bit ADC with 3.3V reference: Digital value = (0.270 / 3.3) × 4095 = 335

5. Microcontroller Processing →

float voltage = (335 / 4095.0) * 3.3;   // = 0.270V
float temperature = voltage * 100;        // = 27.0°C

6. Output → Display 27°C on screen, send to cloud, trigger an alert — whatever your application needs.


Key Sensor Specifications to Know

When selecting a sensor for your project, these are the parameters that matter most:

Parameter

What It Means

Range

Minimum to maximum measurable value

Resolution

Smallest detectable change in the measured quantity

Accuracy

How close the reading is to the true value

Sensitivity

Output change per unit change in input

Response Time

How quickly the sensor reacts to a change

Operating Voltage

Supply voltage required (3.3V, 5V etc.)

Interface

Analog, I2C, SPI, UART

Power Consumption

Critical for battery-powered IoT devices


Conclusion

A sensor is far more than just a component you connect to a pin. It is the starting point of an entire signal chain from the physical phenomenon you want to measure, through transduction, signal conditioning, and analog-to-digital conversion, all the way to a meaningful number inside your microcontroller.


Understanding this journey every stage of it makes you a better embedded engineer. It helps you choose the right sensor, design better circuits, write more accurate firmware, and debug problems faster when readings are noisy, drifting, or simply wrong.


The physical world is rich, messy, and analog. Sensors are how we make sense of it — one measurement at a time.


 
 
 

1 Comment

Rated 0 out of 5 stars.
No ratings yet

Add a rating
Guest
3 days ago
Rated 4 out of 5 stars.

Great post! It’s fascinating how sensors bridge the gap between our physical world and digital signals. Whether it's temperature or motion, the process of converting environmental data into actionable bits is incredible engineering. I was particularly impressed by how these circuits are integrated into modern hardware. For instance, when designing compact sensing arrays, opting for an aluminum PCB for LED lighting is such a smart move for heat dissipation. It really keeps things stable during long-term operation. Thanks for breaking down the technical complexity behind these everyday components; it makes the invisible tech around us much easier to understand!

Like
bottom of page