EAZYLife STEM LAB · MODULE 15

Analog Sensors and Signal Conditioning

Learn how light, temperature and other physical quantities become electrical signals. Build sensor dividers, understand signal conditioning, filter noise and connect analogue sensors to a microcontroller.

Free open lesson Four practical investigations Arduino interface
SENSE · CONDITION · INTERPRET
01 · FROM PHYSICAL WORLD TO ELECTRICAL SIGNAL

A sensor measures a change; a circuit makes it useful

A sensor responds to a physical quantity such as light, temperature, pressure, position or magnetic field. Depending on its technology, it may change resistance, generate a voltage, produce a current or switch an electrical state. The interface circuit converts that response into a signal that the next stage can use.

A typical sensing and control chain

PhysicalquantitySensorSignalconditioningADC /controllerOutputAmplify · filter · protect · scale · linearise when needed

Not every sensor needs every conditioning stage. The circuit depends on the sensor's output type, range, speed, accuracy and the receiving device.

Common sensor families

  • Resistive: LDR, NTC/PTC thermistor, potentiometer, strain gauge.
  • Capacitive: touch, proximity, humidity and level sensing elements.
  • Magnetic: Hall-effect and reed sensors.
  • Self-generating: thermocouples, piezoelectric elements and photovoltaic cells.
  • Semiconductor: integrated temperature, pressure and light sensors.

What signal does it produce?

A passive resistive sensor needs an excitation circuit to make its resistance change observable. A thermocouple produces a small voltage. Some sensors provide an analogue voltage, while others provide a digital data stream or switching output.

Identify the exact sensor part number and datasheet before choosing the interface.

02 · RESISTIVE SENSORS

Turn a changing resistance into a measurable voltage

An LDR changes resistance with illumination. Many LDRs have lower resistance in brighter light and higher resistance in darkness. An NTC thermistor usually decreases in resistance as its temperature rises. These are trends, not universal calibration curves: exact behaviour depends on the part.

Light-dependent resistor (LDR)

More light → typically lower resistance

Use it in a divider to produce a light-dependent voltage. The divider orientation determines whether the output rises or falls as illumination increases.

NTC thermistor

NTCHigher temperature → typically lower resistance

NTC thermistors are useful for temperature sensing and thermal protection. Their resistance-temperature relationship is nonlinear, so accurate temperature conversion needs a calibration model or a lookup table.

Sensor voltage divider wiring

+5 VLDRRfixedArduino / ADCA0 reads VoutVoutGNDCommon ground

With the LDR above the output node and the fixed resistor below it, Vout = Vsupply × Rfixed ÷ (RLDR + Rfixed). As light increases and LDR resistance falls, this particular Vout generally rises.

03 · EXPLORE THE SENSOR DIVIDER

Change the sensor resistance and watch the voltage move

This is an ideal divider model. It does not reproduce a specific LDR's light response or thermistor's temperature curve. Enter the sensor resistance you measured or obtained from a datasheet.

Interactive resistive sensor model

Calculated output voltage2.50 VDivider current0.25 mAPower in sensor0.63 mWPower in fixed resistor0.63 mW

For the selected orientation, decreasing sensor resistance raises Vout.

Divider schematic updates with orientation

VsupplySensorVoutR fixedGND

Use the same supply and resistance values to compare both orientations. Notice how swapping the sensor and fixed resistor reverses the direction of the output change.

04 · FROM VOLTAGE TO DIGITAL VALUE

How a microcontroller reads an analogue signal

An analogue-to-digital converter (ADC) samples an input voltage and represents it as a number. For an ideal unipolar N-bit ADC with reference voltage Vref, the code is approximately proportional to Vin/Vref. Real ADCs have input limits, quantisation, offset, gain error, noise and reference uncertainty.

Ideal ADC scale, 10-bit example

0 VVref10230Input voltage increases →Quantised output codes (illustrative steps)

Conceptual staircase only. A typical Arduino Uno's 10-bit ADC returns codes 0–1023. Its default reference is usually related to the board's supply/reference arrangement; do not assume it is exactly 5.000 V. Check the exact board documentation.

Ideal ADC code estimate

Ideal output code512Approximate voltage per code4.89 mV

Input is within the selected reference range.

ADC design considerations

  • Input voltage must remain within the board's permitted ADC range.
  • Use a common reference/ground as specified by the hardware.
  • Source impedance and ADC sample-and-hold requirements matter.
  • Noise can cause adjacent code variation; averaging can help but does not fix every error.
  • Use the correct reference voltage in conversion calculations.
  • Do not connect a 5 V sensor signal directly to a 3.3 V-only input.
05 · SIGNAL CONDITIONING

