diff --git a/lib/sensor_pzem.c b/lib/sensor_pzem.c index 9d1753a..daabb71 100644 --- a/lib/sensor_pzem.c +++ b/lib/sensor_pzem.c @@ -43,7 +43,7 @@ static uint8_t rx_buffer[7] = {0}; /**< buffer for received response */ static volatile uint8_t rx_i = 0; /**< current position of read received data */ static uint8_t tx_buffer[7] = {0}; /**< buffer for request to transmit */ -static volatile uint8_t tx_i = 0; /**< current position if transmitted data */ +static volatile uint8_t tx_i = 0; /**< current position of transmitted data */ volatile bool sensor_pzem_measurement_received = false; @@ -133,6 +133,9 @@ struct sensor_pzem_measurement_t sensor_pzem_measurement_decode(void) case SENSOR_PZEM_ENERGY: measurement.value.power = ((uint32_t)rx_buffer[1]<<16)+((uint16_t)rx_buffer[2]<<8)+rx_buffer[3]; break; + case SENSOR_PZEM_ADDRESS: + case SENSOR_PZEM_ALARM: + break; // no value is returned default: measurement.valid = false; // unexpected type } diff --git a/lib/sensor_pzem.h b/lib/sensor_pzem.h index dd7b381..952eef9 100644 --- a/lib/sensor_pzem.h +++ b/lib/sensor_pzem.h @@ -23,12 +23,14 @@ /** a measurement response has been received */ extern volatile bool sensor_pzem_measurement_received; -/** measurements offered by electricity meter */ +/** measurements (and configurations) offered by electricity meter */ enum sensor_pzem_measurement_type_t { SENSOR_PZEM_VOLTAGE = 0, SENSOR_PZEM_CURRENT = 1, SENSOR_PZEM_POWER = 2, SENSOR_PZEM_ENERGY = 3, + SENSOR_PZEM_ADDRESS = 4, + SENSOR_PZEM_ALARM = 5, SENSOR_PZEM_MAX };