What is a sensor?
A sensor is a device that notices a change in the world and turns it into an electrical signal. The thing it measures is a physical quantity: light, temperature, distance, sound, pressure, moisture, motion or gas.
A sensor is an input device. It does not decide anything. It only reports. The decision is taken by a controller (a microcontroller or computer), and an actuator (lamp, motor, buzzer, fan, pump) does the action.
Simple chain: physical quantity → sensor → signal → controller → actuator.
Common kinds of sensors
- Light – LDR (light-dependent resistor): more light → less resistance. Also photodiodes and the image sensor in a camera.
- Temperature – thermistor: in the common NTC type, hotter → less resistance. Also thermocouples and digital temperature chips.
- Distance – ultrasonic: sends a sound pulse and times the echo. Distance = speed of sound × time ÷ 2. Infrared sensors also detect nearby objects.
- Motion – PIR (passive infrared): notices the warm body of a moving person.
- Moisture and humidity: wet soil conducts better, so its resistance falls.
- Sound – microphone, pressure / touch, gas / air quality, accelerometer and gyroscope (in phones).
Analogue, digital and the ADC
An analogue signal can take any value in a range, like a voltage from 0 V to 5 V. A digital signal has only fixed steps, like the numbers 0, 1, 2 … 1023.
A computer understands only numbers, so an ADC (analogue-to-digital converter) measures the voltage and gives a number. A 10-bit ADC gives 2¹⁰ = 1024 levels (0 to 1023). For a 0–5 V range, each step is 5 ÷ 1023 ≈ 4.9 mV.
Some sensors are digital already: they just say ON/OFF (a push switch, a PIR) or send the number themselves.
Qualities of a good sensor
- Range: smallest to largest value it can measure.
- Sensitivity: how much the output changes for a small change in input.
- Accuracy: how close the reading is to the true value; calibration means checking against a known value and correcting.
- Response time: how quickly it reacts.
Thresholds, relays and simple automatic control
A threshold is a set value. The controller asks one question again and again: is the reading above or below the threshold? If yes, it switches the output.
repeat forever: light = read LDR if light < 300: lamp ON else: lamp OFF
A microcontroller gives only a tiny current. A relay is an electrically operated switch: a small current in its coil pulls a contact that switches a much bigger current (a pump or a mains lamp).
When the output changes what the sensor measures (a heater warms the room the thermistor is in), we have closed-loop (feedback) control, like an air conditioner holding 24 °C.
Data logging and the Internet of Things
Data logging means taking readings automatically at a fixed time gap (the sampling interval) and storing them. Logging a pond's temperature every 10 minutes for a day gives 6 × 24 = 144 readings. Small intervals catch fast changes but make more data.
In the Internet of Things (IoT) sensors send their data over Wi-Fi or mobile networks to a server, where it can be graphed, alarm messages can be sent, and devices can be switched remotely, like a smart weather station or a smart-farm irrigation system.
Try it: your phone is full of sensors
Open a free sensor app (or the phone's compass and level tools). Cover the top of the phone with your hand and watch the light reading fall. Tilt the phone and watch the accelerometer numbers. Then in the 3D pick each sensor and find its threshold by moving the slider slowly.
Key formulas and definitions
- Sense → Compute → Act (input → process → output)
- ADC levels = 2ⁿ for n bits (10-bit → 1024)
- Voltage step = full-scale voltage ÷ (2ⁿ − 1)
- Ultrasonic distance = speed of sound × echo time ÷ 2
- Number of samples = total time ÷ sampling interval
Worked examples
1. Name the sensor and the actuator in an automatic street light.
Sensor: LDR (light). Actuator: the lamp, switched through a relay. The controller turns it on when light falls below the threshold.
2. An ultrasonic echo returns after 0.01 s. Speed of sound = 340 m/s. How far is the object?
Distance = 340 × 0.01 ÷ 2 = 1.7 m. We halve because the sound goes there and back.
3. How many levels does an 8-bit ADC have?
2⁸ = 256 levels (0 to 255).
4. A 10-bit ADC uses 0–5 V. What number does 2.5 V give?
2.5 ÷ 5 × 1023 ≈ 511.5, so about 511 or 512.
5. A logger records temperature every 30 s for 2 hours. How many readings?
2 h = 7200 s; 7200 ÷ 30 = 240 readings.
6. A fan should turn on above 30 °C. Write the control rule and say which sensor is needed.
Sensor: thermistor (temperature). Rule: repeat — read temperature; if it is above 30 °C turn the fan ON, else OFF.
Common mistakes
- Calling a sensor an output device. A sensor is an input; the lamp, motor or buzzer is the output (actuator).
- Thinking an LDR's resistance goes up with light. More light → lower resistance.
- Forgetting to halve the echo time for ultrasonic distance.
- Thinking a microcontroller can drive a pump directly. It needs a relay or transistor to switch the bigger current.