IoTInfluxDBWebSocketsRaspberry Pi

Building Real-Time IoT Data Pipelines with InfluxDB & WebSockets

How we designed a high-throughput, low-latency IoT data pipeline using Raspberry Pi, InfluxDB time-series storage, and WebSocket push to a live dashboard.

Hawcraft Engineering·

Building Real-Time IoT Data Pipelines with InfluxDB & WebSockets

Modern IoT systems generate thousands of sensor readings per second. Traditional relational databases buckle under this load. This post explains how we built a pipeline that ingests, stores, and streams that data to a live dashboard — all with sub-100ms end-to-end latency.

The Stack

| Layer | Technology | Why | |---|---|---| | Edge device | Raspberry Pi 4 | GPIO access, Linux, affordable | | Transport | MQTT | Lightweight pub/sub for constrained devices | | Time-series DB | InfluxDB v2 | Optimised for high write throughput with nanosecond timestamps | | Push to UI | WebSockets | Bi-directional, persistent, low-overhead | | Dashboard | Next.js + Recharts | React-based charts with live data |

Data Flow

Sensor → Raspberry Pi (MQTT Publish) → MQTT Broker → Node.js Subscriber
  → InfluxDB Write API → WebSocket Server → Browser Dashboard

The key insight is separation of concerns: the Pi's only job is to publish clean JSON. Everything downstream is decoupled.

InfluxDB Write Performance

InfluxDB's line protocol lets you batch thousands of points in a single HTTP write:

temperature,device=sensor-01,location=warehouse value=23.4 1710000000000000000
temperature,device=sensor-02,location=warehouse value=24.1 1710000000000000000

We batch 500 readings per write and stay comfortably under 10ms write latency even at 5,000 points/second.

WebSocket Push Pattern

Rather than polling, clients subscribe to a WebSocket channel keyed by device ID. The server pushes deltas as they arrive from InfluxDB subscriptions:

// Server: push on new InfluxDB subscription event
influxSubscription.on('data', (row) => {
  clients.forEach((ws) => ws.send(JSON.stringify(row)));
});

This gives the dashboard a live, event-driven feel without the overhead of REST polling.

Lessons Learned

  • Clock sync matters — Use NTP on every Pi. Even 1-second drift makes time-series graphs look broken.
  • Batch, don't drip — Single-point writes kill InfluxDB throughput. Always batch.
  • WebSocket reconnect logic — Clients must handle disconnects gracefully with exponential backoff.

Next up: Running on-device ML inference with NVIDIA Jetson Nano.

Enjoyed this post?

← More from the blog