Sensors, Actuators and Embedded DevicesIntroduction and ContextAn Internet of Things (IoT) system connects physical objects to communication networks so that they can be monitored, controlled, and analysed. Its intelligence begins at the edge: sensors observe physical conditions, embedded devices process measurements, actuators influence the environment, and communication interfaces transfer information to other devices or cloud services. Artificial intelligence and machine learning are useful only when the underlying measurements are sufficiently accurate, timely, and representative. Consequently, sensor and embedded-device engineering is a foundation for reliable IoT and AI systems. A typical IoT measurement chain is: Physical phenomenon → sensor → signal conditioning → sampling and ADC → embedded processing → communication → storage or AI analysis A control chain reverses part of this process: Decision or control algorithm → DAC or PWM → driver circuit → actuator → physical process This chapter examines the principles and practical design of this chain, including device selection, calibration, energy management, operating systems, and prototyping. Learning ObjectivesAfter completing this chapter, a student should be able to: 1. Explain how common sensors and actuators operate. 2. Distinguish analogue and digital signals and describe signal-conditioning methods. 3. Analyse sampling, quantisation, ADC, DAC, and PWM requirements. 4. Select a suitable microcontroller, sensor, actuator, and embedded operating system for an IoT application. 5. Design basic GPIO interfaces and identify electrical risks. 6. Explain calibration, uncertainty, energy management, and low-power operation. 7. Develop and evaluate a hardware prototype for an AI-enabled IoT application. 8. Identify safety, privacy, environmental, and regulatory issues in device deployment. 1. Sensors and Measurement PrinciplesA sensor converts a physical quantity into a usable electrical signal. The quantity being measured is the measurand. Examples include temperature, pressure, acceleration, light intensity, humidity, gas concentration, distance, and magnetic field. Sensors can be classified in several ways: - Active sensors generate an electrical output from the measurand, such as a thermocouple or piezoelectric sensor.
- Passive sensors require an external excitation, such as a thermistor, strain gauge, or resistive humidity sensor.
- Analogue sensors produce a continuously varying voltage or current.
- Digital sensors contain internal electronics and communicate using protocols such as I²C, SPI, UART, or CAN.
- Contact sensors physically interact with the object; non-contact sensors use optical, magnetic, acoustic, or electromagnetic coupling.
Sensor characteristicsRange is the interval over which a sensor operates acceptably. Sensitivity is the change in output per unit change in input. For an approximately linear sensor, \[ S = \frac{\Delta y}{\Delta x} \] where \(x\) is the measurand and \(y\) is the sensor output. Sensitivity may be expressed in volts per degree Celsius, millivolts per kilopascal, or counts per metre. Resolution is the smallest input change that can be distinguished. Accuracy describes closeness to the accepted reference value, whereas precision describes repeatability. A sensor may be precise but inaccurate if it has a systematic offset. Linearity indicates how closely the output follows a chosen linear relationship. Hysteresis occurs when the output depends on whether the input is increasing or decreasing. Repeatability concerns results under the same conditions; reproducibility concerns results under changed conditions, such as different operators or instruments. Response time describes how quickly the output follows an input change. A first-order approximation is often used for thermal or chemical sensors: \[ y(t)=y_\infty +(y_0-y_\infty)e^{-t/\tau} \] where \(y_0\) is the initial output, \(y_\infty\) is the final steady output, and \(\tau\) is the time constant. After one time constant, approximately 63.2% of the total step change has occurred; after about five time constants, the response is approximately 99.3% complete. This model applies when the sensor behaves approximately as a single first-order system. Drift is a gradual change in output for a constant input. It may result from ageing, temperature, humidity, mechanical stress, or contamination. Noise is unwanted random variation. Dead band is an input interval producing no measurable output change, while saturation occurs when further input changes cannot produce further output changes. Examples of sensing technologiesA thermistor changes resistance with temperature. A negative-temperature-coefficient thermistor generally decreases in resistance as temperature increases. Because its response is nonlinear, a voltage-divider circuit and calibration model are commonly required. A thermocouple produces a small voltage related to a temperature difference. It is inexpensive and suitable for high temperatures, but requires cold-junction compensation and low-noise amplification. An accelerometer measures acceleration, often through a microelectromechanical system (MEMS) proof mass. Its output includes gravity, vibration, bias, and noise. Orientation can therefore be inferred in static conditions, but not reliably during strong dynamic motion without additional information. Optical sensors use emitted and reflected or interrupted light. Ultrasonic distance sensors estimate range from the time of flight of sound. For a pulse travelling to a target and back, \[ d=\frac{vt}{2} \] where \(d\) is distance, \(v\) is the speed of sound in the medium, and \(t\) is round-trip time. The factor of two is required because the pulse travels to the target and returns. Temperature and air movement affect the speed of sound. 2. Signal ConditioningRaw sensor outputs are rarely suitable for direct conversion or computation. Signal conditioning adapts the signal to the embedded system. Common functions include amplification, attenuation, filtering, isolation, linearisation, excitation, level shifting, protection, and multiplexing. An instrumentation amplifier is useful for small differential signals because it can provide 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. Excessive gain causes clipping; insufficient gain wastes resolution. A voltage divider using resistors \(R_1\) and \(R_2\), with the output measured across \(R_2\), gives \[ V_{out}=V_{in}\frac{R_2}{R_1+R_2} \] This equation assumes ideal resistors and negligible loading by the connected circuit. If the load resistance is comparable to \(R_2\), the effective resistance changes and the unloaded formula is inaccurate. Filters reduce unwanted frequency components. A simple first-order RC low-pass filter has cutoff frequency \[ f_c=\frac{1}{2\pi RC} \] where \(R\) is resistance in ohms and \(C\) is capacitance in farads. Frequencies substantially above \(f_c\) are attenuated, while lower frequencies pass with less attenuation. A filter must not remove information required by the application, and its transient response must be considered. Analogue grounding, shielding, short signal paths, differential measurement, decoupling capacitors, and careful cable routing reduce interference. Motors, relays, radios, and switching regulators are common sources of electromagnetic noise. Protection components such as series resistors, transient suppressors, current-limiting resistors, and fuses help prevent damage. 3. Sampling, Quantisation, ADC, DAC and PWMSamplingAn analogue signal must be sampled before digital processing. The sampling frequency \(f_s\) should be greater than twice the highest significant frequency \(f_{max}\) in a band-limited signal: \[ f_s>2f_{max} \] This is the Nyquist criterion. It prevents ideal-sampling aliasing only when the signal is properly band-limited and the sampling process is ideal. In practice, an anti-aliasing low-pass filter is placed before the ADC, and engineers normally select a sampling rate higher than the theoretical minimum. Aliasing occurs when higher-frequency components appear as false lower-frequency components. It can cause an AI model to learn misleading patterns, especially in vibration, audio, and biomedical applications. ADC operationAn analogue-to-digital converter maps an input voltage to a finite set of digital codes. For an ideal unipolar ADC with resolution \(N\) bits and reference voltage \(V_{ref}\), the number of codes is \(2^N\), and the nominal quantisation step is \[ q=\frac{V_{ref}}{2^N} \] The actual code convention may use a full-scale endpoint differently, but \(q\) is the usual ideal step-size approximation. Quantisation error is commonly bounded by approximately ±\(q/2\) for rounding under ideal assumptions. Real ADC accuracy is also affected by offset error, gain error, integral nonlinearity, differential nonlinearity, reference stability, noise, and input settling. An ADC with more bits does not automatically provide equivalent effective accuracy. The analogue noise floor, reference quality, layout, and effective number of bits determine useful performance. Oversampling and averaging can reduce random noise in suitable systems, but cannot remove systematic errors or aliasing. DAC and PWMA digital-to-analogue converter produces an analogue voltage or current from a digital code. DACs are used in waveform generation, instrumentation, and closed-loop control. Many microcontrollers do not contain a true DAC; instead, they use pulse-width modulation (PWM) followed by a suitable load or low-pass filter. For PWM, the duty cycle is \[ D=\frac{t_{on}}{T} \] where \(t_{on}\) is the on-time and \(T\\) is the period. Under suitable filtering and load conditions, the average output of a 0-to- \(V\) PWM signal is approximately \[ V_{avg}\approx D V \] This is not equivalent to an instantaneous analogue voltage. Ripple, switching frequency, load dynamics, and electromagnetic emissions must be considered. Worked example: ADC selectionA sensor produces 0–3.3 V and changes by at least 2 mV for an event that must be distinguished. An ideal 10-bit ADC has \[ q=\frac{3.3}{1024}=0.00322\text{ V}=3.22\text{ mV} \] Thus, the nominal code spacing is larger than the required 2 mV change. A 12-bit ADC gives \[ q=\frac{3.3}{4096}=0.000806\text{ V}=0.806\text{ mV} \] which provides adequate nominal resolution. This conclusion assumes the reference is stable and total noise and nonlinearity are smaller than the measurement margin. The 12-bit choice does not guarantee 0.806 mV accuracy. 4. Actuators and Driver CircuitsAn actuator converts an electrical command into physical action. Examples include LEDs, buzzers, heaters, solenoid valves, relays, motors, pumps, and servo mechanisms. Actuators require drivers because a microcontroller GPIO pin usually cannot supply the voltage or current demanded by a motor, heater, or solenoid. A transistor or MOSFET can switch a higher-current load. Inductive loads require a flyback diode or an equivalent suppression method to limit the voltage generated when current is interrupted. A relay provides electrical isolation in some configurations but has finite lifetime, switching noise, and slower operation than semiconductor devices. DC motors are commonly controlled through an H-bridge, which permits forward and reverse operation. Brushless motors require specialised electronic commutation. Servos typically interpret pulse timing rather than simply average voltage. Heaters may use on/off control, time-proportional control, or closed-loop proportional–integral–derivative control. Actuator selection must consider force or torque, speed, stroke, accuracy, duty cycle, power, thermal limits, environmental protection, failure mode, and maintenance. A device that meets a nominal force requirement may still fail if its startup current, heat dissipation, or mechanical duty cycle is ignored. 5. Microcontrollers, GPIO and Embedded Operating SystemsA microcontroller integrates a processor core, memory, timers, GPIO, communication peripherals, interrupt logic, and often ADC, PWM, security, and power-management functions. Compared with a general-purpose computer, it normally offers lower power consumption, deterministic peripheral control, and limited memory. GPIO designGPIO pins may be configured as digital inputs or outputs, with optional pull-up or pull-down resistors. Inputs should not be left floating because electrical noise can produce unpredictable logic transitions. A push-button often requires debouncing, either in hardware with an RC network and Schmitt trigger or in software by requiring a stable state for a defined interval. Open-drain or open-collector interfaces allow several devices to share a line, provided a pull-up resistor is used and electrical voltage limits are respected. I²C commonly uses this arrangement. SPI generally provides higher throughput but requires separate chip-select signals. UART is simple and point-to-point, while CAN is designed for robust multi-node communication in electrically noisy environments. GPIO limits include maximum source and sink current, total port current, voltage thresholds, injection-current limits, and boot-configuration constraints. LEDs require a current-limiting resistor. Directly connecting a motor, relay coil, or high-voltage source to a GPIO pin can permanently damage the microcontroller. Embedded software and operating systemsA bare-metal program may provide minimal latency and resource use but requires the developer to implement scheduling and device management. A real-time operating system (RTOS) provides tasks, queues, semaphores, timers, and interrupt-safe communication. Its defining concern is predictable response within deadlines, not simply high average speed. A general-purpose embedded Linux system offers networking, storage, drivers, and application frameworks, but typically requires more memory and power and may have less deterministic timing. The operating-system choice depends on latency, memory, security, connectivity, update requirements, development expertise, and safety constraints. Interrupt service routines should be short: capture essential information, clear the interrupt condition, and defer lengthy processing to a task or main loop. Shared data require suitable synchronisation. Race conditions, priority inversion, deadlock, stack overflow, watchdog failure, and inadequate fault handling are common embedded defects. 6. Device Selection and CalibrationDevice selection begins with requirements rather than component availability. A requirements table should specify measurand, range, accuracy, resolution, response time, operating temperature, supply voltage, communication interface, physical size, lifetime, cost, certification, environmental rating, and maintenance assumptions. The designer must distinguish sensor specifications from system-level performance. A highly accurate sensor may be wasted if the mounting arrangement introduces larger errors. Conversely, a low-cost sensor may be acceptable when the application needs trend detection rather than absolute measurement. Calibration establishes the relationship between sensor output and a reference. A two-point linear calibration can be represented as \[ x=ay+b \] where \(y\) is measured output, \(x\) is estimated measurand, and \(a\) and \(b\) are obtained from reference observations. If reference points are \((y_1,x_1)\) and \((y_2,x_2)\), then \[ a=\frac{x_2-x_1}{y_2-y_1}, \qquad b=x_1-ay_1 \] This method assumes a stable, approximately linear relationship over the operating interval. Nonlinear sensors may require a lookup table, polynomial approximation, or physically based model. Calibration must document conditions, reference instruments, uncertainty, date, and recalibration interval. Calibration is different from validation. Calibration adjusts or estimates the measurement relationship; validation tests whether the complete system meets its intended requirement under representative conditions. 7. Energy ManagementEnergy is a system-level constraint, especially for battery-powered and remote IoT devices. Average power is \[ P_{avg}=\frac{1}{T}\int_0^T v(t)i(t)\,dt \] For a constant-voltage system with discrete operating states, it can be approximated by \[ P_{avg}\approx\sum_i D_iP_i \] where \(D_i\) is the fraction of time in state \(i\), and the duty fractions sum to one. Battery life depends on battery capacity, discharge characteristics, temperature, conversion losses, ageing, and peak-current capability; a simple estimate using energy divided by average power is only approximate. Important techniques include sleep modes, event-driven wake-up, sensor duty cycling, adaptive sampling, local feature extraction, reduced radio transmissions, efficient voltage regulation, and power-aware firmware. A radio may consume more energy during a short transmission than a sensor consumes during a long measurement, so communication architecture deserves careful analysis. Energy management must not compromise measurement quality. Excessive duty cycling can miss events, while aggressive voltage scaling may reduce processing reliability. Energy harvesting from light, vibration, heat, or radio frequency sources can extend lifetime, but harvested energy is intermittent and requires storage and power budgeting. 8. Hardware Prototyping and VerificationA robust prototype proceeds through requirements, block diagram, component selection, schematic, simulation or breadboard experiment, PCB design, firmware bring-up, calibration, environmental testing, and documentation. Breadboards are convenient but introduce parasitic capacitance, unreliable contacts, and poor high-frequency performance. They are unsuitable for many high-current, high-speed, or safety-critical designs. Bring-up should be incremental. First verify power rails and current consumption; then test reset and clock operation; next verify one peripheral at a time; finally integrate sensing, communication, and actuation. Use a multimeter, oscilloscope, logic analyser, current probe, and programmable supply where appropriate. Test both normal and abnormal conditions: sensor disconnection, short circuits, low battery, communication loss, invalid commands, thermal extremes, electromagnetic interference, and reboot during operation. Include watchdog recovery, safe actuator defaults, data-quality flags, and fault logs. 9. Applied Case: Illustrative Smart Greenhouse NodeBackgroundConsider an illustrative university project developing a battery-assisted IoT node for a small greenhouse. The node must monitor temperature, relative humidity, soil moisture, and light, then control ventilation and irrigation while sending selected data to an AI service that predicts plant stress. ProblemThe first prototype samples every sensor continuously and transmits all readings every minute. Its battery lasts only four days. Temperature readings also fluctuate when the ventilation fan starts, causing false stress alerts. AnalysisThe fan creates electrical and mechanical interference. The soil-moisture sensor is also affected by electrode corrosion and requires periodic calibration. Continuous radio operation dominates energy use. The AI model does not require every raw sample; it needs reliable features such as temperature range, humidity trend, and moisture change rate. Approach and solutionThe redesigned node uses a low-power microcontroller with sleep capability. Temperature and humidity are sampled every five minutes, while a low-power threshold circuit wakes the controller when temperature exceeds a safety limit. An RC filter and software median filtering reduce fan-related disturbances, while sensor wiring is separated from motor wiring. The fan is driven by a MOSFET with flyback protection, and a fail-safe rule turns ventilation on if temperature exceeds a critical limit or if communication with the controller is lost. The firmware computes local hourly summaries and transmits them rather than every raw sample. Soil-moisture readings are calibrated at dry and wet reference conditions, and a quality flag is transmitted when the probe is disconnected. The irrigation pump is controlled through a properly rated driver and relay or solid-state interface, with isolation where required. OutcomeIn a representative trial, the duty-cycled design reduces communication activity and extends battery life substantially compared with continuous transmission. More importantly, the resulting data are cleaner and more semantically useful. The AI model receives calibrated features and fewer interference-induced false events. Learning pointsThe case demonstrates that IoT performance is not determined by the AI model alone. Sensor installation, analogue conditioning, sampling strategy, calibration, driver design, communication policy, and fail-safe behaviour jointly determine system quality. It also illustrates that local processing can improve both energy efficiency and data quality. 10. Challenges, Ethics and Contemporary DevelopmentsSensor readings can reveal sensitive information about people, homes, workplaces, health, or industrial processes. Data minimisation, access control, encryption, secure boot, signed firmware, credential protection, and timely patching are essential. Devices should collect only data necessary for a stated purpose and should communicate clearly when sensing occurs. Safety is particularly important when actuators control heat, pressure, motion, chemicals, vehicles, or medical equipment. Designs should follow applicable electrical, electromagnetic-compatibility, radio, environmental, and functional-safety requirements. Certification is not a substitute for engineering analysis. Environmental concerns include battery disposal, rare materials, electronic waste, repairability, and the energy consumed by cloud processing. Long-lived devices require secure update mechanisms and component availability planning. Contemporary developments include edge AI accelerators, event-based cameras, energy-harvesting nodes, flexible and wearable sensors, sensor fusion, digital twins, and TinyML. Sensor fusion combines complementary observations, such as accelerometer and gyroscope data, to improve estimation. However, more sensors increase calibration, synchronisation, attack surface, and maintenance requirements. AI should therefore be deployed only when it provides value beyond transparent rules or conventional signal processing. Chapter SummarySensors convert physical phenomena into electrical information, but their range, sensitivity, accuracy, precision, resolution, drift, noise, and response time determine the usefulness of that information. Signal conditioning adapts raw outputs through amplification, filtering, protection, isolation, and linearisation. Sampling must address bandwidth and aliasing; ADC resolution determines nominal quantisation step, while real performance also depends on noise, reference quality, and nonlinearity. DACs and PWM provide controlled analogue or power outputs. Actuators require correctly sized driver circuits, protection, and consideration of mechanical and thermal limits. Microcontrollers integrate processing and peripherals, while GPIO design must respect voltage, current, floating-input, and inductive-load constraints. Bare-metal systems, RTOSs, and embedded Linux offer different trade-offs in determinism, resources, connectivity, and complexity. Professional device selection begins with measurable requirements. Calibration establishes a measurement relationship, while validation tests complete-system performance. Energy management uses sleep states, duty cycling, local processing, and communication reduction without sacrificing important events. Hardware prototypes should be brought up incrementally and tested under both normal and fault conditions. Secure, safe, maintainable, and environmentally responsible design is essential when IoT devices interact with the physical world and provide data to AI systems. Key TermsSensor: A device that converts a physical measurand into a usable signal. Measurand: The physical quantity intended to be measured. Sensitivity: Change in sensor output per unit change in input. Accuracy: Closeness of a measurement to an accepted reference value. Precision: Repeatability of measurements under specified conditions. Resolution: Smallest distinguishable change in an input or output. Drift: Gradual change in output for a constant input. Hysteresis: Dependence of output on the direction of input change. Signal conditioning: Processing that prepares a sensor signal for conversion or computation. Aliasing: False low-frequency representation caused by inadequate sampling. ADC: Analogue-to-digital converter. DAC: Digital-to-analogue converter. PWM: Pulse-width modulation using variable duty cycle. Actuator: Device that converts an electrical command into physical action. GPIO: General-purpose input/output pin. Microcontroller: Integrated processor containing memory and peripheral interfaces. RTOS: Real-time operating system designed for predictable task timing. Calibration: Establishment or adjustment of a relationship between output and reference input. Duty cycling: Alternating active and low-power states to reduce average energy use. Sensor fusion: Combination of measurements from multiple sensors to improve estimation. Review QuestionsShort Answer Questions1. Distinguish accuracy from precision and give an example of a precise but inaccurate sensor. 2. Why is an anti-aliasing filter used before an ADC? 3. State two reasons a microcontroller GPIO pin should not drive a motor directly. 4. What is the purpose of calibration? 5. Name two techniques for reducing energy consumption in an IoT node. Long Answer Questions1. Explain the complete signal path from a physical measurand to an AI application, including sensor, conditioning, sampling, ADC, processing, and communication. 2. Compare a bare-metal program, an RTOS, and embedded Linux for an IoT device. 3. Discuss the principal characteristics used to evaluate and select a sensor. 4. Explain how an actuator driver protects a microcontroller and enables control of a high-power load. 5. Describe a systematic hardware-prototyping and verification process for an IoT device. Analytical / Application Questions1. A 0–3.3 V sensor must resolve changes of 1.5 mV. Compare the nominal quantisation steps of 10-bit and 12-bit ADCs and recommend one, stating limitations of the recommendation. 2. Design a sampling and filtering strategy for a vibration sensor whose useful signal extends to 200 Hz. Explain how you would reduce aliasing and choose a practical sampling rate. 3. Propose a low-power architecture for a remote environmental node that must detect rare events, transmit summaries, and safely control an actuator. Justify the sensing, processing, communication, and fail-safe choices. Multiple Choice Questions with AnswersQuestion 1Which characteristic describes closeness of a measurement to an accepted reference value? A. Accuracy B. Precision C. Resolution D. Sensitivity Correct Answer: A. Accuracy Question 2A first-order sensor has a time constant of 2 seconds. Approximately how long is required to reach 99.3% of a step response? A. 0.5 seconds B. 2 seconds C. 5 seconds D. 10 seconds Correct Answer: D. 10 seconds Question 3What is the main purpose of an anti-aliasing filter? A. Increase GPIO current B. Limit high-frequency content before sampling C. Convert digital data to analogue voltage D. Provide mechanical isolation Correct Answer: B. Limit high-frequency content before sampling Question 4What is the nominal quantisation step of an ideal 12-bit ADC with a 3.3 V reference? A. 0.806 mV B. 1.65 mV C. 3.3 mV D. 12 mV Correct Answer: A. 0.806 mV Question 5Why is a flyback diode commonly placed across a DC relay coil? A. To increase sensor sensitivity B. To reduce ADC resolution C. To limit the voltage produced when coil current is interrupted D. To create a higher PWM frequency Correct Answer: C. To limit the voltage produced when coil current is interrupted Question 6Which interface commonly uses open-drain lines with pull-up resistors? A. I²C B. Analogue thermocouple output C. A basic DAC output D. A crystal oscillator Correct Answer: A. I²C Question 7For a 0–5 V PWM signal with a 40% duty cycle, what ideal average voltage is expected after suitable filtering? A. 0.4 V B. 2.0 V C. 3.0 V D. 5.0 V Correct Answer: B. 2.0 V Question 8Which statement best distinguishes calibration from validation? A. Calibration tests battery capacity; validation tests radio range B. Calibration establishes a measurement relationship; validation tests whether the system meets its intended requirement C. Calibration is only for digital sensors; validation is only for analogue sensors D. Calibration removes all measurement uncertainty; validation is unnecessary Correct Answer: B. Calibration establishes a measurement relationship; validation tests whether the system meets its intended requirement Question 9Which design choice generally reduces average energy consumption in a battery-powered IoT node? A. Continuous radio transmission B. Keeping all sensors permanently active C. Duty cycling and local feature extraction D. Increasing actuator startup current Correct Answer: C. Duty cycling and local feature extraction Question 10What is the principal purpose of an RTOS in an embedded system? A. Guarantee unlimited memory B. Provide predictable task and response timing C. Replace all sensor calibration D. Convert every analogue signal into a mechanical movement Correct Answer: B. Provide predictable task and response timing
|