Skip to content

Sunbeth Fuel Forecourt

I built a forecourt prototype that signs OPay POS orders and sends the matching payment state over WebSockets to an ESP32 dispenser interlock. The Express gateway records dispenser totals in SQLite and streams telemetry to React.

How it’s built View architecture

How it’s built

Sunbeth Fuel Forecourt · Fuel forecourt controller linking ESP32 dispensers to OPay POS payments

Sunbeth Fuel Forecourt is a forecourt controller prototype for a Nigerian fuel station that releases fuel only after an OPay POS payment is confirmed. I wrote the ESP32 firmware, a 7-state machine that drives a solenoid relay and counts flow-meter pulses on an interrupt. I also built the TypeScript Express gateway with 9 REST endpoints, HMAC-SHA512 request signing, a WebSocket channel to dispensers and a 6-table SQLite database, plus a React SCADA dashboard and simulators for bench testing.

firmware state machine states
7
REST endpoints
9
SQLite tables
6
lines of ESP32 firmware (C++)
715
React dashboard components
9
simulators (mock ESP32, mock OPay cloud, full run)
3

Technology and what it does here

ESP32 (Arduino / PlatformIO)
Dispenser controller with relay valve, flow interrupt and FreeRTOS task
ST7735 TFT
On-dispenser display for amount and status
Express + TypeScript
FCC transaction, OPay webhook and admin SCADA endpoints
ws (WebSocket)
Bidirectional gateway at /ws/fcc for dispenser registration and payment state
better-sqlite3
Edge database in WAL mode for transactions and totalizer audits
OPay POS API
Sends orders to a named POS terminal and receives payment webhooks
Node crypto (HMAC-SHA512)
Signs payloads after recursive alphabetical key sorting
React 19 + Vite
Dashboard with dispensers, tank gauges, KPIs, ledger and price control

Implementation details

  • OPay requests are signed by recursively sorting JSON keys at every level before HMAC-SHA512, with a test that checks key order, 128-hex signature length and verification.
  • Flow-meter pulses are counted on a falling-edge interrupt and the dispensing loop runs in a task pinned to a core with xTaskCreatePinnedToCore.
  • A totalizer_logs table records dispenser meter readings for auditing alongside transactions.
  • Bench simulation mode in firmware generates 1-second flow pulses so the full payment-to-dispense loop can be tested without hardware.

Prototype architecture

The forecourt prototype ties an OPay settlement to a dispenser session. The controller receives the payment state over WebSocket and reports delivery back to the local gateway.

Drag to rotate

Payment and dispenser control

  1. Passes to the next component: Order request
  2. Passes to the next component: Payment callback
  3. Passes to the next component: Paid session

Delivery telemetry

  1. Passes to the next component: Delivery report
  2. Passes to the next component: Station totals

System connections

Component details

Technologies

  • React
  • Express
  • ESP32
  • WebSockets
  • SQLite
  • OPay

Next project · AI/ML Engineer

Sigmant

Portfolio assistant

Gabriel’s projects, experience, and research