sensor_sdm120.h
Go to the documentation of this file.
/* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#pragma once
extern volatile bool sensor_sdm120_measurement_received;
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
};
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
};
void sensor_sdm120_setup(uint32_t baudrate);
bool sensor_sdm120_measurement_request(uint8_t meter_id, enum sensor_sdm120_measurement_type_t type);
bool sensor_sdm120_configuration_request(uint8_t meter_id, enum sensor_sdm120_configuration_type_t type);
bool sensor_sdm120_configuration_set(uint8_t meter_id, enum sensor_sdm120_configuration_type_t type, float value);
float sensor_sdm120_measurement_decode(void);
sensor_sdm120_configuration_type_t
sensor_sdm120_configuration_type_t
configuration types for electricity meter in 4xxx holding registers
Definition: sensor_sdm120.h:45
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
Definition: sensor_sdm120.c:253
sensor_pzem_measurement_t::type
enum sensor_pzem_measurement_type_t type
measurement type
Definition: sensor_pzem.h:39
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
Definition: sensor_sdm120.c:245
sensor_sdm120_measurement_type_t
sensor_sdm120_measurement_type_t
measurement types offered by electricity meter in 3xxx input registers
Definition: sensor_sdm120.h:27
sensor_sdm120_measurement_decode
float sensor_sdm120_measurement_decode(void)
decode received measurement
Definition: sensor_sdm120.c:261
sensor_sdm120_setup
void sensor_sdm120_setup(uint32_t baudrate)
setup peripherals to communicate with electricity meter
Definition: sensor_sdm120.c:127
sensor_sdm120_measurement_received
volatile bool sensor_sdm120_measurement_received
a measurement response has been received
Definition: sensor_sdm120.c:64
sensor_pzem_measurement_t::value
union sensor_pzem_measurement_t::measurement_t value
measurement value
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
Definition: sensor_sdm120.c:237