AI agents & screen readers: for a machine-readable, text-only catalogue, start at /llms.txt. Products are available as Markdown (/products.md, /products/{handle}.md) and JSON (/products.json, /products/{handle}.json).
Store
Your lesson ≈ 360 min

Lesson 4 · Weeks 6-8

Sensing the world

What you'll learn

Turn a physical quantity into a number a microcontroller can use, and judge whether that number is trustworthy.

What you're doing today

  • Wire an LDR as a divider and record how the reading changes with light.
  • Try three different fixed resistors and work out which gives the most useful range for the conditions you care about.
  • Complete PRP 3 and PRP 4.
  • Plot one sensor over ten minutes. Describe the noise, and decide whether it matters for your project.
  • Calibrate one sensor against a reference instrument and write down the relationship you found.
PRP 3

Light sensing with an LDR

Your first real sensor, and the same divider from PRP 1 with one leg that changes on its own.

  1. Wire the LDR as one leg of a divider with a fixed resistor.
  2. Read it into the board and print the value to the serial monitor.
  3. Record readings in three conditions: covered, room light, and a torch on it. Write the numbers down.
  4. Change the fixed resistor to a different value and repeat all three. The readings will change.
  5. Decide which fixed resistor gives the most useful spread for the conditions you care about, and say why. This is a design decision.
  6. Calibrate. Using a light meter or a phone app as a reference, work out roughly what your numbers correspond to in real units.

What you'll learn

Convert a physical quantity into a number, and choose circuit values that make that number useful.

What you'll make

I chose a fixed resistor deliberately and justified it with my own readings.

What you need

LDR, resistor kit, breadboard, board, USB cable.

Build it up — 8 steps

Wiring the light sensor · plays 8 steps Open · Download .fz

Sample code

vce_u1_03_read_ldr.ino · Read an LDR — PRP 3 ✦ English View Raw
// PRP 3 — light sensing with an LDR.
// Wire the LDR and a fixed resistor as a divider, junction to A0.

const int LDR_PIN = A0;

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

void loop() {
  int reading = analogRead(LDR_PIN);   // 0-1023, NOT a light level yet
  Serial.println(reading);
  delay(1000);
}
Quick chips

IPO chart

Inputs

  • Ambient light falling on the LDR

Processing

  • The LDR's resistance falls as light rises, changing the divider output; the ADC converts that voltage to a number 0-1023

Outputs

  • A stream of readings on the serial monitor
Stuck? Common things to check Tap to open

That the ADC number is the measurement. It is a voltage, until calibrated.

Take it slower

Provide the sample sketch and two resistor values to compare, rather than asking the student to select from the whole kit.

Push further

Characterise the LDR across ten light levels and plot resistance against illuminance. Is it linear? Most students assume it is.

Done when…

Readings in three conditions for two different fixed resistors, plus a justified choice.

Reflect

What does your sensor read when nothing is changing, and how steady is it?

PRP 4

Temperature and humidity, plotted over time

This sensor is different: it does its own conversion and hands you real units. That makes it easier to use, and it hides work you should understand is happening.

  1. Wire and read the DHT22. Report temperature and humidity.
  2. Plot both over ten minutes using the serial plotter. Leave it alone while it runs.
  3. Describe what you see. How much does the reading move when nothing is happening? That is your noise floor.
  4. Change something real — breathe on it, move it near a window — and watch the response. How long does it take to settle?
  5. Compare with a reference thermometer and record the difference.
  6. Decide whether this sensor is good enough for your project, and say what "good enough" means for your case.

What you'll learn

Judge whether a sensor's data is good enough for a control decision.

What you'll make

I can state my sensor's noise level and response time, from my own plot.

What you need

DHT22 module, board, USB cable, reference thermometer.

Build it up — 8 steps

Wiring the DHT22 · plays 8 steps Open · Download .fz

Sample code

vce_u1_04_read_dht22.ino · Temperature and humidity — PRP 4 ✦ English View Raw
// PRP 4 — temperature and humidity, plotted over time.
// Requires the DHT sensor library.
//
// The DHT22 needs at least 2 seconds between reads. Sampling faster
// returns stale values or nan — it is the most common cause of both.

#include <DHT.h>

const int DHT_PIN = 2;
DHT dht(DHT_PIN, DHT22);

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

void loop() {
  float humidity = dht.readHumidity();
  float tempC = dht.readTemperature();

  if (isnan(humidity) || isnan(tempC)) {
    Serial.println("read failed");   // check wiring, and check you waited 2s
  } else {
    Serial.print(tempC);
    Serial.print(" ");
    Serial.println(humidity);       // two values, space separated, for the plotter
  }

  delay(2000);                       // minimum sampling interval for this sensor
}
Quick chips

IPO chart

Inputs

  • Air temperature and relative humidity at the sensor

Processing

  • The DHT22 digitises both and sends them over a single data line; the board decodes and reports them

Outputs

  • Two calibrated values, plotted against time
Stuck? Common things to check Tap to open

That a digital sensor is automatically accurate. It is precise and convenient; accuracy still needs checking.

Take it slower

Supply the sample sketch with the library already installed, so the student can focus on reading the plot rather than on getting the sensor talking.

Push further

Time the response: how long does it take to settle after a step change? Then argue which matters more for your project, accuracy or response time.

Done when…

A ten-minute plot, a described noise floor, a response test, and a reference comparison.

Reflect

Would you trust this sensor to make a decision on its own? What would you add?

Maddy, co-founder of Little Bird

Need help? We're here for you!

Hi, I'm Maddy. My team and I are ready to help with your order or any questions.