3.7 Meter Values

The MeterValues message in OCPP 1.6J is sent by the charge point to the central system to report meter readings during a charging session. It includes details like the connector ID, meter value (e.g., energy consumed), timestamp, and transaction ID. These readings help track energy usage, monitor the session, and support billing.

API Syntax

Description

Input Params

Return Value

SendMeterValuesRequest

Sends a Meter values request.

Creates an OCPP frame for the request and sends it using “sendframe”.

(void)

void

Example:

     case TRIGGER_MESSAGE_TYPE_METER_VALUE:
            UpdateContext(CONTEXT_TRIGGER);
            SetMeterValuesRequestType(TRIGGER_MESSAGE_DATA);
            SendMeterValuesRequest();
            break; 

API Syntax

Description

Input Params

Return Value

MeterValueStructInit

Initializes the Meter values structure.

void

void

Example:

void OCPPMessagesInit(void)
{
    DataTransferInit();
    ResetInit();
    MeterValueStructInit();
    SetLocalListVersionNumber(DEFAULT_SEND_LOCAL_LIST_VERSION);   
    SetChargePointConnectorId(CHARGEPOINT_DEFAULT_CONTROLLER);
    SetChargePointError(NOERROR);
    SetChargePointStatus(AVAILABLE);
    SetAuthorizeStatus(AUTHORIZE_INVALID);
    SetRemoteStartTransactionStatus(REMOTE_START_STOP_REJECTED);
    SetOCPPWebsocketOnlineMode();
    UnlockConnectorInit();
    ReserveNowInit();
    ChangeAvailabilityInit();
    ClearCacheInit();
    ChangeConfigurationInit();
    CancelReservationInit();
    GetAllIDsFromDB();
    CheckAndStartClockAlignedMeterValueTimer();
}

API Syntax

Description

Input Params

Return Value

StartMeterValueIntervalTimer

This function starts the timer for Meter values based on the interval passed.

unsigned int inverval

void

Example:

    if((strncmp(meterValueSampleInterval, "0", strlen(meterValueSampleInterval)) != 0) && ((strncmp(ChargePointStatus, "Charging", strlen(ChargePointStatus)) == 0) ))
    {
        unsigned int timerInterval;
       timerInterval = atoi(meterValueSampleInterval);
       StartMeterValueIntervalTimer(timerInterval);
    }
    else
    {
        LogDebug("APP_LOG", " MeterValueSampleInterval not enabled \n\r");
    }

API Syntax

Description

Input Params

Return Value

StopMeterValueIntervalTimer

This function stops the timer that was started for Meter values.

void

void

Example:

    if((strncmp(meterValueSampleInterval, "0", strlen(meterValueSampleInterval)) != 0))
    {
       StopMeterValueIntervalTimer();
    }
    else
    {
        LogDebug("APP_LOG", " MeterValueSampleInterval not enabled \n\r");
    }

Syntax

Description

Constants/Members

READINGCONTECT_T

Enum represents the context of the Meter values.

CONTEXT_INTERRUPTION_BEGIN,

CONTEXT_INTERRUPTION_END,

CONTEXT_OTHER,

CONTEXT_SAMPLE_CLOCK,

CONTEXT_SAMPLE_PERIODIC,CONTEXT_TRANSACTION_BEGIN,

CONTEXT_TRANSACTION_END,

CONTEXT_TRIGGER,

VALUEFORMAT_T

Enum represents the value format.

RAW,

SIGNEDDATA,

MEASURAND_T

Enum represents the Measurand of the Meter values.

CURRENT_EXPORT,

CURRENT_IMPORT,

CURRENT_OFFERED,

ENERGY_ACTIVE_EXPORT_REGISTER, ENERGY_ACTIVE_IMPORT_REGISTER,

ENERGY_REACTIVE_EXPORT_REGISTER,

ENERGY_REACTIVE_IMPORT_REGISTER,

ENERGY_ACTIVE_EXPORT_INTERVAL,

 ENERGY_ACTIVE_IMPORT_INTERVAL,

 ENERGY_REACTIVE_EXPORT_INTERVAL,

ENERGY_REACTIVE_IMPORT_INTERVAL,

FREQUENCY,

POWER_ACTIVE_EXPORT,

POWER_ACTIVE_IMPORT,

POWER_FACTOR, POWER_OFFERED,

POWER_REACTIVE_EXPORT,

POWER_REACTIVE_IMPORT,

RPM,

SOC,

 TEMPERATURE,

 VOLTAGE,

PHASE_T

Enum represents the phase of the Meter values.

    L1,

    L2,

    L3,

    N,

    L1N,

    L2N,

    L3N,

    L1L2,

    L2L3,

    L3L1,

LOCATION_T

Enum represents the location of the Meter values.

    BODY,

    CABLE,

    EV,

    INLET,

    OUTLET

UNITOFMEASURE_T

Enum represents the unit of the Measurand.

    WH,

    KWH,

    VARH,

    KVARH,

    W,

    KW,

    VA,

    KVA,

    VAR,

    KVAR,

    A,

    V,

    CELSIUS,

    FAHRENHEIT,

    K,

    PERCENT,

SAMPLEDVALUE_T

Structure represents the sample values.

    double value;

    READINGCONTECT_T context;

    VALUEFORMAT_T format;

    MEASURAND_T measurand;

    PHASE_T phase;

    LOCATION_T location;

    UNITOFMEASURE_T unit;

ALL_METERVALUES_T

Structure contains all the sampled values of the Measurand.

    SAMPLEDVALUE_T currentExport;

    SAMPLEDVALUE_T currentImport;

    SAMPLEDVALUE_T currentOffered;

    SAMPLEDVALUE_T energyActiveExportRegister;

    SAMPLEDVALUE_T energyActiveImportRegister;

    SAMPLEDVALUE_T energyReactiveExportRegister;

    SAMPLEDVALUE_T energyReactiveImportRegister;

    SAMPLEDVALUE_T energyActiveExportInterval;

    SAMPLEDVALUE_T energyActiveImportInterval;

    SAMPLEDVALUE_T energyReactiveExportInterval;

    SAMPLEDVALUE_T energyReactiveImportInterval;

    SAMPLEDVALUE_T frequency;

    SAMPLEDVALUE_T powerActiveExport;

    SAMPLEDVALUE_T powerActiveImport;

    SAMPLEDVALUE_T powerFactor;

    SAMPLEDVALUE_T powerOffered;

    SAMPLEDVALUE_T powerReactiveExport;

    SAMPLEDVALUE_T powerReactiveImport;

    SAMPLEDVALUE_T rpm;

    SAMPLEDVALUE_T soc;

    SAMPLEDVALUE_T temperature;

    SAMPLEDVALUE_T voltage;

METERVALUE_T

Structure represents the timestamp and sampled value of Meter values.

    char timestamp[METER_VALUE_SIZE];

    SAMPLEDVALUE_T sampledValue;

TX_METERVALUES_T

Structure represents the transmission data of Meter values.

   uint16_t connectorId;

    METERVALUE_T meterValue;

    uint16_t transactionId;

METERVALUE_TYPE_T

Enum represents the types of data.

    SAMPLE_METER_DATA,

    CLOCK_ALIGNED_DATA,

    STOP_TXN_SAMPLE_METER_DATA,

    STOP_TXN_CLOCK_ALIGNED_DATA,

    TRIGGER_MESSAGE_DATA