Data Acquisition

Data acquisition is collecting measurements from sensors and converting them into digital data. The steps are sensing (a physical signal), signal conditioning (amplifying or filtering), sampling (taking readings at a set rate), analog-to-digital conversion and timestamping. The sampling rate must be high enough: by the Nyquist theorem, it must be at least twice the highest frequency in the signal. Too high a rate wastes energy and storage.

Storage

Data may be stored in three places. On the device: flash or an SD card, for buffering when the network is down. At the edge: a local database or file on a gateway. In the cloud: scalable storage. Time-series databases such as InfluxDB are designed for timestamped readings; relational databases (MySQL) suit device and user records; NoSQL stores (MongoDB, DynamoDB) suit flexible JSON data; object storage holds files and images. Large data may be kept at full detail for a short time and then downsampled (averaged) for long-term storage.

Preprocessing

Raw sensor data is noisy and imperfect, so it is cleaned before use.

  1. Cleaning: remove or fix missing values, duplicates and outliers (impossible readings caused by faults).
  2. Filtering and smoothing: a moving average reduces noise.
  3. Normalisation: scaling values to a range such as 0 to 1, using min-max scaling: (x − min) / (max − min).
  4. Aggregation: replacing many readings by an average, minimum or maximum.
  5. Synchronisation: aligning readings from different sensors by time.
  6. Formatting: packaging as JSON or CBOR with ID and timestamp.

Quality of data decides quality of decisions: "garbage in, garbage out".

Definition: Time-series database. A database designed to store and query data points indexed by time, such as sensor readings, with fast writes and time-based summaries.

Table 3.2: Where to store IoT data

Location Typical store Purpose
Device Flash, SD card Buffering during outages
Edge Local database, file Fast local use and filtering
Cloud Time-series DB, object storage Long-term, large-scale analysis

Example 3.2: Cleaning and smoothing a temperature stream

Problem: Readings in °C are 22.1, 22.3, 85.0, 22.2, 22.4, 22.6. A temperature above 50 °C is impossible for this room. Remove the outlier, find the mean, apply a 3-point moving average, and normalise 22.4 on the cleaned data range.

Solution:

  1. Remove 85.0, leaving 22.1, 22.3, 22.2, 22.4, 22.6.
  2. Mean = 111.6 / 5 = 22.32 °C.
  3. Moving average: (22.1 + 22.3 + 22.2)/3 = 22.2; (22.3 + 22.2 + 22.4)/3 = 22.3; (22.2 + 22.4 + 22.6)/3 = 22.4.
  4. Range = 22.1 to 22.6, so normalised 22.4 = (22.4 − 22.1) / 0.5 = 0.6.

Result: The cleaned mean is 22.32 °C, the smoothed series is 22.2, 22.3, 22.4, and 22.4 normalises to 0.6.

raw = [22.1, 22.3, 85.0, 22.2, 22.4, 22.6]
clean = [x for x in raw if x <= 50]
print("Mean:", round(sum(clean) / len(clean), 2))
ma = [round(sum(clean[i:i + 3]) / 3, 1)
      for i in range(len(clean) - 2)]
print("Moving avg:", ma)
lo, hi = min(clean), max(clean)
print("Normalised 22.4:", round((22.4 - lo) / (hi - lo), 1))

Output

Mean: 22.32
Moving avg: [22.2, 22.3, 22.4]
Normalised 22.4: 0.6

Common mistakes

  • Sampling too slowly and missing fast changes (aliasing).
  • Using sensor data without removing faults and outliers.
  • Storing every raw reading forever at full detail.
  • Mixing timestamps from different devices without synchronising.

Key takeaways

  • Acquire: sense, condition, sample, convert, timestamp.
  • Sampling rate at least twice the highest signal frequency.
  • Store at device, edge and cloud; use time-series databases.
  • Preprocess: clean, smooth, normalise, aggregate.

Practice questions

  1. State the Nyquist sampling rule.
  2. Why use a moving average?
  3. Name a time-series database.

Answers to the practice questions

  1. Sample at least twice the highest frequency present in the signal.
  2. It smooths out noise in readings.
  3. InfluxDB.

Sources

  • Official BCA syllabus Internet of Things, course code 25BCA406DS01, Unit III