Backend & Cloud Engineer Guide: EV Charging Networks (OCPP 1.6J/2.0.1) & Smart Grid IoT

Electric Vehicle (EV) Charging Station Management Systems (CSMS), solar microgrid controllers, and battery energy storage systems rely on persistent bi-directional WebSocket connections speaking the Open Charge Point Protocol (OCPP 1.6J and OCPP 2.0.1). Unlike standard web browsers, EV chargers operate over cellular SIM cards in underground parking garages: they disconnect mid-session, buffer offline meter values (`MeterValues`), and require strict command serialization (`RemoteStartTransaction`, `SetChargingProfile`). As a Senior Backend Engineer and Cloud Engineer, I architect resilient OCPP CSMS backends and smart-grid telemetry platforms in Go, Python, and TimescaleDB.

1. OCPP RPC Call Framing & Deterministic Session State Machines

Under the OCPP-J specification, every WebSocket message is a 3- or 4-element JSON array: [2, MessageId, Action, Payload] for a CALL, and [3, MessageId, Payload] for a CALLRESULT. Furthermore, a charger only permits one in-flight server-to-charger CALL at a time per connection—meaning your CSMS gateway must coordinate per-charger command mutexes and correlate replies by MessageId:

import json
import uuid
from typing import Any

OCPP_CALL = 2
OCPP_CALLRESULT = 3
OCPP_CALLERROR = 4

def build_ocpp_remote_start_frame(id_tag: str, connector_id: int = 1) -> tuple[str, str]:
    msg_id = str(uuid.uuid4())
    frame = [
        OCPP_CALL,
        msg_id,
        "RemoteStartTransaction",
        {
            "connectorId": connector_id,
            "idTag": id_tag,
        },
    ]
    return msg_id, json.dumps(frame, separators=(",", ":"))

def calculate_session_kwh_delta(meter_start_wh: int, meter_stop_wh: int) -> float:
    if meter_stop_wh < meter_start_wh:
        raise ValueError("Invalid negative meter reading delta")
    return round((meter_stop_wh - meter_start_wh) / 1000.0, 3)

2. Dynamic Load Management & Time-of-Use Tariff Billing

When 20 EV chargers share a single building transformer with a 250kW peak limit, simultaneously charging 20 vehicles at 22kW trips the main breaker. I implement dynamic SetChargingProfile load-balancing loops that allocate amperage proportionally across active connectors while ingesting 15-second MeterValues into TimescaleDB to calculate exact Time-of-Use (peak vs. off-peak kWh) invoices.

3. Hire a Senior Backend & Cloud Engineer for CleanTech & IoT

Building an OCPP EV charging platform, solar telemetry dashboard, or industrial IoT backend? Explore my Backend Engineer Pillar Guide, review my Cloud Engineer Guide, or book a 1-Day IoT & OCPP Architecture Sprint.


About the Author — Hire Aldian Fazrihady (Cloud Engineer, GCP Professional Cloud Architect, GCP Professional Data Engineer, Backend, AI & Full Stack Engineer)

Aldian Fazrihady is a Top-Rated Senior Cloud Engineer, GCP Professional Cloud Architect (Google Cloud Certified), GCP Professional Data Engineer (Google Cloud Certified), Backend Engineer (Python, Django, FastAPI, Go, PostgreSQL), AI Application Engineer (LLMs, RAG, MCP, Google ADK, LangGraph), and Full Stack Engineer (React, Next.js, TypeScript) with 15+ years of production software engineering experience.

Hire Aldian Fazrihady on Upwork | Book 1-Day Programming Service ($100 USD / Rp 1.000.000) | View Live AI Portfolio | Send a Direct Message

Related Engineering Articles

Engineering Role Pillar Guides & Category Hubs