IoT Data Management, Analytics and AIIntroductionThe value of an Internet of Things (IoT) system does not arise merely from connecting sensors. Its value comes from converting observations into reliable information and useful decisions. A temperature sensor may produce thousands of readings, but those readings become operationally valuable only when they are acquired correctly, filtered appropriately, stored with context, analysed, visualised clearly, and retained according to business and legal requirements. IoT data is commonly continuous, time-stamped, distributed and heterogeneous. A smart meter produces time-series measurements; a motion detector produces events; a gateway produces logs; and an actuator produces status changes. These forms of data require management techniques that differ from those used for conventional office databases. This chapter explains the data lifecycle in IoT, basic descriptive and streaming analytics, anomaly detection, predictive maintenance, machine learning and edge AI. It also considers data quality, security, privacy, governance and practical deployment limitations. Learning ObjectivesAfter completing this chapter, a learner should be able to: - Describe the IoT data lifecycle from acquisition to retention or deletion.
- Distinguish time-series data, event data, metadata and telemetry.
- Apply basic filtering, aggregation and descriptive statistics.
- Explain window-based streaming analytics and anomaly detection.
- Describe predictive maintenance and suitable machine-learning workflows.
- Compare cloud, gateway and edge AI deployment.
- Identify data-quality, privacy, security and governance requirements.
1. The IoT Data LifecycleAn IoT data lifecycle normally contains the following stages: - Sensing and acquisition – a device measures a physical variable or detects an event.
- Transmission – data travels through a local network, gateway or wide-area connection.
- Ingestion – a platform receives, authenticates, timestamps and validates messages.
- Filtering and preparation – noise, duplicates, missing values and invalid readings are handled.
- Storage – data is stored in a time-series database, event store, relational database, data lake or archive.
- Analysis – descriptive, diagnostic, predictive or prescriptive methods are applied.
- Visualisation and action – dashboards, alerts or automated control actions communicate results.
- Retention and disposal – data is retained for a defined period and securely deleted or anonymised when no longer required.
A useful design principle is to collect data for a stated purpose. Indiscriminate collection increases storage cost, privacy exposure and cybersecurity risk. 1.1 Data categories| Category | Meaning | Example |
|---|
| Telemetry | Repeated measurements from a device | Motor temperature every 10 seconds | | Event data | A discrete occurrence | Door opened, alarm triggered | | State data | Current condition or mode | Pump = running | | Metadata | Information describing data | Sensor ID, unit, location, calibration date | | Log data | Operational records | Gateway connection failure | | Command data | Instructions sent to devices | Set fan speed to 60% |
A reading without metadata is often difficult to interpret. The value 72 is incomplete unless the system knows whether it represents 72 °C, 72%, 72 volts or another quantity. 1.2 Time-series dataTime-series data is a sequence of observations indexed by time. A record commonly includes a device identifier, timestamp, value, unit, quality flag and sometimes location. Timestamps should use a consistent standard such as Coordinated Universal Time (UTC), while local time can be displayed to users. Important timestamp issues include clock drift, incorrect time zones, daylight-saving changes, delayed transmission and out-of-order messages. A platform should distinguish event time, when the measurement occurred, from ingestion time, when the platform received it. This distinction is essential when networks are unreliable. 1.3 Event dataEvent data describes occurrences rather than continuous measurements. Events may be represented as records containing an event type, time, source, severity and attributes. For example: {device: pump-17, event: overheat, time: 10:15:22 UTC, severity: high}
An event may initiate a workflow, such as notifying a technician or shutting down equipment. Event processing must consider duplicate messages, delayed messages and event ordering. 2. Acquisition, Quality and Preparation2.1 Sampling and resolutionSampling is the process of taking measurements at selected times. A sampling interval of 1 second gives a sampling frequency of 1 Hz. In general, fs = 1 / Δt where fs is sampling frequency in hertz and Δt is the sampling interval in seconds. This relationship applies when samples are taken at a regular interval. A shorter interval captures faster changes but increases energy use, bandwidth and storage requirements. For a simple periodic signal, the sampling frequency should be sufficiently greater than twice the highest signal frequency to reduce aliasing. This is the Nyquist condition. Real systems also use anti-aliasing filters because practical signals contain noise and frequencies outside the desired range. 2.2 Data-quality dimensionsCommon data-quality dimensions are: - Accuracy: closeness to the true value.
- Completeness: proportion of expected data that is present.
- Timeliness: arrival within the required time.
- Consistency: agreement across systems and records.
- Validity: compliance with permitted format and range.
- Uniqueness: absence of unintended duplicates.
A quality flag should travel with a measurement. For example, a value may be marked valid, suspect, calibration_required or estimated rather than silently corrected. 2.3 Filtering and preprocessingCommon preprocessing operations include: - Range checks, such as rejecting a humidity below 0% or above 100%.
- Duplicate removal using a device identifier and measurement identifier.
- Unit conversion, such as Fahrenheit to Celsius.
- Resampling to a common time interval.
- Interpolation or imputation of missing values.
- Smoothing of high-frequency noise.
- Calibration correction.
A moving average over the most recent n observations is: \bar{x}t = (1/n) ∑i=0n-1 xt-i Here, xt is the current observation and n is the window size. The observations must represent comparable quantities and, for a regular moving average, should normally be equally spaced. A moving average reduces random variation but introduces delay and can hide sudden faults. An exponentially weighted moving average (EWMA) is: st = αxt + (1 − α)st−1 where 0 < α ≤ 1, xt is the new observation and st is the smoothed value. Larger α responds more quickly; smaller α produces stronger smoothing. The initial value s0 must be defined, often as the first observation or an initial baseline mean. Preprocessing should not destroy evidence. For safety investigations, original readings should be preserved and transformed values should be stored as derived data. 3. Storage Architecture and Retention3.1 Storage choicesA time-series database is optimised for timestamped measurements and operations such as range queries, downsampling and aggregation. A relational database is useful for structured relationships, transactions and master data. An event store preserves an ordered history of events. A data lake can hold large volumes of raw, semi-structured data for later analysis. Many IoT platforms use a layered architecture: - Hot storage: recent data used by dashboards and real-time alerts.
- Warm storage: older data used for regular reporting and analysis.
- Cold or archival storage: infrequently accessed data retained at lower cost.
Storage design should consider retention period, query patterns, device count, write rate, replication, backup, geographical location and recovery objectives. 3.2 Retention and governanceA retention policy specifies what data is kept, for how long, in what form and for what purpose. High-resolution data may be retained for days, while hourly summaries may be retained for years. Aggregation can reduce cost, but it may prevent later investigation of short-lived events. A sound policy defines: - the data owner and responsible custodian;
- permitted uses and access roles;
- retention and deletion periods;
- backup and disaster-recovery procedures;
- audit requirements;
- anonymisation or pseudonymisation rules; and
- secure disposal methods.
Personal data requires additional care. Location, occupancy, biometric and behavioural data may identify individuals directly or indirectly. Collection should follow principles such as purpose limitation, data minimisation, transparency, access control and accountability. Applicable privacy law depends on jurisdiction and sector. 4. Descriptive AnalyticsDescriptive analytics answers: “What happened?” It includes counts, totals, averages, variation, percentiles, rates and trends. For observations x1, x2, …, xn, the arithmetic mean is: \bar{x} = (1/n) ∑i=1n xi The mean uses the same unit as the observations and can be strongly affected by extreme values. The median is the middle ordered observation and is often more robust to outliers. The population variance is: σ² = (1/n) ∑i=1n (xi − μ)² where μ is the population mean. When data is treated as a sample used to estimate a wider population, the sample variance is: s² = (1/(n−1)) ∑i=1n (xi − \bar{x})² The corresponding standard deviation is s = √s². Variance has squared units, while standard deviation has the original unit. The range is maximum minus minimum. Percentiles indicate the value below which a specified proportion of observations falls. The 95th percentile is useful for service-level analysis, but percentile calculation methods can differ for small datasets; the selected method should be documented. Worked example: descriptive statisticsSuppose five vibration readings in mm/s are 2, 3, 3, 4 and 8. The mean is: \bar{x} = (2 + 3 + 3 + 4 + 8)/5 = 4 mm/s The ordered middle value is 3 mm/s, so the median is 3 mm/s. The large reading of 8 mm/s raises the mean above the median, indicating a right-skewed small dataset. A maintenance engineer should investigate the 8 mm/s reading rather than relying on the mean alone. 5. Streaming AnalyticsBatch analytics processes a stored collection, whereas streaming analytics processes data as it arrives. IoT systems use streaming analytics when delay matters, such as detecting overheating or unsafe pressure. A tumbling window divides time into non-overlapping intervals. A five-minute window produces one result every five minutes. A sliding window moves continuously or at regular steps and may overlap. A session window groups events separated by less than a chosen inactivity period. For a count rate, rate = count / duration The units must be stated, such as events per minute. A windowed average should specify both the window duration and whether missing periods are ignored or treated as zero. Streaming systems must address late data, out-of-order data, duplicate events and fault recovery. Watermarks estimate how complete a time interval is; however, accepting late data always involves a trade-off between result timeliness and completeness. 6. Anomaly DetectionAn anomaly is an observation or pattern that differs substantially from expected behaviour. It may indicate a fault, attack, sensor failure, unusual operating condition or legitimate rare event. An anomaly score is not automatically a diagnosis. 6.1 Rule-based detectionA rule may trigger when a temperature exceeds a safe limit or when a door opens outside permitted hours. Rules are transparent and easy to validate, but they may generate false alarms when operating conditions change. 6.2 Statistical detectionA z-score measures distance from a mean in standard-deviation units: z = (x − μ)/σ This interpretation assumes that μ and σ represent an appropriate baseline and that standard deviation is not zero. A threshold such as |z| > 3 is only a screening rule, not a universal law. Non-normal data, changing conditions and small samples require caution. For a robust alternative, the median and median absolute deviation (MAD) can be used. The MAD is: MAD = median(|xi − median(x)|) Robust methods are less influenced by extreme observations. 6.3 Multivariable and model-based detectionA motor may be abnormal when temperature, current and vibration jointly change even if each variable remains within an individual limit. Multivariable methods learn normal patterns and flag observations with large reconstruction or prediction errors. They require representative training data and careful validation. Performance should be evaluated using false positives, false negatives, precision, recall and detection delay. In safety applications, the cost of a missed fault may be much greater than the cost of an extra inspection. 7. Predictive Maintenance and Machine LearningMaintenance strategies include: - Corrective maintenance: repair after failure.
- Preventive maintenance: service at scheduled intervals.
- Condition-based maintenance: service when measured condition indicates need.
- Predictive maintenance: estimate future failure or remaining useful life using data and models.
A typical machine-learning workflow is: - Define the operational decision and prediction horizon.
- Collect sensor data, maintenance records and operating context.
- Label failures or define a useful target.
- Clean and align data by event time.
- Divide data into training, validation and test sets.
- Train a baseline model and compare alternatives.
- Evaluate using operationally meaningful metrics.
- Deploy with monitoring, alerts and human review.
For classification, a confusion matrix contains true positives, false positives, true negatives and false negatives. Precision and recall are: precision = TP/(TP + FP) recall = TP/(TP + FN) Precision answers how many predicted failures were genuine; recall answers how many actual failures were detected. These formulas require non-zero denominators and must be interpreted with the class balance and business costs. A model can perform well in testing but fail in production because of concept drift, sensor replacement, seasonal changes or changes in machine operation. Monitoring should therefore include data distributions, missingness, prediction rates and actual outcomes. 8. Edge AI and Cloud AICloud AI sends data to central computing infrastructure for storage and analysis. It offers substantial computational resources and convenient model management. Its disadvantages may include network delay, connectivity dependence, bandwidth cost and data-sovereignty concerns. Edge AI executes inference near the sensor, gateway or device. It can reduce latency, limit raw-data transmission and continue operating during network disruption. Constraints include limited memory, processing power, energy and software-management capability. A common architecture performs filtering and immediate safety decisions at the edge, sends selected features or alerts to the cloud, and uses cloud resources for model training and long-term analysis. Edge inference is not the same as edge training; training is usually more computationally demanding. Model compression, quantisation and pruning can reduce resource requirements, but may reduce accuracy. Any safety-critical edge decision should have a defined fallback state, secure update process and independent validation. 9. Illustrative Case: Predictive Maintenance of a Water-Pumping StationBackgroundA municipal pumping station operates three electric pumps. Each pump reports vibration, motor current, temperature, run state and operating hours through an industrial gateway. ProblemThe station experiences unexpected pump failures. Scheduled maintenance is expensive, but operating a failed pump can interrupt water supply. Historical records also contain missing timestamps and duplicate gateway messages. AnalysisThe engineering team first standardises timestamps in UTC and assigns each reading a quality flag. Duplicate records are removed using device ID, event time and message ID. Vibration is resampled into one-minute intervals, while raw readings are retained for investigations. A dashboard displays current temperature, vibration percentiles and recent alarms. The team establishes a baseline for each pump during verified healthy operation. A rolling median and EWMA are used to reduce the influence of sensor noise. An alert is produced only when vibration remains elevated for three consecutive windows and motor current is also abnormal. This persistence rule reduces alarms caused by one erroneous reading. For predictive modelling, failure reports are aligned with sensor data. The model predicts whether a pump will require intervention within the next seven days. Data is divided by time rather than randomly, so that future information cannot leak into training. Recall is prioritised because missing an impending failure is costly, but precision is also monitored to avoid unnecessary maintenance visits. Approach and outcomeThe system performs immediate threshold checks at the gateway and sends summaries and alerts to the cloud. Maintenance staff receive an alert containing the pump, evidence, confidence, recent trend and recommended inspection. The model does not automatically shut down a pump; authorised personnel make the final maintenance decision unless a separate safety interlock is activated. After deployment, the organisation reviews false alarms, missed failures, sensor calibration and model drift monthly. The retention policy stores raw data for a short investigative period and daily summaries for longer planning analysis. Learning pointsThe case demonstrates that predictive maintenance is not simply a machine-learning problem. Reliable timestamps, quality control, domain knowledge, appropriate evaluation, human procedures and secure deployment are equally important. A complicated model cannot compensate for poor labels or faulty sensors. 10. Challenges, Ethics and Best PracticesImportant challenges include unreliable connectivity, sensor drift, missing data, inconsistent units, limited labelled failures, class imbalance and changing operating conditions. Correlation does not establish causation; a model may identify a useful warning pattern without explaining the physical mechanism. IoT analytics can affect employment, safety, insurance and access to services. Organisations should explain significant automated decisions, limit access to sensitive data and provide audit trails. Data collected for one purpose should not automatically be reused for another without lawful and ethical justification. Recommended practices are: - Define the decision and required latency before selecting technology.
- Store metadata, units, calibration information and quality flags.
- Preserve raw data where it may be needed for safety or audit.
- Use event time and document late-data handling.
- Establish baselines separately for different machines and operating modes.
- Validate models with time-aware, leakage-resistant evaluation.
- Measure both technical metrics and operational consequences.
- Secure devices, gateways, APIs, storage and model-update channels.
- Monitor drift and retrain only through controlled procedures.
- Keep humans responsible for high-impact decisions unless safety engineering justifies automation.
Contemporary DevelopmentsCurrent IoT practice increasingly combines digital twins, federated learning, automated model monitoring and semantic metadata. Digital twins link data to a representation of an asset and its operating context. Federated learning can train across sites without centralising all raw data, although model updates may still reveal information and require protection. Lightweight AI models are being integrated into microcontrollers and gateways, enabling local classification and anomaly detection. These developments do not remove fundamental requirements for data quality, explainability, cybersecurity and governance. The most effective systems combine physical understanding with statistical evidence and operational feedback. Chapter SummaryIoT data management begins with purposeful acquisition and continues through transmission, ingestion, quality control, storage, analysis, visualisation and controlled retention. Time-series data requires attention to sampling, timestamps, units and ordering, while event data requires reliable identity, severity and duplicate handling. Filtering and smoothing can improve signal quality but may hide important faults, so raw data and derived data should be distinguished. Descriptive analytics uses measures such as mean, median, variance, standard deviation and percentiles. Streaming analytics applies windows and incremental calculations to data arriving continuously. Anomaly detection may use rules, statistical baselines or machine-learning models, but an anomaly is not automatically a confirmed fault. Predictive maintenance uses sensor and maintenance data to estimate future intervention needs. Precision, recall, false alarms and missed failures must be interpreted according to operational risk. Cloud AI provides centralised computing and storage, while edge AI supports low-latency, bandwidth-efficient and locally available decisions. Both require secure deployment, monitoring and fallback procedures. Across all approaches, metadata, data quality, privacy, retention, access control, model drift and human accountability are essential. Key TermsTelemetry: Repeated measurements transmitted from an IoT device. Event data: Records describing discrete occurrences. Time-series data: Observations indexed by time. Metadata: Data describing the meaning, source, unit or quality of another dataset. Event time: The time when an observation or event occurred. Ingestion time: The time when a platform received data. Sampling frequency: Number of measurements taken per unit of time. Moving average: Average calculated over a recent fixed-size window. EWMA: A smoothing method that weights recent observations more heavily. Time-series database: A database optimised for timestamped data. Retention policy: Rules defining how long data is kept and how it is disposed of. Streaming analytics: Analysis performed as data arrives. Anomaly: An observation or pattern that differs from expected behaviour. Predictive maintenance: Maintenance based on forecasts of condition or failure. Precision: The proportion of positive predictions that are true positives. Recall: The proportion of actual positives that are detected. Edge AI: AI inference performed near the data source. Concept drift: Change in the relationship between inputs and outcomes over time. Data minimisation: Collecting only data needed for a legitimate purpose. Model leakage: Use of information during training that would not be available at prediction time. Review QuestionsShort Answer Questions- Distinguish event time from ingestion time.
- State two advantages and one limitation of a moving average.
- What is the purpose of a data-quality flag?
- Define precision and recall.
- Why is metadata important in IoT data management?
Long Answer Questions- Explain the IoT data lifecycle from acquisition to secure disposal.
- Compare time-series databases, relational databases and event stores.
- Explain how tumbling, sliding and session windows support streaming analytics.
- Describe a machine-learning workflow for predictive maintenance.
- Compare cloud AI and edge AI in terms of latency, bandwidth, resilience and governance.
Analytical / Application Questions- A pump produces temperature, vibration and current readings, but network delays sometimes cause out-of-order messages. Design a data-preparation and streaming-alert strategy that preserves event-time accuracy.
- A failure-detection model has high precision but low recall. Explain the operational meaning and recommend changes if missed failures are much more costly than false alarms.
- Design a retention and governance policy for an occupancy-monitoring system in a public building. Address raw data, summaries, privacy, access control and deletion.
Multiple Choice Questions with AnswersQuestion 1Which timestamp records when a measurement actually occurred? A. Event time B. Ingestion time C. Archive time D. Query time Correct Answer: A. Event time Question 2If measurements are taken every 2 seconds, what is the sampling frequency? A. 0.2 Hz B. 0.5 Hz C. 2 Hz D. 4 Hz Correct Answer: B. 0.5 Hz Question 3What is a principal limitation of a moving average? A. It cannot use numerical data B. It always increases noise C. It can introduce delay and hide sudden changes D. It requires labelled failure data Correct Answer: C. It can introduce delay and hide sudden changes Question 4Which storage type is specifically optimised for timestamped measurements? A. Time-series database B. Word processor C. Image editor D. Compiler Correct Answer: A. Time-series database Question 5For values 2, 3, 3, 4 and 8, what is the arithmetic mean? A. 3 B. 4 C. 5 D. 8 Correct Answer: B. 4 Question 6A system predicts 20 failures, of which 15 are genuine. What is its precision? A. 25% B. 50% C. 75% D. 80% Correct Answer: C. 75% Question 7Which window is non-overlapping? A. Tumbling window B. Sliding window C. Session window D. Diagnostic window Correct Answer: A. Tumbling window Question 8What does high recall indicate in failure detection? A. Most predicted failures are genuine B. Most actual failures are detected C. Few failures are detected D. The model has no false positives Correct Answer: B. Most actual failures are detected Question 9Which is a typical advantage of edge AI? A. Unlimited storage on every sensor B. Guaranteed perfect accuracy C. Reduced latency and dependence on connectivity D. No need for cybersecurity Correct Answer: C. Reduced latency and dependence on connectivity Question 10What is concept drift? A. Permanent loss of a sensor B. Change in the relationship between inputs and outcomes C. Conversion from Celsius to Fahrenheit D. Duplicate event removal Correct Answer: B. Change in the relationship between inputs and outcomes
|