Prepare the signal before it reaches the controller

Filtering unwanted variation

A simple RC low-pass filter can reduce fast fluctuations. Its cutoff frequency is:

fc = 1 ÷ (2πRC)

RVoutCVinSeries resistorGround

Filtering trades response speed for noise reduction. Choose R and C based on how quickly the physical quantity can change and the sampling rate of the controller.

Buffering and amplification

A voltage follower built with a suitable op-amp can provide a high-input-impedance buffer between a sensor divider and a load. An amplifier can scale a small signal into a useful ADC range.

Check input common-mode range, output swing, supply voltage, bandwidth, offset, bias current and stability. Not every op-amp works rail-to-rail or on a single low-voltage supply.

Review Module 09 for op-amp feedback and comparator fundamentals.

Revisit op-amp lesson

Protection and scaling

Use appropriate series resistance, clamps or dedicated interface components where necessary to protect an ADC input. A resistor divider can scale a voltage down, but it also adds source impedance and must be designed for the signal and ADC input requirements.

Never assume a microcontroller pin is 5 V tolerant. Verify the exact board's absolute maximum ratings and normal operating limits.

Calibration and linearisation

Many sensors are nonlinear. Use measured calibration points, a datasheet equation or a suitable lookup table. Calibration should cover the intended operating range and account for sensor tolerance, mounting and environmental effects.

A threshold that works in one room or enclosure may not work reliably in another.

RC low-pass cutoff calculator

Time constant τ10 msCutoff frequency15.92 Hz

First-order ideal RC estimate; actual response depends on source and load impedances.

What happens around cutoff?

  • At very low frequencies, the output follows the input closely.
  • At the cutoff frequency, output magnitude is about 0.707 of the passband value (−3 dB).
  • Above cutoff, the output amplitude falls at approximately 20 dB per decade for an ideal first-order filter.
  • The filter also introduces phase shift and delay.
06 · PRACTICAL 1

Build an LDR light-sensing input

Goal: observe how illumination changes the voltage at an analogue input. This is a sensor measurement activity, not yet an automatic lamp controller.

Wiring: LDR divider to Arduino Uno

Arduino Uno5VA0GNDLDR10 kΩ5 V railCommon GNDA0 sense node

Use a 10 kΩ fixed resistor as a starting point, not a universal optimum. Choose a value near the LDR's resistance around the illumination range of interest for useful sensitivity.

Components

  • Arduino Uno or compatible 5 V board.
  • One LDR.
  • One 10 kΩ resistor.
  • Breadboard and jumper wires.
  • USB cable or suitable regulated board supply.

Build and investigate

  1. Keep power disconnected while wiring the divider.
  2. Connect the LDR from 5 V to the A0 junction.
  3. Connect the 10 kΩ resistor from A0 to GND.
  4. Check that 5 V is not directly shorted to GND, then power the board.
  5. Upload the sketch and open Serial Monitor at 9600 baud.
  6. Record readings in bright light, shaded light and darkness. Change the resistor value and compare sensitivity.

Arduino sketch: read and report

const int lightPin = A0;

void setup() {
  Serial.begin(9600);
}

void loop() {
  int raw = analogRead(lightPin);

  // For a typical 10-bit ADC:
  float voltage = raw * (5.0 / 1023.0);

  Serial.print("ADC: ");
  Serial.print(raw);
  Serial.print("  Voltage: ");
  Serial.print(voltage, 3);
  Serial.println(" V");

  delay(250);
}

The 5.0 V conversion is illustrative for a board whose ADC reference is actually 5.0 V. Measure or configure the real reference for better accuracy. Check your board's ADC resolution before using 1023.

07 · PRACTICAL 2

Build an automatic night light

Use the same LDR divider to decide when an LED should turn on. The threshold is an application setting, not a universal light level. Real installations may need a transistor driver, enclosure, hysteresis and calibration to avoid flicker around the switching point.

Arduino-controlled LED output

ArduinoA0 · sensor inputD9 · LED outputGNDLDRdividerA0 signal330 ΩLEDCommon ground · LED current limited by series resistor

The LED is shown as a low-current indicator connected to a suitable GPIO output. Check the board's pin current limits and LED forward voltage; use a transistor driver for larger loads.

Arduino sketch: threshold control with hysteresis

const int lightPin = A0;
const int ledPin = 9;

// Example thresholds, calibrate
// using readings from your own setup.
const int darkOn = 350;
const int brightOff = 450;

bool lampOn = false;

