IoTDecember 20, 2024•9 min read•Verified Production Post

Building Real-Time IoT Telematics with WebSockets, Node.js & Leaflet (Our SIH 2024 1st Prize Architecture)

The technical blueprint behind our 1st Prize winning Smart India Hackathon 2024 project. How we processed 10,000 concurrent EV telemetry packets per second with Redis Pub/Sub, geofencing algorithms, and adaptive load balancing.

Listen to Audio DispatchAI Voice
9 min article overview • Narrated audio
<UB>
Ankit Bhuria
Lead Architect & Agency Founder • National SIH 2024 Winner
Building Real-Time IoT Telematics with WebSockets, Node.js & Leaflet (Our SIH 2024 1st Prize Architecture)
Executive Architecture Takeaways

The technical blueprint behind our 1st Prize winning Smart India Hackathon 2024 project. How we processed 10,000 concurrent EV telemetry packets per second with Redis Pub/Sub, geofencing algorithms, and adaptive load balancing.

Architecture Focus
IoT + WebSockets
Reading Investment
9 Min Breakdown
Testing Standard
100% Production Tested
Reader Controls•

#Background & The SIH 2024 Challenge

At the Smart India Hackathon (SIH) 2024, our team tackled a mission-critical problem statement issued by the Ministry of Power: Managing Grid Stability in High-Density EV Charging Corridors.

When hundreds of commercial electric vehicles plug into fast chargers simultaneously during peak grid hours, local transformers face severe harmonic distortion and brownout risks. Our solution—the EV Fleet Balancing Grid—ingested live battery state-of-charge (SoC), route telemetry, and transformer heat sensor data to dynamically throttle charging currents and reroute fleet vehicles.


#High-Throughput Ingestion Architecture

Each simulated EV hardware beacon emitted a 128-byte binary packet every 500ms containing:

  • GPS coordinates (Latitude, Longitude, Altitude)
  • Battery state-of-charge (SoC percentage & cell temperature)
  • Instantaneous power draw (kW)
  • Vehicle cryptographic identifier

To prevent database bottlenecking, we bypassed direct relational writes and built an in-memory Redis ingestion pipeline:

typescript
// IoT Ingestion Handler
import { WebSocketServer, WebSocket } from 'ws';
import { createClient } from 'redis';

const redisPublisher = createClient({ url: process.env.REDIS_URL });
await redisPublisher.connect();

const wss = new WebSocketServer({ port: 8080 });

wss.on('connection', (ws: WebSocket) => {
  ws.on('message', async (data: Buffer) => {
    try {
      const packet = decodeTelemetryBinary(data);
      
      // Publish to distributed Redis stream for worker consensus
      await redisPublisher.xAdd('stream:telemetry', '*', {
        vehicleId: packet.vehicleId,
        lat: packet.lat.toString(),
        lng: packet.lng.toString(),
        soc: packet.soc.toString(),
        timestamp: Date.now().toString(),
      });
    } catch (err) {
      console.error('Packet parsing drop:', err);
    }
  });
});

#Dynamic Sub-Station Load Balancing Algorithm

Our optimizer evaluated grid capacity every 3 seconds using quadratic constraint optimization. If a substation exceeded 85% rated thermal load:

  1. 01Chargers were instructed over WebSockets to taper from 150kW to 60kW.
  2. 02In-transit delivery vans with SoC > 45% received automated in-dash reroutes to adjacent low-stress sub-stations.
typescript
interface GridNode {
  substationId: string;
  currentLoadKw: number;
  maxCapacityKw: number;
}

export function calculateThrottleFactor(node: GridNode): number {
  const utilization = node.currentLoadKw / node.maxCapacityKw;
  if (utilization <= 0.70) return 1.0; // Full 100% speed
  if (utilization <= 0.85) return 0.75; // 75% load
  if (utilization <= 0.95) return 0.40; // Critical load shedding
  return 0.15; // Emergency trickle rate
}

#Results & Hackathon Outcome

  • Ingested 12,400 simultaneous vehicle streams with p99 latency under 42ms.
  • Successfully demonstrated automated grid blackout prevention under simulated transformer failure.
  • Awarded National 1st Prize (₹1,00,000) by the Grand Finale Jury.
Reader Feedback & Reactions
UB

Ankit Bhuria

Founder, Upgrader Boy • National SIH 2024 Winner

We design and ship high-performance MERN & Next.js 15 platforms, IoT telematics architectures, and real-time distributed backends for ambitious startups and enterprises.

Continue Reading

More engineering deep-dives from the Upgrader Boy team

View All