IoT-based data acquisition and automation
IoT data acquisition and automation: sensors → signal conditioning → ADC → microcontroller → communication → cloud/app → decision/control → actuator, including sampling, quantization, protocols, and basic control.
Drafted with Aria, reviewed by the AiCanCode.org team · Updated . How we write and check our notes. Spotted an error? Use Give Feedback at the bottom of the page.
Why it matters
Engineers use IoT-based data acquisition and automation to measure real-world quantities (temperature, pressure, motion) and automatically control systems (pumps, lights, motors) in homes, factories, farms, and healthcare. Understanding the complete chain from sensor to cloud to actuator helps you design reliable, accurate, and safe systems that work in noisy, resource-limited, real environments.
Key ideas
- Automation: Using measurements and logic to make a system act without human intervention, via actuators.
Typical IoT DAQ and automation chain (describe this block diagram if asked to draw):
- Sensor/transducer → 2) Signal conditioning → 3) Analog-to-digital conversion (ADC) → 4) Microcontroller (MCU) with firmware → 5) Communication interface/protocol → 6) Cloud/server/app → 7) Decision/control logic → 8) Actuator/driver. Draw left-to-right blocks with arrows; label each block with its role and main signals (analog in, digital data, control PWM/GPIO out). Add a feedback arrow from actuator/system back to sensor to show a closed loop.
Core definitions and principles:
- Sensor / transducer: A device that converts a physical quantity (temperature, pressure, light) into an electrical signal (voltage, current, resistance). Examples: thermistor (resistance vs temperature), photodiode (current vs light), strain gauge (resistance vs strain), accelerometer (voltage vs acceleration).
- Signal conditioning: Circuits that prepare the sensor signal for ADC: amplification (op-amp, instrumentation amplifier), filtering (anti-alias low-pass), level shifting and protection (clamps, divider), and impedance matching (buffer). Assumption: the conditioned signal stays within ADC input range and bandwidth.
- Sampling: Measuring an analog signal at discrete instants separated by sampling period Ts = 1/fs. The Nyquist–Shannon sampling theorem states: For a band-limited signal with maximum frequency B hertz, exact reconstruction is possible if the sampling frequency satisfies fs ≥ 2·B. Assumptions: ideal sampling, perfect anti-alias filter, and signal strictly band-limited to B.
- Aliasing: Distortion where higher-frequency components fold into lower frequencies when fs < 2·B. Prevention: use an anti-alias filter (typically an analog low-pass) to limit signal bandwidth to below fs/2 (Nyquist frequency).
- Analog-to-Digital Converter (ADC): A circuit that produces a digital code corresponding to input voltage. Key specs: resolution (N bits), input range (Vref_low to Vref_high), sampling rate (samples per second), integral/differential nonlinearity (INL/DNL), and effective number of bits (ENOB).
- Resolution (ADC): The number of discrete output levels 2^N. The quantization step size Δ is the smallest voltage change distinguishable ideally: Δ = (Vref_high − Vref_low)/2^N.
- Quantization error: The difference between true input and quantized output. For an ideal mid-tread quantizer, maximum error is ±Δ/2 and RMS quantization noise is Δ/√12, assuming a uniform distribution.
- Signal-to-Quantization-Noise Ratio (SQNR): For a full-scale sine wave and ideal N-bit ADC, SQNR ≈ 6.02·N + 1.76 dB.
- Microcontroller (MCU): A small computer on a chip with CPU, memory, peripherals (ADC, timers), GPIO (digital input/output), and communication interfaces (UART, I2C, SPI). It runs firmware to read sensors, process data, communicate, and drive actuators. See the separate topic “Microcontroller basics” for CPU and memory details.
- Communication interface: The physical and link-level method for data transfer. Common embedded buses: UART (asynchronous serial, point-to-point), I2C (two-wire multi-drop, master–slave, address-based), SPI (four-wire master–slave, high speed). Network protocols for IoT: Wi‑Fi, Bluetooth LE, LoRa, cellular (GSM/4G) at physical/MAC layers; application protocols like MQTT (publish/subscribe, lightweight), and HTTP/HTTPS (request/response).
- Throughput (data rate): Bits per second needed to send data. Approximate as samples per second × bits per sample × number of channels, plus protocol overhead.
- Actuator: A device that converts electrical signals into physical action: DC motor, solenoid valve, relay, LED, heater. Often needs a driver stage (transistor/MOSFET, H‑bridge) because MCU GPIO cannot supply required current/voltage.
- Control loop: A system that uses feedback from sensors to adjust actuator output to achieve a setpoint. Types: open-loop (no feedback) and closed-loop (with feedback). Simple control laws: bang-bang (on/off with hysteresis) and proportional control. More advanced like PID are beyond first-year scope (mention only if asked).
- Pulse-Width Modulation (PWM): A digital technique to control power by switching a fixed-voltage signal on and off with duty cycle D = ton/T. The load sees an average proportional to D if the switching is much faster than the system’s response.
- Power, grounding, and protection: Use decoupling capacitors near IC power pins, separate analog and digital grounds with a single-point (star) connection when needed, protect ADC inputs with series resistors and clamps, and provide flyback diodes across inductive loads (relays, motors). Ensure common ground between sensor and MCU domains.
- Calibration: The process of relating sensor output to the true physical quantity using known references. Often a linear calibration y = m·x + c is applied, where x is raw reading and y is engineering units.
Derivations (commonly asked):
- Sampling theorem statement and Nyquist frequency: State fs ≥ 2·B and define Nyquist frequency fn = fs/2. Derive the aliasing condition by considering spectral replicas at k·fs and overlap when fs < 2·B.
- ADC step size and quantization noise: For an ideal N-bit ADC with input range Vspan = Vref_high − Vref_low, the step size is Δ = Vspan/2^N. Assuming quantization error e is uniformly distributed in [−Δ/2, +Δ/2], its mean is 0 and variance is Δ^2/12, so RMS = Δ/√12. Substituting into SNR for a full-scale sine gives SQNR ≈ 6.02·N + 1.76 dB (state as a known result; detailed proof uses sinusoid RMS and noise power).
- RC low-pass cutoff: For a first-order RC low-pass anti-alias filter, the transfer magnitude is |H(jω)| = 1/√(1+(ωRC)^2). The −3 dB cutoff frequency is fc = 1/(2πRC). Assumptions: linear passive components.
What to draw and label in exam diagrams:
- DAQ and automation block diagram: label each block as above; show signals and indicate analog/digital boundaries.
- Anti-alias filter: draw an RC low-pass (series resistor R, shunt capacitor C to ground) and label Vin, Vout, R, C, and fc.
- ADC staircase characteristic: input voltage on x-axis, digital code on y-axis, showing step size Δ, and indicating quantization error bounds ±Δ/2.
- PWM waveform: label period T, on-time ton, duty cycle D = ton/T, and amplitude (e.g., 0 to 5 V or 0 to 12 V driver output).
Formulas
Δ = (Vref_high − Vref_low)/2^N— ADC step size. Δ: V, Vref_high/Vref_low: V, N: bits. Ideal ADC.e_max = ±Δ/2— Maximum quantization error. e_max: V. Ideal mid-tread quantizer.e_rms = Δ/√12— RMS quantization noise. e_rms: V. Error assumed uniformly distributed.SQNR_dB ≈ 6.02·N + 1.76— Ideal N-bit ADC SQNR for a full-scale sine. SQNR_dB: dB, N: bits.fc = 1/(2·π·R·C)— First-order RC low-pass cutoff. fc: Hz, R: Ω, C: F. Passive RC filter.D = ton/T— PWM duty cycle. D: unitless (or %), ton: s, T: s. Applies to PWM waveform.Vavg = D·Vs— Average voltage to a load with PWM (ideal low ripple). Vavg: V, D: duty, Vs: supply V.Data_rate ≈ fs · bits_per_sample · channels— Approximate raw throughput ignoring overhead. Data_rate: bps, fs: Hz, bits_per_sample: bits, channels: count.τ = R·C— Time constant of first-order RC. τ: s, R: Ω, C: F. Step response and filtering.V = I·R— Ohm’s law for simple sensor/interface calculations. V: V, I: A, R: Ω. Linear resistive elements.
Worked examples
Example 1: Choose sampling rate, anti-alias filter, and ADC resolution for a temperature sensor Given: A temperature sensor’s conditioned output bandwidth is B = 10 Hz (after amplifier), expected voltage range 0 V to 3.0 V, desired temperature resolution corresponds to ≤ 2 mV at the ADC input.
Steps:
- Sampling frequency using Nyquist: formula fs ≥ 2·B.
- fs ≥ 2·10 Hz = 20 Hz. Choose a practical margin, e.g., fs = 50 Hz (to simplify timing and allow gentle filtering).
- Anti-alias filter design (first-order RC): choose fc somewhat below fn = fs/2 = 25 Hz to attenuate out-of-band noise. Use fc ≈ 10 Hz.
- Use fc = 1/(2·π·R·C). Choose a convenient R = 10 kΩ.
- Compute C = 1/(2·π·R·fc) = 1/(2·π·10,000 Ω·10 Hz).
- Numbers: 2·π·10,000·10 = 2·π·100,000 ≈ 628,318.53.
- C ≈ 1/628,318.53 F ≈ 1.59 µF. Standard value: 1.5 µF to 1.6 µF is acceptable.
- ADC resolution to meet ≤ 2 mV step size over 0–3.0 V range.
- Formula: Δ = Vspan/2^N ≤ 2 mV, where Vspan = 3.0 V.
- 2^N ≥ Vspan/Δ = 3.0 V / 0.002 V = 1500.
- Smallest power of 2 ≥ 1500 is 2048 = 2^11.
- So N ≥ 11 bits. Choose a common 12-bit ADC (N = 12) for margin.
- Check Δ for N = 12: Δ = 3.0 V / 4096 ≈ 0.000732 V = 0.732 mV ≤ 2 mV. Meets requirement.
Answer: Choose fs = 50 Hz, RC low-pass with R ≈ 10 kΩ and C ≈ 1.6 µF (fc ≈ 10 Hz), and a 12-bit ADC over 0–3.0 V range to achieve ≤ 0.732 mV step size.
Example 2: Data throughput check for multi-channel ADC over UART Given: 4 channels, sampling fs = 1000 samples/s per channel, ADC resolution N = 12 bits, sending raw packed data over UART at 115200 bps. Ignore framing and protocol overhead for a first estimate; then check a practical margin assuming 8N1 framing (1 start, 8 data, no parity, 1 stop) and byte alignment.
Steps:
- Ideal raw data rate (packed bits): Data_rate ≈ fs · bits_per_sample · channels.
- Data_rate ≈ 1000 s⁻¹ · 12 bits · 4 = 48,000 bps.
- Practical UART with 8N1 and byte alignment: 12-bit samples usually sent as 2 bytes (16 bits). Each byte over UART uses 10 bits on the wire (start+8 data+stop), so 2 bytes → 20 bits per sample.
- Per channel: 1000 s⁻¹ · 20 bits = 20,000 bps.
- For 4 channels: 4 · 20,000 = 80,000 bps.
- Compare with UART capacity 115,200 bps.
- Utilization ≈ 80,000 / 115,200 ≈ 0.695 ≈ 69.5%.
- There is margin for simple headers/checksums; avoid adding large overhead or high-rate text formatting.
Answer: Required link ≈ 80 kbps with 8N1 framing; UART at 115200 bps is sufficient with ≈ 30% headroom. For robustness, keep payloads binary and use brief framing.
Example 3: PWM control for DC motor speed with average voltage target Given: A 12 V DC motor is driven by a MOSFET from 12 V supply using PWM. Desired average voltage Vavg = 7.2 V. PWM frequency should be above audible range; choose fPWM = 20 kHz. Compute duty cycle D and comment on driver needs.
Steps:
- Duty cycle formula: Vavg = D·Vs ⇒ D = Vavg/Vs.
- D = 7.2 V / 12 V = 0.6.
- As percentage, D = 60%.
- PWM frequency: fPWM = 20 kHz is above most audible sensitivity (~20 kHz) and usually okay for small motors; verify the MOSFET and driver can switch efficiently at this rate.
- Driver note (no calculation): The MCU pin cannot drive the motor; use a logic-level MOSFET with gate driver if needed, a flyback diode across the motor, and ensure common ground.
Answer: Set PWM duty cycle to 60% at 20 kHz. Use a suitable MOSFET driver and flyback diode for safe operation.
Common mistakes
- Ignoring units in throughput calculations; forgetting UART framing overhead and byte padding.
- Feeding sensor outputs directly to MCU pins without signal conditioning, protection, or proper grounding; exceeding ADC input range.
- Using long, unshielded wires for small signals without considering noise pickup; missing decoupling capacitors.
- Driving actuators directly from MCU GPIO; forgetting flyback diode on inductive loads.
- Confusing sampling rate (fs) with PWM frequency (fPWM). They are different.
- Calibrating at one point only; not checking linearity or temperature effects.
For your exam
Expect these types of questions:
- Definitions: IoT, data acquisition, sampling, aliasing, ADC resolution, Nyquist frequency, PWM, actuator, throughput. Full-marks answers give clear definitions, units, and context.
- Short notes with block diagrams: “Explain the IoT data acquisition chain” or “Draw and explain an anti-alias filter.” Full marks: neat labeled blocks, signal directions, and 2–3 sentences per block.
- Derivations/statements: State and explain the sampling theorem; derive Δ and e_rms for an ideal N-bit ADC; derive fc for an RC low-pass. Full marks: state assumptions and final expressions.
- Numericals: Compute sampling rate from bandwidth; compute ADC step size and required bits; data throughput over UART/SPI/I2C; design an RC filter for a given cutoff; compute PWM duty cycle for a required average. Full marks: formula first, substitute with units, final answer highlighted.
- Application/design: Propose an IoT sensing system with sensors, conditioning, ADC/MCU, communication protocol selection (e.g., MQTT vs HTTP), and actuator control approach (open vs closed loop). Full marks: justify each choice briefly and note practical issues (power, grounding, protection).
Quick check
- A sensor signal is band-limited to 200 Hz. What is the minimum sampling frequency to avoid aliasing, and what is the Nyquist frequency if you sample at 1 kHz?
- A 10-bit ADC over 0–5 V has what step size Δ, and what is the maximum quantization error magnitude?
- You need to deliver an average of 3 V to a load from a 12 V supply using PWM. What duty cycle should you set?
Answers: 1) Minimum fs = 2·200 Hz = 400 Hz; Nyquist frequency at 1 kHz sampling is fn = 500 Hz. 2) Δ = 5 V / 1024 ≈ 4.883 mV; e_max = ±Δ/2 ≈ ±2.442 mV. 3) D = 3/12 = 0.25 = 25%.
Finished this topic? Mark it so your progress, study plan and readiness keep up.
Stuck on something here?