sensor_sdm120.h File Reference

library to query measurements from eastron SDM120-ModBus electricity meter (API) More...

Go to the source code of this file.

## Enumerations

enum

sensor_sdm120_measurement_type_t {
SENSOR_SDM120_VOLTAGE = 0, SENSOR_SDM120_CURRENT, SENSOR_SDM120_POWER_ACTIVE, SENSOR_SDM120_POWER_APPARENT,
SENSOR_SDM120_POWER_REACTIVE, SENSOR_SDM120_POWER_FACTOR, SENSOR_SDM120_FREQUENCY, SENSOR_SDM120_ENERGY_ACTIVE_IMPORT,
SENSOR_SDM120_ENERGY_ACTIVE_EXPORT, SENSOR_SDM120_ENERGY_REACTIVE_IMPORT, SENSOR_SDM120_ENERGY_REACTIVE_EXPORT, SENSOR_SDM120_ENERGY_ACTIVE_TOTAL,
SENSOR_SDM120_ENERGY_REACTIVE_TOTAL, SENSOR_SDM120_MEASUREMENT_MAX
}

| measurement types offered by electricity meter in 3xxx input registers
enum | sensor_sdm120_configuration_type_t { SENSOR_SDM120_RELAY_PULSE_WIDTH = 0, SENSOR_SDM120_NETWORK_PARITY_STOP, SENSOR_SDM120_METER_ID, SENSOR_SDM120_BAUD_RATE, SENSOR_SDM120_PULSE_1_OUTPUT_MODE, SENSOR_SDM120_TIME_OF_SCROLL_DISPLAY, SENSOR_SDM120_PULSE_1_OUTPUT, SENSOR_SDM120_MEASUREMENT_MODE, SENSOR_SDM120_CONFIGURATION_MAX }
| configuration types for electricity meter in 4xxx holding registers

## Functions

void | sensor_sdm120_setup (uint32_t baudrate)
| setup peripherals to communicate with electricity meter More...
bool | sensor_sdm120_measurement_request (uint8_t meter_id, enum sensor_sdm120_measurement_type_t type)
| request measurement from electricity meter More...
bool | sensor_sdm120_configuration_request (uint8_t meter_id, enum sensor_sdm120_configuration_type_t type)
| request configuration from electricity meter More...
bool | sensor_sdm120_configuration_set (uint8_t meter_id, enum sensor_sdm120_configuration_type_t type, float value)
| set configuration in electricity meter More...
float | sensor_sdm120_measurement_decode (void)
| decode received measurement More...

## Variables

volatile bool | sensor_sdm120_measurement_received
| a measurement response has been received

## Detailed Description

library to query measurements from eastron SDM120-ModBus electricity meter (API)

Author
  King Kévin kingk.nosp@m.evin.nosp@m.@cuvo.nosp@m.odoo.nosp@m..info

Date
  2016

Note
  peripherals used: USART USART peripheral used for communication with electricity meter , GPIO GPIO peripheral used for controlling RS-485 adapter , timer timer peripheral to enforce waiting time between messages

Definition in file sensor_sdm120.h.

## Function Documentation

## sensor_sdm120_configuration_request()

bool sensor_sdm120_configuration_request | ( | uint8_t | meter_id,
|  | enum sensor_sdm120_configuration_type_t | type
| ) |  |

request configuration from electricity meter

Parameters

  [in] | meter_id | electricity meter device ID
  [in] | type | configuration type to request

Returns
  if transmission started

Definition at line 245 of file sensor_sdm120.c.

## sensor_sdm120_configuration_set()

bool sensor_sdm120_configuration_set | ( | uint8_t | meter_id,
|  | enum sensor_sdm120_configuration_type_t | type,
|  | float | value
| ) |  |

set configuration in electricity meter

Parameters

  [in] | meter_id | electricity meter device ID
  [in] | type | configuration type to set
  [in] | value | configuration value to set

Returns
  if transmission started

Definition at line 253 of file sensor_sdm120.c.

## sensor_sdm120_measurement_decode()

float sensor_sdm120_measurement_decode | ( | void |  | ) |

decode received measurement

Returns
  decoded measurement or number of registers written, NaN if message has error or no new measurement has been received, infinity if an error or unknown message has been received

Definition at line 261 of file sensor_sdm120.c.

## sensor_sdm120_measurement_request()

bool sensor_sdm120_measurement_request | ( | uint8_t | meter_id,
|  | enum sensor_sdm120_measurement_type_t | type
| ) |  |

request measurement from electricity meter

Parameters

  [in] | meter_id | electricity meter device ID
  [in] | type | measurement type to request

Returns
  if transmission started

Definition at line 237 of file sensor_sdm120.c.

## sensor_sdm120_setup()

void sensor_sdm120_setup | ( | uint32_t | baudrate | ) |

setup peripherals to communicate with electricity meter

Parameters

  [in] | baudrate | baud rate of RS485 serial communication

Definition at line 127 of file sensor_sdm120.c.