Internet of Things

Chapter 3
Sensors, Actuators and Physical Computing

Bachelors Program in Computer Science Engineering
Internet of Things   •   Bachelor

Sensors, Actuators and Physical Computing

Introduction and Context

The Internet of Things (IoT) connects physical objects to computational, communication, and service systems. Sensors provide observations of the physical world; embedded processors interpret those observations; actuators produce physical effects. Together, these components form the essential interface between cyber systems and reality.

A typical IoT node contains a sensing element, signal-conditioning circuitry, an analogue-to-digital converter (ADC), a microcontroller, communication hardware, and one or more actuators. The quality of the complete system depends not only on the sensor datasheet but also on installation, wiring, sampling, calibration, software timing, power supply, and environmental conditions.

This chapter examines sensing and actuation principles, signal conditioning, sampling, calibration, error analysis, sensor fusion, and practical interfacing with embedded hardware.

Learning Objectives

By the end of this chapter, a student should be able to:

  1. Explain how common sensors and actuators convert between physical and electrical domains.
  2. Select suitable signal-conditioning and interfacing circuits.
  3. Apply sampling principles and identify aliasing risks.
  4. Distinguish accuracy, precision, resolution, sensitivity, and uncertainty.
  5. Calibrate sensors and evaluate measurement error.
  6. Combine sensor observations using basic sensor-fusion methods.
  7. Interface common sensors and actuators safely with a microcontroller.
  8. Analyze an IoT physical-computing application and identify practical limitations.

1. Physical Computing as a Cyber-Physical Interface

Physical computing is the design of systems in which software responds to physical inputs and controls physical outputs. The basic closed loop is:

physical phenomenon → sensor → signal conditioning → ADC and processor → control decision → driver → actuator → physical response

A sensor is a transducer that converts a measurand—such as temperature, pressure, light, acceleration, or gas concentration—into an electrical signal. An actuator performs the reverse general function: it converts electrical energy or a control signal into motion, heat, light, sound, or fluid flow.

Sensors may be classified by their output:

TypeOutputExamples
AnalogContinuous voltage, current, resistance, or frequencyThermistor, LDR, strain gauge
DigitalLogic levels, pulses, or serial dataLimit switch, I²C temperature sensor, encoder
PassiveRequires external excitation or supplies little signal energyRTD, thermistor, strain gauge
ActiveGenerates an electrical signal from the measurandPhotovoltaic cell, piezoelectric sensor
ContactRequires physical contactPush-button, reed switch
Non-contactMeasures remotelyInfrared, ultrasonic, radar

The selection of a sensor should consider range, sensitivity, resolution, response time, accuracy, repeatability, environmental tolerance, power consumption, interface, cost, and safety requirements. The sensor with the greatest nominal accuracy is not necessarily the best choice if it has an unsuitable range, slow response, poor environmental protection, or difficult calibration.

2. Sensor Characteristics and Measurement Models

A useful static model for a sensor is:

y = f(x) + b + n

where x is the true measurand, y is the observed output, f(x) is the ideal transfer function, b is systematic bias, and n is random noise. For a linear sensor this becomes:

y = Sx + b + n

Here, S is sensitivity, with units of output per unit input. The model assumes that the sensor is operating within its specified range and that nonlinear effects are either negligible or represented separately.

Important characteristics include:

  • Range: minimum and maximum measurable values.
  • Sensitivity: change in output per unit change in input, S = Δy⁄Δx.
  • Resolution: smallest input change that can be distinguished.
  • Accuracy: closeness to the accepted or true value.
  • Precision: closeness of repeated measurements to one another.
  • Repeatability: agreement under the same conditions.
  • Hysteresis: different outputs for increasing and decreasing input at the same input value.
  • Linearity: closeness of the transfer curve to a specified straight line.
  • Response time: time required to respond to a change in input.
  • Drift: slow change in output when the input remains constant.
  • Noise: unwanted random variation in the measurement.

Accuracy and precision are distinct. A set of measurements can be precise but inaccurate if all values are tightly grouped around an incorrect value caused by calibration bias.

