Heartbeat

Core CS->CSMS OCPP 2.0.1

Sent by the Charging Station to indicate it is still connected and operational. The CSMS responds with the current time for clock synchronization.

Quick Reference

This message has an empty payload: {}

Example Payload

{}

Example Full Frame

[
  2,
  "msg-001",
  "Heartbeat",
  {}
]

Format: [MessageType, MessageId, Action, Payload]

Overview

The Heartbeat message serves as a keep-alive signal between the Charging Station and the CSMS. It lets the CSMS know the Charging Station is still online and also provides a clock synchronization mechanism.

When to Send

  • Periodically, at the interval specified in the BootNotification response
  • The interval can be updated via SetVariables with variable HeartbeatInterval
  • Only after receiving a BootNotification response with status: Accepted

Expected Response

The CSMS responds with:

  • currentTime: ISO 8601 timestamp — use this to keep the Charging Station clock synchronized

Key Differences from OCPP 1.6J

Functionally identical to 1.6J. Both request and response have empty or minimal payloads. The main operational difference is that in 2.0.1 the heartbeat interval is managed via SetVariables instead of ChangeConfiguration.

Usage Notes

  • The request payload is always an empty object {}
  • If the heartbeat times out repeatedly, consider the connection lost
  • Do not send heartbeats if the WebSocket is disconnected

Best Practices

  1. Respect the interval - Use the value from BootNotification response, not a hardcoded one
  2. Stop on disconnect - Pause the heartbeat timer when the WebSocket drops
  3. Use currentTime for clock sync - Periodically adjust the Charging Station clock from the response

Testing Tips

  • Verify the heartbeat starts only after a successful BootNotification
  • Test that the interval updates correctly when HeartbeatInterval is set via SetVariables
  • Verify behavior when the CSMS is temporarily unreachable

Common Errors

GenericError

Cause: Heartbeat sent before BootNotification is Accepted

Solution: Only start the heartbeat loop after receiving BootNotification response with status Accepted

RpcFrameworkError

Cause: Non-empty payload sent in the request

Solution: Heartbeat request payload must be an empty object {}