Type | Name |
---|---|
struct | ce2727a_config_t CE2727A driver configuration. |
typedef struct ce2727a_driver_state_t * | ce2727a_handle_t CE2727A driver handle. |
struct | ce2727a_readings_energy_t CE2727A readings. |
Type | Name |
---|---|
esp_err_t | ce2727a_deinit (ce2727a_handle_t handle) Deinitialize the CE2727A driver. |
esp_err_t | ce2727a_get_active_power (ce2727a_handle_t handle, uint32_t * active_power, uint16_t timeout_ms) Get active power. |
esp_err_t | ce2727a_get_energy (ce2727a_handle_t handle, ce2727a_readings_energy_t* readings, uint16_t timeout_ms) Get energy readings. |
esp_err_t | ce2727a_init (const ce2727a_config_t* config, ce2727a_handle_t * out_handle) Initialize the CE2727A driver. |
CE2727A driver configuration. Variables:
-
uint32_t addr
Target power meter address, default is 0x0 - broadcasting to all meters -
uint32_t password
Target power meter password, default is 0x0 -
uint8_t * rx_buffer
Receive buffer. Shall be enough to hold required responses -
uint16_t rx_buffer_size
Size of receive buffer -
uart_config_t * uart_config_override
UART port configuration override parameters. defaults: 9600,8E1 -
uint8_t uart_de_pin
UART RTS pin for RS485 DE=!RE -
uint8_t uart_port
UART port number -
uint8_t uart_rx_pin
UART RX pin -
uint8_t uart_tx_pin
UART TX pin
CE2727A driver handle.
typedef struct ce2727a_driver_state_t* ce2727a_handle_t;
CE2727A readings. Variables:
-
uint8_t active_tariff
Current active tariff [1,2,3,4] -
uint32_t t1
Cumulative energy for tariff 1 -
uint32_t t2
Cumulative energy for tariff 2 -
uint32_t t3
Cumulative energy for tariff 3 -
uint32_t t4
Cumulative energy for tariff 4 -
uint32_t total
Cumulative energy consumed on all tariffs
Deinitialize the CE2727A driver.
esp_err_t ce2727a_deinit (
ce2727a_handle_t handle
)
Parameters:
handle
Driver handle obtained from ce2727a_init(), or NULL
Returns:
esp_err_t ESP_OK on success.
Get active power.
esp_err_t ce2727a_get_active_power (
ce2727a_handle_t handle,
uint32_t * active_power,
uint16_t timeout_ms
)
Get current active power
Parameters:
handle
Driver handle obtained from ce2727a_init()active_power
Active powertimeout_ms
Timeout in milliseconds for receiving a response from the meter
Returns:
esp_err_t
- ESP_OK on success
- ESP_ERR_TIMEOUT if no message was received within the timeout
- ESP_ERR_INVALID_ARG if the buffer too short
- ESP_ERR_INVALID_RESPONSE
- ESP_ERR_INVALID_CRC
- ESP_ERR_INVALID_STATE Issues sending data
Get energy readings.
esp_err_t ce2727a_get_energy (
ce2727a_handle_t handle,
ce2727a_readings_energy_t * readings,
uint16_t timeout_ms
)
Get energy readings
Parameters:
handle
Driver handle obtained from ce2727a_init()readings
Destination for readingstimeout_ms
Timeout in milliseconds for receiving a response from the meter
Returns:
esp_err_t
- ESP_OK on success
- ESP_ERR_TIMEOUT if no message was received within the timeout
- ESP_ERR_INVALID_ARG if the buffer too short
- ESP_ERR_INVALID_RESPONSE
- ESP_ERR_INVALID_CRC
- ESP_ERR_INVALID_STATE Issues sending data
Initialize the CE2727A driver.
esp_err_t ce2727a_init (
const ce2727a_config_t * config,
ce2727a_handle_t * out_handle
)
Parameters:
config
Pointer to the configuration struct. The driver makes a copy, so can point to a local variable.out_handle
Pointer to a variable to receive the driver handle.
Returns:
esp_err_t ESP_OK on success, ESP_ERR_NO_MEM if out of memory.