Skip to content
Tutorials Center
My learning

Topics

Lesson 25 of 36 ยท Edge, Cloud and Data Pipelines

Edge Computing: Filtering and Deciding Near the Device

Learn why IoT processing moves to the edge: latency, bandwidth, privacy and offline operation. Run dead-band filtering, local rules and store-and-forward.

Sending every reading to the cloud sounds simple, and it quickly becomes expensive and slow. A vibration sensor sampling 1,000 times per second produces 86 million numbers per day. A camera produces gigabytes. A factory robot cannot wait 200 milliseconds for a cloud answer before it stops. Edge computing means doing part of the work on or near the device: on the microcontroller itself, on a gateway in the building, or in a small local server.

You will meet three related words. Edge is the device or gateway at the network's rim. Fog is an intermediate layer of local servers between edge and cloud. Cloud is the central data center. Most real systems use all three, as the previous lesson's pipeline can run at any of these levels.

Why process at the edge

Four reasons for the edge

Latency Decide in milliseconds, not round trips
Bandwidth Send summaries, not raw streams
Privacy Raw video or audio stays local
Offline Keep working when the link is down

Cost is the fifth reason: cellular data is not free

1 / 2
flowchart LR
  S["Sensors"] --> E["Edge device<br/>filter, rules"]
  E --> F["Gateway / fog<br/>aggregate, buffer"]
  F --> C["Cloud<br/>history, ML training"]
  C -. "models, config" .-> E

Data flows up and shrinks; models and configuration flow back down.

Technique 1: report by exception

A room temperature changes slowly. Instead of sending every second, send only when the value moved by more than a dead band (also called delta or hysteresis threshold) since the last sent value, plus a heartbeat every so often so the receiver knows the sensor is alive.

Node.js Dead-band filtering with heartbeat

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or process.stdin), it gets the next line from this box.

Seven messages instead of sixty. The spike at 30 s is transmitted (and the return to normal right after it), as is every drift that crosses the 0.5 degree threshold. Here the drift is fast enough that the 20 s heartbeat never needed to fire; on a perfectly flat signal it would be the only thing sent. Choose the dead band from the physical meaning: a freezer alarm cares about 0.5 degrees, a weather station may not.

Technique 2: decide locally

When a rule must act fast or work offline, run it at the edge. Add hysteresis so the output does not flicker around the threshold: switch on below 19, switch off above 21, and hold the state between.

Node.js Local thermostat rule with hysteresis

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or process.stdin), it gets the next line from this box.

Without hysteresis, a temperature hovering at 19.0 would switch the relay on and off every second, wearing it out. The heater's action happens in microseconds on the device; the cloud only needs to be told afterwards.

Technique 3: store and forward

Links fail. An edge node should buffer data while offline and send it in order once the connection returns. The buffer must be bounded (flash and RAM are small) with a policy for what to drop when it fills: usually the oldest low-priority samples first.

Node.js Bounded store-and-forward buffer

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or process.stdin), it gets the next line from this box.

Because each message carries its own timestamp, the cloud can still place late data correctly.

Edge hardware and AI at the edge

Edge devices range from a $2 microcontroller (ESP32, RP2040) running small neural networks with TinyML, to a Raspberry Pi gateway, to an industrial PC with a GPU. Typical edge AI jobs: detecting a wake word on-device, spotting anomalies in vibration, counting people in a camera image without uploading the video. The cloud usually trains the model; the edge runs inference.

On an Arduino-class device, the dead-band logic from above looks like this (read-only, needs hardware):

C++
float lastSent = NAN;
void loop() {
  float t = readTemperature();
  if (isnan(lastSent) || fabs(t - lastSent) >= 0.5) {
    mqtt.publish("home/hall/temp", String(t, 1).c_str());
    lastSent = t;
  }
  delay(1000);
}

Trade-offs

  • More code on the device means more firmware to update securely; see secure updates.
  • Distributed state makes debugging harder; log decisions with timestamps.
  • Edge nodes are physically exposed, so protect keys and data at rest.
  • Do not over-filter. Raw data discarded at the edge is gone; keep a short raw buffer when diagnostics may need it.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What does report by exception (dead band) do?

    It cuts traffic by skipping insignificant changes while the heartbeat proves the sensor is alive.
  2. 2. Why is hysteresis used in an on/off rule?

    Two thresholds with a hold zone stop the output flickering when the value hovers near the limit.
  3. 3. Which is a valid reason to process at the edge?

    Local rules keep running offline and avoid round-trip latency.
  4. 4. What should a full store-and-forward buffer usually drop first?

    Memory is limited, and stale low-value data is the cheapest loss.

Summary

  • Edge computing processes data on or near devices for latency, bandwidth, privacy, offline use and cost.
  • Dead-band filtering with a heartbeat cuts traffic; hysteresis stabilizes local rules.
  • Store-and-forward with a bounded buffer and timestamps survives outages.
  • The cloud trains and stores; the edge acts and filters. Edge code adds update and security duties.

Next: Time-Series Storage and Dashboards