2.1 Static and Dynamic Response

For a first-order sensor, a common dynamic model is:

τ dy(t)⁄dt + y(t) = Kx(t)

where τ is the time constant, K is the static gain, x(t) is the input, and y(t) is the output. For a step input, the response approaches its final value exponentially:

y(t) = y_∞ + [y(0) − y_∞]e^(−t⁄τ)

After approximately 1τ, 2τ, and 3τ, the response has reached about 63%, 86%, and 95% of its total change, respectively. This model is applicable when the sensor behaves approximately as a linear first-order system. It is not a complete model for sensors with significant delay, resonance, saturation, or nonlinear dynamics.

3. Common Sensors

3.1 Temperature Sensors

A thermistor is a temperature-dependent resistor. Negative-temperature-coefficient (NTC) thermistors decrease in resistance as temperature increases. A widely used approximation is:

R(T) = R₀ exp[B(1⁄T − 1⁄T₀)]

where resistance and temperature are R(T) and R₀, T is absolute temperature in kelvin, T₀ is the reference temperature in kelvin, and B is the material constant in kelvin. This equation is an approximation over a limited range.

An RTD, such as platinum Pt100, provides more stable and approximately linear temperature measurement. Thermocouples generate a small voltage related to a temperature difference and require cold-junction compensation. Integrated digital temperature sensors perform conversion and often provide calibration internally, reducing analogue design effort.

3.2 Light, Proximity, and Distance Sensors

Photodiodes generate current related to incident light. Light-dependent resistors change resistance with illumination but typically have slower and less predictable responses. Infrared proximity sensors may use reflected light, while ultrasonic sensors estimate distance from echo time. For an ultrasonic measurement:

d = vt⁄2

where d is target distance, v is the speed of sound in the medium, and t is round-trip echo time. The factor 2 is required because the pulse travels to the target and back. Temperature, angle, absorption, and multiple reflections affect accuracy.

3.3 Motion and Inertial Sensors

Accelerometers measure specific force along one or more axes; gyroscopes measure angular rate. A magnetometer estimates the direction of the local magnetic field. These sensors are affected by bias, scale-factor error, axis misalignment, vibration, and magnetic interference. An inertial measurement unit (IMU) combines several such sensors but does not automatically provide accurate position: integrating acceleration and angular rate causes error to accumulate over time.

3.4 Pressure, Gas, and Environmental Sensors

Pressure sensors commonly use piezoresistive or capacitive structures. Gas sensors may be semiconductor, electrochemical, or optical. Environmental sensors often require warm-up time, compensation for temperature and humidity, and protection from condensation or contamination. A sensor suitable for laboratory air may be unsuitable for an industrial process because of cross-sensitivity or hazardous conditions.

4. Signal Conditioning

Raw sensor signals are rarely ready for direct processing. Signal conditioning may include excitation, amplification, attenuation, filtering, linearization, isolation, level translation, protection, and multiplexing.

4.1 Voltage-Divider Interface

A resistive sensor can be placed in a voltage divider:

Vo = Vs R₂⁄(R₁ + R₂)

where Vs is the excitation voltage, R₁ and R₂ are the two resistances, and Vo is the divider output measured across R₂. The equation assumes ideal resistors, negligible loading, and a stable excitation voltage. If a microcontroller input has finite impedance, that input must be included in the circuit analysis.

A divider converts resistance into voltage but may consume continuous power. For a battery device, resistor values should balance signal strength, noise susceptibility, ADC input requirements, and energy consumption.

4.2 Amplification and Level Shifting

An instrumentation amplifier is useful for small differential signals such as those from strain gauges. It offers high input impedance and good common-mode rejection. The gain must be selected so that the largest expected signal remains within the ADC input range. Saturation at either amplifier rail causes measurement distortion.

A microcontroller ADC may accept 0 to 3.3 V, while a sensor may produce ±1 V. Direct connection would be unsafe or would lose half the information. Attenuation, offsetting, protection, or a suitable external ADC may be required.

4.3 Filtering

A low-pass filter suppresses high-frequency noise. For a simple RC low-pass filter:

