Add multi-meter energy sender schema with UART0/1/2 mode split
This commit is contained in:
@@ -32,7 +32,9 @@ constexpr uint8_t PIN_BAT_ADC = 35;
|
||||
constexpr uint8_t PIN_ROLE = 14;
|
||||
constexpr uint8_t PIN_OLED_CTRL = 13;
|
||||
|
||||
constexpr uint8_t PIN_METER_RX = 34;
|
||||
constexpr uint8_t PIN_METER1_RX = 34; // UART2 RX
|
||||
constexpr uint8_t PIN_METER2_RX = 25; // UART1 RX
|
||||
constexpr uint8_t PIN_METER3_RX = 3; // UART0 RX (prod only, when serial debug is off)
|
||||
|
||||
// LoRa settings
|
||||
#ifndef LORA_FREQUENCY_HZ
|
||||
@@ -68,6 +70,9 @@ constexpr bool ENABLE_HA_DISCOVERY = true;
|
||||
#define SERIAL_DEBUG_MODE_FLAG 0
|
||||
#endif
|
||||
constexpr bool SERIAL_DEBUG_MODE = SERIAL_DEBUG_MODE_FLAG != 0;
|
||||
constexpr uint8_t METER_COUNT_DEBUG = 2;
|
||||
constexpr uint8_t METER_COUNT_PROD = 3;
|
||||
constexpr uint8_t METER_COUNT = SERIAL_DEBUG_MODE ? METER_COUNT_DEBUG : METER_COUNT_PROD;
|
||||
constexpr bool SERIAL_DEBUG_DUMP_JSON = false;
|
||||
constexpr bool LORA_SEND_BYPASS = false;
|
||||
constexpr bool ENABLE_SD_LOGGING = true;
|
||||
|
||||
@@ -28,6 +28,9 @@ struct MeterData {
|
||||
uint32_t ts_utc;
|
||||
uint16_t short_id;
|
||||
char device_id[16];
|
||||
bool energy_multi;
|
||||
uint8_t energy_meter_count;
|
||||
uint32_t energy_kwh_int[3];
|
||||
float energy_total_kwh;
|
||||
float phase_power_w[3];
|
||||
float total_power_w;
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
#include "data_model.h"
|
||||
|
||||
void meter_init();
|
||||
bool meter_read(MeterData &data);
|
||||
bool meter_poll_frame(const char *&frame, size_t &len);
|
||||
bool meter_parse_frame(const char *frame, size_t len, MeterData &data);
|
||||
void meter_poll();
|
||||
uint8_t meter_count();
|
||||
bool meter_get_last_energy_kwh(uint8_t meter_idx, uint32_t &out_energy_kwh);
|
||||
|
||||
Reference in New Issue
Block a user