sensor_pzem.h File Reference

library to query measurements from peacefair PZEM-004 and PZEM-004T electricity meter (API) More...

Go to the source code of this file.

## Data Structures

struct | sensor_pzem_measurement_t
| measurement returned by electricity meter More...
union | sensor_pzem_measurement_t::measurement_t
| possible measurement values More...

## Enumerations

enum | sensor_pzem_measurement_type_t { SENSOR_PZEM_VOLTAGE = 0, SENSOR_PZEM_CURRENT = 1, SENSOR_PZEM_POWER = 2, SENSOR_PZEM_ENERGY = 3, SENSOR_PZEM_MAX }
| measurements (and configurations) offered by electricity meter

## Functions

void | sensor_pzem_setup (void)
| setup peripherals to communicate with electricity meter
void | sensor_pzem_measurement_request (uint32_t address, enum sensor_pzem_measurement_type_t type)
| request measurement from electricity meter More...
struct sensor_pzem_measurement_t | sensor_pzem_measurement_decode (void)
| decode received measurement More...

## Variables

volatile bool | sensor_pzem_measurement_received
| a measurement response has been received

## Detailed Description

library to query measurements from peacefair PZEM-004 and PZEM-004T 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, timer timer peripheral used for waiting before sending the next request

Definition in file sensor_pzem.h.

## Function Documentation

## sensor_pzem_measurement_decode()

struct sensor_pzem_measurement_t sensor_pzem_measurement_decode | ( | void |  | ) |

decode received measurement

Returns
  decoded measurement (invalid if no new measurement has been received)

Definition at line 128 of file sensor_pzem.c.

## sensor_pzem_measurement_request()

void sensor_pzem_measurement_request | ( | uint32_t | address,
|  | enum sensor_pzem_measurement_type_t | type
| ) |  |

request measurement from electricity meter

Parameters

  [in] | address | electricity meter device address
  [in] | type | measurement type to request

Definition at line 97 of file sensor_pzem.c.