fc = 1⁄(2πRC)

where R is resistance in ohms, C is capacitance in farads, and fc is the −3 dB cutoff frequency in hertz. This expression assumes an ideal first-order filter with negligible loading. A filter attenuates rapid changes as well as noise, so its cutoff must reflect the required physical response.

A high-pass filter removes slowly varying components, while a notch filter suppresses a narrow interference frequency such as mains hum. Digital filtering can be applied after sampling, but it cannot reliably remove aliasing that occurred before sampling. Therefore, analogue anti-alias filtering is normally required before an ADC.

5. Sampling and Data Conversion

An ADC maps an analogue voltage to a finite digital code. For an ideal N-bit ADC with input range 0 to Vref, the nominal voltage step is approximately:

q = Vref⁄2ᴺ

where q is the quantization interval. The quantization uncertainty is often approximated as ±q⁄2 under a specified rounding model. Real ADCs also exhibit offset error, gain error, integral nonlinearity, differential nonlinearity, reference variation, and noise.

The sampling theorem states that a band-limited signal with highest frequency fmax can theoretically be reconstructed when:

fs > 2fmax

where fs is the sampling frequency. This is a theoretical condition; engineering designs normally use margin and an anti-alias filter because real signals are not perfectly band-limited. Frequencies above half the sampling rate fold into lower frequencies, producing aliasing that cannot be corrected after sampling.

Worked example. A vibration signal contains useful components up to 800 Hz. The theoretical minimum sampling rate is greater than 1,600 samples/s. A practical design may select 4,000 samples/s or more and place an analogue low-pass filter below the Nyquist frequency, depending on the required transition band and measurement accuracy.

5.1 ADC Example

Suppose a 12-bit ADC uses a 3.3 V reference. Its nominal step is:

q = 3.3⁄4096 ≈ 0.000806 V = 0.806 mV

If a sensor output changes by 2 mV per unit of the measurand, the ideal quantization step corresponds to approximately 0.403 measurement units. This does not mean the complete system has that accuracy; sensor noise, reference error, calibration, and analogue errors may dominate.

6. Calibration and Error Analysis

Calibration establishes the relationship between instrument output and a reference. A practical procedure is:

  1. Define the operating range and acceptable uncertainty.
  2. Select traceable reference points.
  3. Allow the system to reach thermal and electrical equilibrium.
  4. Record repeated measurements at increasing and decreasing inputs.
  5. Fit a transfer function or create a lookup table.
  6. Validate at points not used for fitting.
  7. Record environmental conditions, date, equipment, and uncertainty.

For a linear two-point calibration, if raw readings r₁ and r₂ correspond to reference values x₁ and x₂, the calibrated estimate can be written:

x̂ = x₁ + (r − r₁)(x₂ − x₁)⁄(r₂ − r₁)

where r is a new raw reading and x̂ is the estimated measurand. This method assumes a stable, approximately linear relationship over the interval.

The absolute error is:

e = x̂ − xtrue

and the percentage error, when xtrue ≠ 0, is:

percentage error = 100|e|⁄|xtrue|

Random variation can be summarized using the sample mean and sample standard deviation:

x̄ = (1⁄n)∑ᵢ₌₁ⁿ xᵢ
s = √[∑ᵢ₌₁ⁿ(xᵢ − x̄)²⁄(n − 1)]

Here, n is the number of observations. The denominator n − 1 is used for the usual unbiased estimate of population variance from a sample. Standard deviation describes spread; it does not remove systematic bias.

Uncertainty propagation must consider how input uncertainties affect an output. For independent variables in a function y = f(x₁, x₂, ..., xk), a first-order approximation is:

uy² ≈ ∑ⱼ₌₁ᵏ (∂f⁄∂xⱼ)²uⱼ²

where uj is the standard uncertainty of xj. This approximation assumes small uncertainties, a locally differentiable model, and negligible covariance. Correlated inputs require covariance terms.

7. Actuators and Driver Circuits

