Skip to content

matth-x/MicroOcpp

Repository files navigation

Icon   MicroOCPP

Build Status Unit tests codecov

OCPP 1.6 / 2.0.1 client for microcontrollers. Portable C/C++. Compatible with Espressif, Arduino, NXP, STM, Linux and more.

✔️ Works with 15+ commercial Central Systems

✔️ Eligible for public chargers (Eichrecht-compliant)

✔️ Supports all OCPP 1.6 feature profiles and the basic OCPP 2.0.1 UCs

Reference usage: OpenEVSE | Technical introduction: Docs | Website: www.micro-ocpp.com

Tester / Demo App

Main repository: MicroOcppSimulator

The Simulator is a demo & development tool for MicroOCPP which allows to quickly assess the compatibility with different OCPP backends. It simulates a full charging station, adds a GUI and a mocked hardware binding to MicroOCPP and runs in the browser (using WebAssembly): Try it

Screenshot

Usage

OCPP server setup: Navigate to "Control Center". In the WebSocket options, add the OCPP backend URL, charge box ID and authorization key if existent. Press "Update WebSocket" to save. The Simulator should connect to the OCPP server. To check the connection status, it could be helpful to open the developer tools of the browser.

If you don't have an OCPP server at hand, leave the charge box ID blank and enter the following backend address: wss://echo.websocket.events/ (this server is sponsored by Lob.com)

RFID authentication: Go to "Control Center" > "Connectors" > "Transaction" and update the idTag with the desired value.

Benchmarks

Full report: MicroOCPP benchmarks

The following measurements were taken on the ESP32 @ 160MHz and represent the optimistic best case scenario for a charger with two physical connectors (i.e. compiled with -Os, disabled debug output and logs).

Description Value
Flash size (minimal) 121,170 B
Heap occupation (idle) 12,308 B
Heap occupation (peak) 21,916 B
Initailization 21 ms
loop() call (idle) 0.05 ms
Large message sent 5 ms

In practical setups, the execution time is largely determined by IO delays and the heap occupation is significantly influenced by the configuration with reservation, local authorization and charging profile lists.

Developers guide

PlatformIO package: MicroOcpp

MicroOCPP is an implementation of the OCPP communication behavior. It automatically initiates the corresponding OCPP operations once the hardware status changes or the RFID input is updated with a new value. Conversely it processes new data from the server, stores it locally and updates the hardware controls when applicable.

Please take examples/ESP/main.cpp as the starting point for the first project. It is a minimal example which shows how to establish an OCPP connection and how to start and stop charging sessions. The API documentation can be found in MicroOcpp.h. Also check out the Docs.

Dependencies

Mandatory:

If compiled with the Arduino integration:

If using the built-in certificate store (to enable, set build flag MO_ENABLE_MBEDTLS=1):

In case you use PlatformIO, you can copy all dependencies from platformio.ini into your own configuration file. Alternatively, you can install the full library with dependencies by adding matth-x/MicroOcpp@1.2.0 in the PIO library manager.

OCPP 2.0.1 and ISO 15118

The following OCPP 2.0.1 use cases are implemented:

UC Description Note
B01 - B04
B11 - B12
Provisioning Ported from OCPP 1.6
B05 - B07 Variables
C01 - C06 Authorization options
C15 Offline Authorization
E01 - E12 Transactions
F01 - F03
F05 - F06
RemoteControl
G01 - G04 Availability
J02 Tx-related MeterValues persistency not supported yet
M03 - M05 Certificate management Enable Mbed-TLS to use the built-in certificate store
P01 - P02 Data transfer
- Protocol negotiation The charger can select the OCPP version at runtime

The OCPP 2.0.1 features are in an alpha development stage. By default, they are disabled and excluded from the build, so they have no impact on the firmware size. To enable, set the build flag MO_ENABLE_V201=1 and initialize the library with the ProtocolVersion parameter 2.0.1 (see this example in the Simulator).

An integration of the library for OCPP 1.6 will also be functional with the 2.0.1 upgrade. It works with the same API in MicroOcpp.h.

ISO 15118 defines some use cases which include a message exchange between the charger and server. This library facilitates the integration of ISO 15118 by handling its OCPP-side communication.

Contact

If you have further questions, feel free to reach out!

✉️ : matthias [A⊤] micro-ocpp [DО⊤] com