Electric mobility companies deploying electric motorcycles (e-bodas), electric three-wheelers (e-tuk-tuks), and Battery-as-a-Service (BaaS) swapping networks across Nairobi, Mombasa, Kisumu, Eldoret, Kampala, and Kigali manage thousands of circulating Lithium Iron Phosphate (LFP) and Nickel Manganese Cobalt (NMC) battery packs. Treating a $650–$950 smart lithium battery pack like an anonymous LPG cylinder—without real-time CAN-bus Battery Management System (BMS) cell-imbalance telemetry, coulomb-counted State of Health (SoH) depreciation ledgers, smart cabinet slot thermal interlocks, and automated M-Pesa differential energy billing—leads to accelerated pack degradation from hot-pack fast charging, battery theft and BMS spoofing, peak-tariff electricity margin erosion, and stranded riders at depleted swap stations.
At devManue, we engineer custom Electric Motorcycle Battery-Swapping Network, Smart Cabinet IoT & LFP Pack Lifecycle ERP platforms. Our architecture connects 4G/MQTT swap cabinets, CAN-bus 2.0B / RS-485 BMS handshakes, dynamic Time-of-Use (ToU) charger current throttling, rider M-Pesa STK Push / wallet energy settlement, and second-life stationary BESS retirement workflows.
1. Atomic Battery Custody, CAN-Bus BMS Telemetry & Fraud Prevention
In a high-throughput swap station handling $80\text{–}150$ swaps per day, the physical battery swap must execute in under $45\text{ seconds}$ while preventing three critical attack vectors: inserting a counterfeit/cloned shell, returning a pack with severe internal cell imbalance ($\Delta V_{\text{cell}} > 80\text{ mV}$) or water ingress fault flags, or swapping a battery belonging to a defaulted hire-purchase motorcycle. Every battery pack contains a cryptographic BMS serial number verified over CAN-bus immediately upon slot insertion before the charged door latch is energized.
Our PostgreSQL schema tracks every battery pack's cell chemistry, cycle count, Coulombic SoH trajectory, current custodian (station slot vs. rider motorcycle), and swap financial ledger:
-- PostgreSQL Schema for e-Boda Battery Packs, Swap Cabinets & Custody Ledger
CREATE TABLE ev_battery_packs (
pack_id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
bms_hardware_uid VARCHAR(64) UNIQUE NOT NULL,
chemistry VARCHAR(16) NOT NULL DEFAULT 'LFP_72V_45AH', -- Nominal 3.24 kWh
nominal_capacity_ah NUMERIC(6, 2) NOT NULL DEFAULT 45.00,
full_charge_capacity_ah NUMERIC(6, 2) NOT NULL DEFAULT 45.00,
state_of_health_pct NUMERIC(5, 2) NOT NULL DEFAULT 100.00,
total_charge_cycles INTEGER NOT NULL DEFAULT 0,
max_cell_delta_mv NUMERIC(6, 2) NOT NULL DEFAULT 12.00,
custody_state VARCHAR(24) NOT NULL, -- IN_CABINET_SLOT, ASSIGNED_TO_RIDER, IN_MAINTENANCE, RETIRED_2ND_LIFE
current_holder_id UUID, -- References swap_station_id or rider_account_id
last_telemetry_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
CREATE TABLE ev_battery_swap_transactions (
swap_id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
station_id UUID NOT NULL,
rider_id UUID NOT NULL,
returned_pack_id UUID NOT NULL REFERENCES ev_battery_packs(pack_id),
returned_soc_pct NUMERIC(5, 2) NOT NULL,
returned_pack_temp_c NUMERIC(4, 1) NOT NULL,
issued_pack_id UUID NOT NULL REFERENCES ev_battery_packs(pack_id),
issued_soc_pct NUMERIC(5, 2) NOT NULL,
net_energy_dispensed_kwh NUMERIC(6, 3) NOT NULL,
tariff_rate_kes_per_kwh NUMERIC(7, 2) NOT NULL,
billed_amount_kes NUMERIC(10, 2) NOT NULL,
mpesa_receipt_no VARCHAR(32) UNIQUE,
swapped_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);2. BMS State-of-Health (SoH), Thermal Rest & ToU Charging Engine in Python
Immediately charging an LFP pack returned from steep uphill riding at $46\text{ °C}$ internal cell temperature accelerates SEI layer growth and lithium plating. Conversely, charging all slots at $1.0\text{C}$ during evening grid peak hours inflates electricity costs and trips transformer breakers. Below is our Python cabinet controller & ERP billing engine that enforces thermal cool-down rest, calculates net $\text{kWh}$ swap charges, and modulates CC/CV charging currents across off-peak tariff windows:
from dataclasses import dataclass
from decimal import Decimal, ROUND_HALF_UP
@dataclass
class SwapSettlementAndChargePlan:
returned_pack_uid: str
soh_pct: Decimal
net_energy_kwh: Decimal
total_charge_kes: Decimal
pack_quarantined: bool
quarantine_reason: str
recommended_charge_current_amps: Decimal
def process_battery_swap_and_charging(
returned_pack_uid: str,
nominal_voltage_v: Decimal,
nominal_capacity_ah: Decimal,
bms_full_capacity_ah: Decimal,
soc_issued_prev_pct: Decimal,
soc_returned_now_pct: Decimal,
pack_temp_c: Decimal,
cell_delta_mv: Decimal,
is_off_peak_tariff_window: bool,
rate_kes_per_kwh: Decimal = Decimal("42.50"),
) -> SwapSettlementAndChargePlan:
"""
Computes pack SoH, net kWh consumed since previous issue, BMS safety quarantine,
and thermal/tariff-aware charging current setpoint.
"""
soh_pct = ((bms_full_capacity_ah / nominal_capacity_ah) * Decimal("100")).quantize(
Decimal("0.01"), rounding=ROUND_HALF_UP
)
# Actual usable kWh capacity adjusted for current SoH
effective_pack_kwh = (nominal_voltage_v * bms_full_capacity_ah) / Decimal("1000")
soc_delta_fraction = max(Decimal("0"), (soc_issued_prev_pct - soc_returned_now_pct) / Decimal("100"))
net_kwh = (effective_pack_kwh * soc_delta_fraction).quantize(Decimal("0.001"), rounding=ROUND_HALF_UP)
charge_kes = (net_kwh * rate_kes_per_kwh).quantize(Decimal("0.01"), rounding=ROUND_HALF_UP)
# Safety & cell-imbalance quarantine checks
if cell_delta_mv > Decimal("85.0"):
return SwapSettlementAndChargePlan(
returned_pack_uid, soh_pct, net_kwh, charge_kes, True,
"CELL_IMBALANCE_EXCEEDS_85MV_ACTIVE_BALANCING_REQUIRED", Decimal("0.0")
)
if soh_pct < Decimal("75.0"):
return SwapSettlementAndChargePlan(
returned_pack_uid, soh_pct, net_kwh, charge_kes, True,
"RETIRE_TO_SECOND_LIFE_STATIONARY_BESS", Decimal("0.0")
)
# Thermal & Time-of-Use (ToU) current modulation
if pack_temp_c >= Decimal("43.0"):
# Fan cooling only until cell temp drops below 38°C
charge_amps = Decimal("0.0")
elif is_off_peak_tariff_window:
charge_amps = (nominal_capacity_ah * Decimal("0.65")).quantize(Decimal("0.1"))
else:
charge_amps = (nominal_capacity_ah * Decimal("0.40")).quantize(Decimal("0.1"))
return SwapSettlementAndChargePlan(
returned_pack_uid=returned_pack_uid,
soh_pct=soh_pct,
net_energy_kwh=net_kwh,
total_charge_kes=charge_kes,
pack_quarantined=False,
quarantine_reason="NONE",
recommended_charge_current_amps=charge_amps,
)3. IAS 16 Battery Depreciation & Second-Life Stationary BESS Repurposing
Instead of depreciating EV battery packs on a flat 3-year calendar schedule, our ERP depreciates each pack on a unit-of-production (cycle-degradation) basis tied to measured $\text{SoH}$ loss per swap. When a mobility pack crosses the $75\%\text{ SoH}$ threshold where rider range drops below commercial requirements, the ERP automatically flags the slot to lock the pack for collection and transfers its residual book value into the Second-Life Stationary Solar BESS Inventory for telecom base stations and rural microgrids.
| EV Battery-Swap Network Metric | Legacy Spreadsheets & Manual Tallying | devManue Custom Enterprise ERP |
|---|---|---|
| Battery Pack Custody & Anti-Theft | Manual swap logbooks; packs swapped across unauthorized bikes or lost without audit trail. | Cryptographic CAN-bus BMS UID handshake pairing every pack to a verified rider & motorcycle VIN. |
| Swap Billing Fairness | Flat fee per swap penalizes riders returning packs with 35% remaining SoC. | Coulomb-counted differential kWh billing (SoC_issued minus SoC_returned) settled instantly via M-Pesa. |
| Pack Thermal Lifespan Protection | Immediate 1C fast-charging of hot returned packs (>45°C), cutting LFP cycle life in half. | Automated cabinet fan cool-down interlock (<38°C) and cell Delta-V (>85 mV) quarantine locking. |
| Grid Electricity Cost Optimization | All cabinet slots charge at maximum current during peak tariff hours. | Dynamic CC/CV current throttling shifting bulk kWh replenishment into KPLC off-peak Time-of-Use windows. |
Related Enterprise ERP & Engineering Guides
- PAYGO Asset Financing & IoT Remote Immobilizer ERP — Integrating daily e-boda motorcycle hire-purchase installments with battery swap wallet deductions.
- Battery Manufacturing, Recycling & Warranty Lifecycle ERP — End-of-life battery pack material recovery and warranty claim forensics.
- Solar EPC, Mini-Grid & BESS Energy Storage ERP — Repurposing retired 75% SoH e-mobility LFP packs into stationary solar microgrid storage banks.
- Harbor Tugboat Towage, Marine Pilotage Dispatch, Bollard-Pull Telemetry & Port Berth Allocation ERP — How to architect a Harbor Tugboat Towage, Marine Pilotage Dispatch, Bollard-Pull Telemetry & Port Berth Allocation ERP: vessel.
- Custom EV Fleet, BaaS Swap Network & IoT Telemetry ERP — Architect your e-mobility battery swapping and M-Pesa billing platform with devManue.