Actuators include LEDs, buzzers, relays, motors, solenoid valves, heaters, and displays. A microcontroller pin generally provides a logic signal, not the current or voltage required by an actuator.

  • LEDs: require a current-limiting resistor and correct polarity.
  • DC motors: require a transistor or motor driver, a flyback path, and attention to startup current.
  • Relays and solenoids: are inductive loads; a diode or suitable suppression network limits turn-off voltage.
  • Servomotors: commonly accept pulse-width control, but the power supply must handle their current peaks.
  • Stepper motors: require a dedicated driver for phase sequencing and current control.
  • Heaters: require power switching, thermal sensing, insulation, and independent safety protection.

For pulse-width modulation (PWM), the duty cycle is:

D = ton⁄T

where ton is the on-time and T is the period. For an ideal resistive load driven between 0 and Vs, the average voltage is approximately:

Vavg ≈ DVs

This relationship does not imply that every actuator responds linearly to average voltage. Motors, LEDs, heaters, and switching converters have different electrical and mechanical responses.

Never connect an inductive load directly to a general-purpose I/O pin unless the hardware is explicitly designed for it. Use a correctly rated driver, common-ground arrangement where appropriate, current limiting, transient suppression, and a separate actuator supply when necessary.

8. Sensor Fusion

Sensor fusion combines complementary measurements to produce a more useful estimate. A temperature sensor may provide accurate slow information while another sensor responds rapidly but noisily. A GPS receiver provides bounded position observations outdoors, whereas inertial sensors provide rapid short-term motion information but drift.

A simple weighted average is:

x̂ = ∑ᵢ wᵢxᵢ⁄∑ᵢ wᵢ

where xi are estimates and wi are nonnegative weights. If independent estimates have known variances σi², a common choice is wi = 1⁄σi², giving greater weight to more precise measurements. The independence assumption is important; correlated errors can make this method overconfident.

A complementary filter combines low-frequency information from one sensor with high-frequency information from another. For orientation, gyroscope data may be integrated for rapid response while an accelerometer supplies a long-term gravity reference. More advanced systems use Kalman filters or Bayesian estimators, which maintain an estimate and its uncertainty, predict the next state, and update it using observations.

Fusion does not automatically improve results. Sensors with shared environmental bias, poor time synchronization, incorrect coordinate frames, or unrecognized faults can produce a confidently wrong estimate. Fusion systems should include plausibility checks, timestamp validation, range checks, and fault handling.

9. Embedded Interfacing Practices

Common interfaces include:

InterfaceCharacteristicsTypical use
GPIOLogic input/output; interrupts possibleSwitches, status signals
ADCConverts analogue voltage to digital codeThermistors, potentiometers
PWMTimed digital waveformLED brightness, motor control
I²CTwo-wire addressed serial busEnvironmental sensors, displays
SPIFast synchronous bus with chip selectADCs, displays, memory
UARTAsynchronous point-to-point serial linkGPS, modems, debug consoles
1-WireSingle data line with addressingSome temperature sensors

Good practice includes checking voltage levels, pull-up requirements, bus speed, cable length, grounding, connector polarity, startup state, and electromagnetic compatibility. Datasheet limits are absolute boundaries, not recommended operating targets. Software should initialize pins to safe states before enabling actuators, detect communication timeouts, validate sensor ranges, and record diagnostic information.

Timing is also a design concern. Blocking delays can prevent a controller from servicing communication or safety functions. A scheduled, non-blocking architecture is usually preferable: sample sensors at defined rates, timestamp data, run control logic at an appropriate period, and update actuators only after safety checks.

10. Illustrative Case: Smart Greenhouse Ventilation

Background

Consider an illustrative IoT greenhouse system that regulates temperature and humidity. It uses a digital temperature-humidity sensor, a light sensor, a door switch, a fan, and a motorized ventilation window.

Problem

The original system switched the fan on whenever the measured temperature exceeded 28 °C. It oscillated rapidly near the threshold, operated during rain, and sometimes reported implausible humidity after condensation.

Analysis

The design contained three problems. First, a single threshold created actuator chatter. Second, the controller did not combine temperature with rain and door status. Third, it accepted every sensor reading without validation or timeout handling.

