Hello People. This article discusses about Implementing OCPP over MQTT. Creating a correct interoperable OCPP Protocol Buffer and MQTT implementation is important while developing an IoT based EV charging app.
OCPP started supporting websockets sometime ago and also you can implement communication with chargers through MQTT. The two viable choices here are websockets and MQTT.
MQTT stands for MQ Telemetry Transport. It isa light weight event and message oriented protocol allowing devices to asynchronously communicate efficiently across constrained networks to remote systems.
Protocol Buffer is a language-neutral, platform-neutral, extensible mechanism for serializing structured data. Protocol Buffer is used to serialize messages and reduce the bandwidth cost. And utilizing technology like MQTT allows OCPP focus more on the service-oriented logics and leaves the work of networks communication to MQTT.
We can use MQTT for network connection, which is based on TCP/IP. It is recommended to choose broker software supporting MQTT later than 3.1. After setting up the MQTT server, we need to configure both Charge Points and Central System as MQTT clients. MQTT implementation is based on Publisher/Subscriber model. All OCPP messages are posted into MQTT topics, and message receivers need to subscribe to the appropriate topics.
After a Network Connection is established by a MQTT Client to a Server, the first Packet sent from Client to Server MUST be a CONNECT Packet. For different MQTT client, the response might be different. But all of them will return CONNACK. The variable header of CONNACK package contains Connect Return Code which basically indicates whether the connection is accepted or has any errors.
Based on the message direction, there are two types of OCPP topics. They are 1. the message sent from Charge Point to Central System, and 2. the message sent from Central System to Charge Point.
Though Websockets is a new addition and supposedly more modern, MQTT is more suitable for the implementation of OCPP, as we will be dealing with large numbers of chargers with potentially unstable connections.
Hope this article on Implementing OCPP over MQTT is useful to you. Please read about IoT based Electric Vehicle Charging