Sensors, Actuators and Embedded DevicesIntroductionAn Internet of Things (IoT) system connects the physical world to software and networks. Sensors observe physical conditions, embedded devices process information, actuators produce physical effects, and communication networks transfer data to other devices or services. The quality of an IoT solution therefore depends not only on cloud software but also on the correct selection, connection, programming and maintenance of field devices. A temperature-monitoring system illustrates the complete chain. A temperature sensor converts heat into an electrical signal. A microcontroller samples and interprets that signal. A communication module sends the measurement to a server. Software compares the value with a set point, and an actuator such as a relay switches a fan. Each stage introduces possible error, delay, energy consumption and failure. This chapter develops the practical foundations needed to design such systems. It examines sensor principles, actuators, microcontrollers, single-board computers, input/output interfaces, sampling, calibration, power management and device selection. Learning ObjectivesAfter studying this chapter, the learner should be able to: - explain how common sensors convert physical variables into electrical signals;
- distinguish accuracy, precision, resolution, sensitivity, range and response time;
- compare digital and analog interfaces and identify suitable GPIO uses;
- describe the roles of microcontrollers and single-board computers;
- select and safely control common actuators;
- apply sampling and calibration principles to sensor measurements;
- estimate basic energy and battery requirements;
- select an embedded device for a practical IoT application;
- identify safety, reliability, security and ethical issues in field deployment.
1. The Physical Interface of an IoT SystemAn embedded IoT node normally contains five functional elements: - Sensing: measurement of temperature, pressure, light, motion, position or another variable.
- Processing: filtering, conversion, decision-making and local control.
- Actuation: switching, moving, heating, illuminating or otherwise affecting the environment.
- Communication: transfer through Wi-Fi, Bluetooth Low Energy, cellular, Ethernet, LoRaWAN or another technology.
- Power: provision, conversion and management of electrical energy.
The signal path can be represented conceptually as: physical quantity → sensor → signal conditioning → input interface → processor → output interface → actuator. A sensor is not simply a measuring device. It is part of a measurement chain whose performance is affected by mounting, wiring, electromagnetic interference, environmental conditions, software and calibration. Similarly, an actuator is not merely an output component: it requires suitable voltage, current, protection and control timing. Important Measurement Terms| Term | Meaning |
|---|
| Range | Minimum to maximum value that a device can measure or produce safely | | Sensitivity | Change in output per unit change in input | | Resolution | Smallest change distinguishable by the system | | Accuracy | Closeness of a measurement to the accepted true value | | Precision | Closeness of repeated measurements to one another | | Linearity | How closely the input-output relationship follows a straight line | | Hysteresis | Difference in output for the same input depending on whether the input is increasing or decreasing | | Response time | Time required to reach a specified fraction of the final output | | Repeatability | Agreement under the same conditions over repeated trials | | Drift | Change in output over time when the input or reference is unchanged |
Accuracy and precision are different. A sensor can produce tightly grouped readings that are consistently offset from the true value: it is precise but inaccurate. Calibration can reduce systematic offset, but it cannot necessarily remove random noise or poor mechanical installation. 2. Sensor PrinciplesSensors use physical effects to transform an input quantity into a measurable output. Common transduction principles include resistance change, capacitance change, generation of voltage, variation in magnetic field, and interaction with light. 2.1 Resistive SensorsA thermistor changes resistance with temperature. A light-dependent resistor changes resistance with illumination. A strain gauge changes resistance when stretched or compressed. These devices are often placed in a voltage divider. For two resistors connected between supply voltage VCC and ground, with the output measured across R2, Vout = VCC × R2/(R1 + R2) where R1 and R2 are in ohms and Vout is in volts. This equation assumes ideal resistors, negligible input current from the measuring device, and a stable supply. If the sensor resistance is R2 = 10 kΩ, R1 = 10 kΩ and VCC = 3.3 V, then Vout = 1.65 V. The divider must be designed so that the expected sensor resistance range produces useful voltages within the input range of the analog-to-digital converter (ADC). Self-heating may occur if excessive current flows through a thermistor or other resistive sensor. 2.2 Capacitive and Inductive SensorsA capacitive sensor detects changes in capacitance caused by distance, humidity, liquid level or touch. Capacitance depends on electrode geometry, dielectric material and separation. Capacitive touch buttons measure a change caused by the human body and generally require shielding and careful layout. Inductive proximity sensors detect conductive objects by observing changes in an electromagnetic field. They are robust in industrial environments but often consume more power than simple passive sensors and may require a separate supply voltage. 2.3 Thermoelectric and Semiconductor SensorsA thermocouple produces a small voltage related to a temperature difference. It can operate over a wide temperature range, but its signal is low-level and requires amplification and reference-junction compensation. Semiconductor temperature sensors may provide an analog voltage or a digital reading and are convenient for moderate temperature ranges. 2.4 Optical and Magnetic SensorsPhotodiodes generate current in response to light, while phototransistors provide amplified switching or analog behavior. Infrared sensors are widely used for proximity and remote-control applications. Hall-effect sensors detect magnetic fields and can measure position, speed or current when combined with a suitable magnetic arrangement. 2.5 Motion, Inertial and Environmental SensorsAccelerometers measure specific force along one or more axes. Gyroscopes measure angular rate. Inertial measurement units combine accelerometers and gyroscopes, sometimes with magnetometers. Air-quality sensors may detect gases through metal-oxide, electrochemical or optical principles. Such sensors differ greatly in selectivity, warm-up time, environmental dependence and calibration requirements; a low-cost gas sensor should not automatically be interpreted as a laboratory-grade concentration analyser. 3. Analog and Digital InterfacesAnalog InterfacesAn analog sensor produces a continuously varying voltage or current. An ADC maps the input range to a finite number of codes. For an ideal ADC with N bits, 2N codes are available. If the ADC input range is from 0 to Vref, the ideal code for an input voltage Vin is approximately Code = floor((Vin/Vref) × (2N − 1)) where floor means rounding down. This assumes the input is within the ADC range, the reference is known and stable, and the ADC is ideal. The ideal voltage step, or least significant bit size, is ΔV = Vref/(2N − 1) although datasheets may define quantization step using 2N intervals. The distinction is small for large N, but the datasheet convention should be followed. For a 12-bit ADC with Vref = 3.3 V and Vin = 1.65 V, the ideal code is approximately (1.65/3.3) × 4095 = 2047.5, so the digital result is about 2047 or 2048 depending on rounding. The theoretical voltage resolution is approximately 3.3/4095 = 0.806 mV per code. Real accuracy is poorer because of reference error, noise, nonlinearity, grounding and input impedance. A current-loop interface such as 4–20 mA is useful over long industrial cables because current is less affected by voltage drop and electromagnetic interference. The 4 mA live zero can also indicate a broken wire when the measured current falls near zero. Digital InterfacesDigital signals represent discrete logic states. A GPIO pin may be configured as an input or output. Important considerations include logic-high and logic-low voltage thresholds, maximum current, pull-up or pull-down resistors, input protection and whether the pin tolerates the connected voltage. Common buses include: - I²C: two-wire addressable bus using serial data and serial clock; convenient for multiple low-speed sensors, but it requires appropriate pull-up resistors and short, carefully routed connections.
- SPI: synchronous bus with clock, data-in, data-out and chip-select signals; generally faster than I²C but uses more wires.
- UART: asynchronous serial communication using transmit and receive lines; useful for modules such as GPS receivers and cellular modems.
- 1-Wire: a low-pin-count bus often used with simple digital sensors; timing and cable conditions must be respected.
A digital sensor may internally perform amplification, conversion and calibration. This does not mean it is error-free: digital readings can still contain offset, noise, quantization and environmental error. 4. Sampling, Filtering and CalibrationA continuous physical signal must be sampled before a digital processor can use it. The sampling frequency is the number of samples per second. To represent a signal with highest frequency fmax without ideal-sampling aliasing, the sampling frequency should satisfy fs > 2fmax This is the Nyquist condition. It assumes the signal has been bandwidth-limited and that sampling is sufficiently ideal. In practice, an anti-aliasing low-pass filter is used before the ADC, and engineers select a margin above the theoretical minimum. If a temperature changes slowly, sampling once per second may be sufficient. A vibration signal containing components up to 500 Hz requires a sampling rate greater than 1 kHz in theory, and typically higher in practice. Sampling faster increases processing, storage and energy consumption. A simple moving average of M samples is y[n] = (1/M) × ∑k=0M−1 x[n−k] where x[n is the current sample and y[n] is the filtered output. It reduces random noise but adds delay and can hide rapid changes. Filtering must therefore match the control and safety requirements. CalibrationCalibration compares a device with a reference and establishes a correction. A simple linear calibration model is ycorrected = a xmeasured + b where a is a scale factor and b is an offset. For two reference points, (x1, y1) and (x2, y2), a = (y2 − y1)/(x2 − x1), b = y1 − ax1 The model is appropriate only when the response is sufficiently linear over the operating range. Multi-point calibration or a lookup table may be required for nonlinear sensors. Calibration records should include the reference instrument, environmental conditions, date, uncertainty and next calibration interval. Calibration does not correct poor installation. A temperature sensor mounted beside a heat-producing regulator may remain wrong even after excellent electrical calibration. 5. Actuators and Output ControlAn actuator converts an electrical command into a physical effect. Examples include: - LEDs and lamps for visual indication;
- buzzers and speakers for audible output;
- relays and solid-state relays for switching loads;
- DC motors, stepper motors and servo motors for motion;
- solenoid valves for fluid control;
- heaters, pumps and fans for environmental control.
Microcontroller pins generally cannot drive high-power loads directly. A transistor or driver is used to provide current gain and electrical isolation where required. A relay coil or motor is inductive; when current is interrupted, the collapsing magnetic field produces a voltage spike. A flyback diode across a suitable DC coil provides a path for this energy. AC loads require appropriately rated relays, fuses, insulation and enclosure design. Pulse-width modulation (PWM) controls average power by switching rapidly. For an ideal load and fixed switching voltage, the duty cycle is D = ton/T where ton is the on-time and T is the switching period. The duty cycle is dimensionless and commonly expressed from 0 to 1 or from 0% to 100%. For an ideal resistive load, the average voltage is approximately Vavg = D Vs, but the actual effect depends on the load, switching frequency and driver. Motors and heaters do not necessarily respond as a simple average-voltage device. Actuator selection must consider voltage, continuous and peak current, starting current, mechanical load, speed, duty cycle, heat dissipation, noise, fail-safe behavior and electrical isolation. A valve that consumes 500 mA at 12 V cannot be powered from a 3.3 V GPIO pin. 6. Microcontrollers and Single-Board ComputersA microcontroller unit (MCU) integrates a processor, memory, timers, GPIO, ADCs and communication peripherals on one chip. It is suited to deterministic, low-power, real-time tasks such as reading sensors, controlling motors and entering sleep modes. Examples include families based on ARM Cortex-M, AVR, PIC and RISC-V architectures. A single-board computer (SBC) is a complete computer on one circuit board. It typically includes a more powerful processor, substantial RAM, storage support and an operating system such as Linux. It is suitable for local databases, graphical interfaces, computer vision, gateways and complex networking. It usually consumes more power and has less deterministic timing than a small MCU. | Criterion | Microcontroller | Single-board computer |
|---|
| Operating system | Often bare-metal or real-time firmware | General-purpose operating system | | Power consumption | Typically low | Typically higher | | Startup time | Very short | Often longer | | Real-time control | Strong | Requires careful design and may be nondeterministic | | Processing and storage | Limited to moderate | Moderate to high | | Best use | Battery nodes and direct control | Gateways, analytics and rich applications |
Many practical products combine both: an MCU performs reliable sensor and actuator control while an SBC or cloud service performs gateway, user-interface or analytics functions. A device choice should be based on requirements rather than popularity. GPIO and Electrical SafetyBefore connecting a component, check the board documentation for voltage levels, absolute maximum ratings, current limits, boot-time states and reserved pins. Never assume that a pin marked “5 V” is a 5 V-tolerant input. A 5 V sensor output connected directly to a 3.3 V-only input can permanently damage the processor. Use a level shifter, voltage divider or compatible interface. Inputs may float when disconnected and produce unpredictable readings. Pull-up or pull-down resistors establish a defined state. Switches require debouncing, either in hardware or software, because mechanical contacts may oscillate for several milliseconds. 7. Power ManagementPower design is often the difference between a prototype and a reliable product. The basic electrical relationships are P = VI and E = Pt where P is power in watts, V is voltage in volts, I is current in amperes, E is energy in joules and t is time in seconds. For a device drawing 80 mA at 3.3 V, the nominal power is 0.08 × 3.3 = 0.264 W. For a battery-powered device, average current is estimated from operating modes: Iavg = (Iactivetactive + Isleeptsleep)/(tactive+tsleep) If a node draws 100 mA for 2 s and 0.2 mA for 58 s in each 60 s cycle, Iavg = (100×2 + 0.2×58)/60 = 3.53 mA. This ideal estimate excludes regulator losses, battery self-discharge, cold-temperature effects, transmission retries and aging. A nominal 2,000 mAh battery would therefore have an ideal operating time of about 2000/3.53 = 567 hours, or 23.6 days, before derating. A real design must apply a safety margin. Power-saving techniques include sleep modes, event-driven sensing, reduced sampling rate, short radio transmissions, local processing, efficient regulators and correct power-domain switching. Capacitors may support short current bursts, but they do not replace a supply capable of delivering the required energy. 8. Selecting Devices for Practical Use CasesA systematic selection process is more reliable than choosing a board first. - Define the measured variables, range, required accuracy and response time.
- Identify environmental conditions such as temperature, moisture, dust, vibration and chemical exposure.
- Determine sampling rate, data volume and control latency.
- Select interfaces and verify voltage compatibility.
- Calculate actuator voltage, current and peak requirements.
- Estimate energy budget and maintenance interval.
- Consider communication coverage, security and software support.
- Check physical dimensions, enclosure, certifications, cost and availability.
- Prototype under realistic conditions and test failure modes.
- Document calibration, wiring, firmware versions and maintenance procedures.
For a greenhouse irrigation node, soil-moisture measurement, temperature, humidity and tank level may be required. A low-power MCU with sleep capability is usually preferable for a battery node. A pump requires a separate power path, a suitably rated MOSFET or relay, flyback protection for DC inductive loads, and a manual or fail-safe shutoff. A moisture sensor should be selected for the soil type and calibrated against actual moisture conditions; an uncalibrated resistive probe may corrode and give misleading results. 9. Illustrative Case: Cold-Storage Monitoring and AlarmBackgroundA small food distributor needs to monitor a refrigerated room. The target temperature is between 2 °C and 8 °C. Staff must receive an alarm if the temperature remains outside this range for more than five minutes. Problem AnalysisA suitable solution must measure accurately in a humid environment, continue recording during network interruptions, avoid false alarms during brief door opening, and operate safely near mains-powered refrigeration equipment. The sensor should be located in representative air, not directly beside the cooling outlet or door. Approach and SolutionA digital temperature sensor with a documented operating range is connected to an MCU through a protected digital bus. The MCU samples once every 10 seconds, stores recent measurements locally and transmits periodic summaries through a gateway. A moving average may reduce short-lived noise, while a timed alarm state prevents a single abnormal reading from triggering an unnecessary response. The alarm logic must include hysteresis. For example, an alarm may activate above 8 °C after five minutes but clear only when the temperature falls below 7.5 °C and remains there for a defined period. This prevents rapid switching at the threshold. A local buzzer and visible indicator provide immediate notification, while a network message informs the supervisor. The system uses a protected power supply and a backup battery sized for the required outage period. The sensing circuit is electrically separated from mains switching equipment. Each installed sensor is compared with a traceable reference thermometer before commissioning, and calibration results are recorded. OutcomeThe design reduces false alarms, provides an auditable temperature history and continues local monitoring during temporary network failure. It does not replace regulatory food-safety procedures: the organization must define acceptable limits, response responsibilities, record retention and verification intervals. Learning PointsThe case demonstrates that device selection involves more than sensor accuracy. Placement, sampling, filtering, hysteresis, power continuity, communication failure, calibration, human response and electrical safety are all part of the IoT engineering problem. 10. Challenges, Ethics and Best PracticesSensors may fail open, fail short, freeze at a constant value or slowly drift. Software should detect impossible values, missing samples, rapid unrealistic changes and communication loss. Redundant sensors may be justified where failure threatens safety or major financial loss. IoT devices can collect information about people, homes, workplaces and health. Designers should minimize data collection, protect credentials, encrypt communications where appropriate, restrict access, update firmware and avoid exposing debug interfaces in production. A motion sensor in a workplace may have privacy implications even if it does not record images. Users should understand what is collected, why it is collected and how long it is retained. Professional practice includes: - use datasheets and verified electrical limits rather than assumptions;
- separate high-current and signal paths where possible;
- provide fuses, grounding, shielding and enclosure protection;
- use watchdog timers and safe startup states;
- log sensor quality and calibration status, not only measurements;
- test at temperature, voltage and load extremes;
- design for maintenance, replacement and end-of-life disposal;
- follow applicable electrical, radio, machinery, environmental and data-protection regulations.
Contemporary systems increasingly use edge machine learning for anomaly detection, predictive maintenance and sensor fusion. Such techniques can reduce bandwidth and response time, but they do not eliminate the need for reliable raw measurements, representative training data, explainable alarms and human oversight. Artificial intelligence cannot compensate for a badly installed or uncalibrated sensor. Chapter SummarySensors translate physical conditions into electrical signals through resistive, capacitive, inductive, optical, magnetic, thermoelectric and semiconductor effects. Their performance must be described using range, sensitivity, resolution, accuracy, precision, response time, hysteresis and drift. Analog interfaces require attention to ADC resolution, reference voltage, quantization and noise; digital interfaces require correct logic levels, bus wiring and timing. Sampling must be fast enough for the signal bandwidth and should normally be preceded by appropriate filtering. Calibration establishes a relationship between measured and reference values, but it cannot correct poor installation or all environmental effects. Actuators require suitable drivers, protection, power supplies and fail-safe behavior. Microcontrollers are generally efficient and deterministic, whereas single-board computers provide richer operating systems and greater processing capability at higher power cost. Power calculations use P = VI, E = Pt and duty-cycle estimates. Practical device selection considers measurement requirements, environment, interfaces, actuator loads, energy, communication, security, maintenance and regulation. Reliable IoT engineering treats the sensor, processor, actuator, power system, software and human response as one integrated system. Key TermsSensor: Device that detects a physical quantity and produces a corresponding signal. Actuator: Device that converts an electrical command into a physical action. Transducer: Device or element that converts one form of energy or physical quantity into another. Microcontroller: Integrated circuit containing a processor, memory and peripherals for embedded control. Single-board computer: Complete computer system implemented on one circuit board. GPIO: General-purpose input/output pin used for digital interfacing. ADC: Analog-to-digital converter that maps an analog input to digital codes. PWM: Pulse-width modulation using duty cycle to control average output power. Sensitivity: Change in sensor output per unit change in input. Accuracy: Closeness of a measurement to an accepted reference value. Precision: Agreement among repeated measurements. Resolution: Smallest distinguishable change in a measurement. Calibration: Comparison with a reference to determine or correct measurement behavior. Drift: Change in output over time without a corresponding input change. Sampling: Measuring a continuous signal at discrete times. Aliasing: Misrepresentation of signal frequency caused by inadequate sampling. GPIO pull-up: Resistor that biases a digital input toward the supply voltage. Flyback diode: Diode that limits voltage produced when current in an inductive load is interrupted. Duty cycle: Fraction of a switching period during which a signal is active. Hysteresis: Different switching thresholds for increasing and decreasing inputs. Review QuestionsShort Answer Questions- Distinguish accuracy from precision.
- What is the purpose of an ADC?
- Why should a flyback diode be used with a DC relay coil?
- State two differences between a microcontroller and a single-board computer.
- Why is calibration not a substitute for correct sensor placement?
Long Answer Questions- Explain the operation and design considerations of analog and digital sensor interfaces.
- Discuss sampling, aliasing and filtering in an IoT measurement system.
- Compare microcontrollers and single-board computers for battery-powered and gateway applications.
- Explain the main electrical and mechanical factors involved in actuator selection.
- Describe a systematic process for selecting sensors, processors, communication interfaces and power supplies for an IoT product.
Analytical / Application Questions- An analog sensor is connected to a 12-bit, 3.3 V ADC. Explain the expected digital code for a 1.65 V input and identify at least three reasons why a practical result may differ.
- Design a monitoring approach for a water tank that must detect low level, operate for several months on a battery and activate a pump safely. Justify the sensor, controller, sampling, power and actuator choices.
- A temperature alarm oscillates repeatedly when the measured value is close to its threshold. Analyse the likely cause and propose a solution involving filtering, hysteresis and timing.
Multiple Choice Questions with AnswersQuestion 1Which characteristic describes closeness of repeated measurements to one another? A. Accuracy B. Precision C. Range D. Sensitivity Correct Answer: B. Precision Question 2A 3.3 V supply is connected to two equal resistors in a voltage divider. What is the ideal midpoint output voltage? A. 0 V B. 1.65 V C. 3.3 V D. 6.6 V Correct Answer: B. 1.65 V Question 3What is the main purpose of an ADC? A. To convert a digital code into mechanical motion B. To convert an analog signal into a digital representation C. To increase battery capacity D. To isolate a relay coil from mains voltage Correct Answer: B. To convert an analog signal into a digital representation Question 4Which interface normally uses serial data and serial clock lines and supports addressed devices? A. I²C B. PWM C. UART only D. Analog voltage divider Correct Answer: A. I²C Question 5A flyback diode is commonly placed across which type of load? A. Resistive heater B. Inductive DC coil C. Photodiode D. Pull-down resistor Correct Answer: B. Inductive DC coil Question 6A signal contains frequency components up to 500 Hz. Which sampling frequency satisfies the ideal Nyquist condition? A. 250 Hz B. 500 Hz C. 800 Hz D. More than 1,000 Hz Correct Answer: D. More than 1,000 Hz Question 7A device draws 100 mA for 2 seconds and 0.2 mA for 58 seconds in every 60-second cycle. What is its approximate average current? A. 0.20 mA B. 2.00 mA C. 3.53 mA D. 100 mA Correct Answer: C. 3.53 mA Question 8Which device is generally best suited to low-power, deterministic direct control of sensors and motors? A. Microcontroller B. Desktop workstation C. Cloud database D. Passive network switch Correct Answer: A. Microcontroller Question 9What problem does hysteresis help prevent in a threshold-controlled actuator? A. ADC quantization B. Rapid switching near the threshold C. Battery self-discharge D. Sensor range expansion Correct Answer: B. Rapid switching near the threshold Question 10Which statement is a best practice when connecting a 5 V sensor to a 3.3 V-only input? A. Connect it directly because GPIO pins accept all voltages B. Remove the sensor ground connection C. Use a suitable level-shifting or voltage-reduction method D. Increase the sampling frequency Correct Answer: C. Use a suitable level-shifting or voltage-reduction method
|