Approach and Solution

The revised design samples temperature and humidity once per second and applies a validated moving average. A moving average over N samples is:

x̄k = (1⁄N)∑ⱼ₌₀ᴺ⁻¹ xₖ₋ⱼ

The fan turns on at 28 °C and remains on until temperature falls below 26 °C. This separation is hysteresis and prevents rapid switching. The window opens only when temperature is high, rain is absent, and the door is closed. A timeout places the system in a safe state if sensor communication fails. The motor driver includes limit switches so that software cannot continuously drive the window beyond its mechanical travel.

Outcome

The control loop becomes less sensitive to noise, actuator wear is reduced, and unsafe operation during rain is prevented. The system also reports sensor faults rather than treating missing data as a valid zero. Energy use can be evaluated using fan runtime and motor-operation logs.

Learning Points

Physical-computing design requires more than connecting a sensor to a processor. Filtering, hysteresis, calibration, fault detection, environmental assumptions, and actuator protection are all part of the engineering solution.

11. Limitations, Safety, Ethics, and Contemporary Developments

Sensor systems are vulnerable to calibration drift, ageing, contamination, interference, spoofing, power failure, and communication loss. Safety-critical applications require redundancy, diagnostic coverage, fail-safe states, watchdog timers, isolation, and documented verification. A consumer IoT sensor should not be assumed suitable for medical, industrial, or aviation use without appropriate certification.

Sensors can reveal occupancy, health, location, voice, or behaviour. Data minimization, informed consent, access control, encryption, retention limits, and secure firmware updates are therefore relevant even at the physical layer. A device should collect only what is necessary and should protect raw data as well as derived analytics.

Contemporary systems increasingly use edge machine learning for anomaly detection, predictive maintenance, and adaptive calibration. Such methods can be valuable when cloud connectivity is limited, but they do not eliminate the need for trustworthy sensing. Training-data bias, model drift, explainability, computational cost, and unsafe false negatives must be assessed. AI-generated estimates should retain provenance and uncertainty where decisions have physical consequences.

Best practices are to define requirements quantitatively, use traceable calibration, design analogue anti-alias filtering, separate logic and actuator power where necessary, protect inductive loads, timestamp measurements, validate ranges, log faults, test environmental extremes, and document assumptions.

Chapter Summary

Sensors and actuators create the physical boundary of an IoT system. Sensor design involves selecting an appropriate transducer, modelling its transfer function, conditioning its signal, sampling it correctly, and calibrating the complete measurement chain. Accuracy, precision, resolution, noise, drift, hysteresis, and response time describe different aspects of performance.

Signal conditioning may include excitation, amplification, filtering, isolation, and level conversion. ADC resolution is limited by quantization, while real accuracy also depends on reference stability, nonlinearity, noise, and calibration. Sampling must satisfy the Nyquist condition with practical anti-alias filtering. Calibration and uncertainty analysis distinguish random variation from systematic bias.

Actuators require correctly rated driver circuits, protection from transients, safe startup states, and suitable control methods such as PWM. Sensor fusion can combine complementary observations, but only when assumptions about uncertainty, timing, coordinate systems, and correlation are respected. Reliable physical computing additionally requires fault detection, safety engineering, privacy protection, and environmental validation.

Key Terms

Sensor: A transducer that measures a physical quantity and produces a usable signal.

Actuator: A device that converts a control signal or electrical energy into physical action.

Measurand: The physical quantity intended to be measured.

Sensitivity: Change in sensor output per unit change in input.

Accuracy: Closeness of a measurement to the accepted value.

Precision: Closeness of repeated measurements to one another.

Resolution: Smallest distinguishable change in an input or output.

Bias: Systematic measurement offset.

Noise: Unwanted random variation in a signal.

Drift: Slow change in output under constant input.

Hysteresis: Dependence of output on the direction of input change.

Signal conditioning: Processing that prepares a sensor signal for conversion or interpretation.

ADC: Analogue-to-digital converter.

Aliasing: False low-frequency representation caused by insufficient sampling.