void setup() {
  pinMode(ledPin, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  int lightValue = analogRead(lightPin);

  if (!lampOn && lightValue < darkOn) {
    lampOn = true;
  } else if (lampOn && lightValue > brightOff) {
    lampOn = false;
  }

  digitalWrite(ledPin, lampOn ? HIGH : LOW);

  Serial.print("Light ADC: ");
  Serial.print(lightValue);
  Serial.print("  Lamp: ");
  Serial.println(lampOn ? "ON" : "OFF");

  delay(100);
}

This example assumes the divider orientation shown earlier, where darkness usually lowers A0 voltage and ADC reading. If your sensor is wired the other way, reverse the comparison logic. The gap between thresholds provides simple software hysteresis.

Investigate and improve

  1. Record ADC readings under several light conditions.
  2. Choose darkOn and brightOff from the observed range, not by copying the example blindly.
  3. Observe whether the lamp flickers near the threshold.
  4. Increase or reduce the hysteresis gap and compare behaviour.
  5. Move the sensor and LED apart to reduce the LED's own light feedback into the LDR.
  6. Consider averaging or an RC filter if the signal is noisy, while checking response delay.

Do not use this simple circuit as a safety-critical or outdoor mains lighting controller.

08 · PRACTICAL 3 AND 4

Thermistor measurement and noise filtering

Practical 3 · Read an NTC thermistor

Materials: NTC thermistor, known fixed resistor, breadboard, multimeter and low-voltage microcontroller ADC.

  1. Identify the thermistor nominal resistance and reference temperature from its datasheet.
  2. Build a divider with a known resistor and the thermistor. Start with a modest low-voltage supply and check expected current.
  3. Measure the thermistor resistance at room temperature with the circuit unpowered.
  4. Power the divider and measure its midpoint voltage.
  5. Warm the thermistor gently using your fingers or a controlled warm environment. Do not use a flame or exceed its rating.
  6. Observe resistance and divider voltage changes. Compare with the datasheet curve.

For accurate temperature, use the correct thermistor beta/Steinhart–Hart coefficients or a calibration table. Resistance alone does not give a universal temperature.

Practical 4 · Compare filtered and unfiltered signals

Materials: low-voltage signal source or sensor divider, resistor, capacitor, oscilloscope or ADC logger.

  1. Record the raw sensor signal under a steady condition.
  2. Add a first-order RC low-pass filter between the sensor and the measurement input, observing the correct circuit topology.
  3. Compare signal variation before and after filtering.
  4. Change R or C and observe the effect on noise and response time.
  5. Introduce a slow change to the sensor input and check whether the filtered output follows quickly enough.

Keep the source impedance and ADC input requirements in mind. A filter capacitor connected directly to an ADC input may need a suitable series resistor or buffer, depending on the hardware.

09 · DESIGN DECISIONS AND TROUBLESHOOTING

Make sensor readings dependable

Sensor reading is stuck at zero or maximum

Check supply, ground, divider connections, sensor orientation, ADC pin, input limits and whether the divider midpoint is actually connected to the ADC. Check for an open sensor or shorted connection.

Reading changes in the wrong direction

The sensor and fixed resistor may be swapped compared with the assumed divider arrangement. Confirm which element is above and below Vout, then adjust the conversion logic.

Readings jump around

Inspect loose breadboard contacts, supply noise, long wires, poor grounding and electromagnetic interference. Try sensible averaging or a low-pass filter, but avoid hiding real fast changes.

Sensor is slow to respond

Check the sensor's own thermal/physical response time, filter time constant, sampling interval and software averaging. A large capacitor can make a signal stable but sluggish.

Sensor becomes hot

Calculate divider current and sensor power. Choose a fixed resistor and supply that keep dissipation within the sensor's rating and self-heating limits.

Values do not match the datasheet

Check tolerance, temperature, illumination geometry, supply/reference voltage, ADC resolution, calibration conditions and whether the datasheet curve uses a different test current or mounting condition.

Sensor safety and suitability: low-cost LDRs and thermistors are not certified fire, gas, medical or life-safety detectors. Do not use hobby sensors as the sole protection for people or property. Avoid touching exposed mains, hot surfaces or hazardous chemicals during sensor investigations.

KNOWLEDGE CHECK

Check your understanding

1. In the illustrated divider, the LDR is above Vout and the fixed resistor is below. What usually happens to Vout as light increases?

2. What does an RC low-pass filter do?

3. Why might an NTC thermistor need a calibration equation?

KEEP LEARNING · GO FURTHER

Free to learn. More support when you need it.

Explore these open lessons at your own pace. For personalised explanations, project-specific troubleshooting, guided practical training or masterclasses, EazyLife offers paid support tailored to your learning goals.

Free or sponsored lesson referrals may be available through active programmes; they are not guaranteed.

Enquire about guidance