Calibration: Comparison with a reference to establish or correct a measurement relationship.

PWM: Pulse-width modulation used to control power or actuator behaviour.

Sensor fusion: Combination of multiple measurements to estimate a quantity.

Time constant: Parameter describing the speed of a first-order response.

Fail-safe state: A condition designed to minimize harm when a fault occurs.

Review Questions

Short Answer Questions

  1. Distinguish accuracy from precision.
  2. What purpose does an anti-alias filter serve?
  3. Why is a flyback diode used with some actuators?
  4. Define sensor hysteresis.
  5. Name two factors that can cause ADC error besides quantization.

Long Answer Questions

  1. Explain the complete signal path from a physical measurand to a digital IoT decision.
  2. Describe the calibration procedure for a resistive temperature sensor and identify its assumptions.
  3. Compare GPIO, ADC, I²C, SPI, and UART interfaces in terms of typical IoT use.
  4. Explain how sampling frequency, bandwidth, and aliasing are related.
  5. Discuss the engineering and ethical requirements of deploying environmental sensors in occupied buildings.

Analytical / Application Questions

  1. A 10-bit ADC has a 5 V reference and measures a 0–100 °C sensor output spanning 0–5 V. Calculate the ideal ADC voltage step and the corresponding temperature increment, then explain why actual temperature accuracy may be worse.
  2. Design a safe control strategy for a motorized valve using a temperature sensor, two limit switches, a watchdog timer, and a motor driver. Identify normal, fault, and recovery states.
  3. An IMU gives fast but drifting orientation while an accelerometer gives noisy long-term gravity information. Propose a complementary sensor-fusion strategy and explain how you would detect implausible measurements.

Multiple Choice Questions with Answers

Question 1

Which characteristic describes closeness of repeated measurements to one another?

A. Accuracy

B. Precision

C. Sensitivity

D. Range

Correct Answer: B. Precision

Question 2

A first-order sensor has a time constant of 2 s. Approximately what fraction of a step change has appeared after 2 s?

A. 25%

B. 50%

C. 63%

D. 95%

Correct Answer: C. 63%

Question 3

What is the principal purpose of an analogue anti-alias filter?

A. Increase ADC resolution

B. Suppress frequency components before sampling

C. Provide actuator current

D. Calibrate sensor bias

Correct Answer: B. Suppress frequency components before sampling

Question 4

A 12-bit ADC with a 3.3 V reference has an ideal nominal step closest to:

A. 0.806 mV

B. 3.3 mV

C. 12 mV

D. 806 mV

Correct Answer: A. 0.806 mV

Question 5

An ultrasonic sensor measures round-trip travel time. Which relationship gives distance?

A. d = vt

B. d = 2vt

C. d = v⁄2t

D. d = vt⁄2

Correct Answer: D. d = vt⁄2

Question 6

Which component is most appropriate for switching a motor from a microcontroller output?

A. A correctly rated transistor or motor driver

B. A bare GPIO pin

C. An unconnected ADC input

D. A pull-up resistor alone

Correct Answer: A. A correctly rated transistor or motor driver

Question 7

If a sensor output is 2.0 V at 0 units and 3.0 V at 100 units, what value corresponds to 2.5 V under a linear model?

A. 25 units

B. 50 units

C. 75 units

D. 100 units

Correct Answer: B. 50 units

Question 8

Why is hysteresis commonly used in a threshold-based actuator controller?

A. To increase ADC bit depth

B. To prevent rapid switching near the threshold

C. To eliminate all sensor bias

D. To increase communication speed

Correct Answer: B. To prevent rapid switching near the threshold

Question 9

In inverse-variance weighted fusion, an estimate with smaller variance generally receives:

A. A smaller weight

B. A negative weight

C. A larger weight

D. No weight

Correct Answer: C. A larger weight

Question 10

Which statement about integrating inertial measurements is correct?

A. Integration eliminates bias

B. Small bias can accumulate into drift

C. Integration requires no calibration

D. Inertial position is always absolute

Correct Answer: B. Small bias can accumulate into drift

Internet of Things
Chapter 3 of 15