16#include <ArduinoJson.h>
50#define PROJECT_PATH (__FILE__)
54#define BRANCH_NAME ("N/A")
57#define COMMIT_HASH ("N/A")
62 DBUGLN(F(
"----------------------------------"));
63 DBUG(F(
"Sketch ID: "));
66 DBUG(F(
"From branch '"));
68 DBUG(F(
"', commit "));
79 DBUGLN(F(
"ADC mode: free-running"));
81 DBUGLN(F(
"Electrical settings"));
84 DBUG(F(
"\tf_powerCal for L"));
89 DBUG(F(
"\tf_voltageCal, for Vrms_L"));
95 DBUG(F(
"\tf_phaseCal for all phases = "));
98 DBUG(F(
"\tExport rate (Watts) = "));
101 DBUG(F(
"\tzero-crossing persistence (sample sets) = "));
106 DBUG(F(
"Temperature capability "));
113 DBUGLN(F(
"is NOT present"));
116 DBUG(F(
"Dual-tariff capability "));
124 DBUGLN(F(
"is NOT present"));
127 DBUG(F(
"Load rotation feature "));
134 DBUGLN(F(
"is NOT present"));
137 DBUG(F(
"Relay diversion feature "));
142 relays.printConfiguration();
146 DBUGLN(F(
"is NOT present"));
149 DBUG(F(
"RF capability "));
151 DBUG(F(
"IS present, Freq = "));
152 if (
FREQ == RF12_433MHZ)
154 else if (
FREQ == RF12_868MHZ)
158 DBUGLN(F(
"is NOT present"));
161 DBUG(F(
"Datalogging capability "));
164 DBUGLN(F(
"in Human-readable format"));
168 DBUGLN(F(
"in IoT format"));
172 DBUGLN(F(
"in JSON format"));
176 DBUGLN(F(
"is NOT present"));
198 ArduinoJson::StaticJsonDocument< 256 > doc;
205 doc[
"R"] =
relays.get_average();
211 doc[
"P1"] =
tx_data.power_L[0];
212 doc[
"P2"] =
tx_data.power_L[1];
213 doc[
"P3"] =
tx_data.power_L[2];
218 doc[
"P1"] =
tx_data.power_L[0];
219 doc[
"P2"] =
tx_data.power_L[1];
222 static_assert(
NO_OF_PHASES != 1,
"Unsupported number of phases");
243 doc[String(
"T") + (idx + 1)] = (
float)
tx_data.temperature_x100[idx] * 0.01F;
250 doc[
"TA"] = bOffPeak ?
"low" :
"high";
253 serializeJson(doc, Serial);
275 Serial.print(F(
", P:"));
280 Serial.print(F(
"/"));
281 Serial.print(
relays.get_average());
286 Serial.print(F(
", P"));
287 Serial.print(phase + 1);
288 Serial.print(F(
":"));
289 Serial.print(
tx_data.power_L[phase]);
293 Serial.print(F(
", V"));
294 Serial.print(phase + 1);
295 Serial.print(F(
":"));
296 Serial.print((
float)
tx_data.Vrms_L_x100[phase] * 0.01F);
309 Serial.print(F(
", T"));
310 Serial.print(idx + 1);
311 Serial.print(F(
":"));
312 Serial.print((
float)
tx_data.temperature_x100[idx] * 0.01F);
316 Serial.print(F(
", (minSampleSets/MC "));
318 Serial.print(F(
", #ofSampleSets "));
323 Serial.print(F(
", NoED "));
327 Serial.println(F(
")"));
358 teleInfo.startFrame();
364 teleInfo.
send(
"R",
static_cast< int16_t
>(
relays.get_average()));
369 teleInfo.
send(
"R",
relays.get_relay(idx).isRelayON());
370 }
while (++idx <
relays.get_size());
376 teleInfo.
send(
"V",
tx_data.Vrms_L_x100[idx], idx + 1);
394 teleInfo.
send(
"T",
tx_data.temperature_x100[idx], idx + 1);
425 static bool startup{
true };
468 DBUGLN(F(
"Load Priorities: "));
491 extern int __heap_start, *__brkval;
493 return (
int)&v - (__brkval == 0 ? (int)&__heap_start : (int)__brkval);
Calibration values definition.
constexpr float f_phaseCal
constexpr float f_voltageCal[NO_OF_PHASES]
constexpr float f_powerCal[NO_OF_PHASES]
A class for managing and sending telemetry information in a structured frame format.
void send(const char *tag, int16_t value, uint8_t index=0)
Sends a telemetry value as an integer.
constexpr bool RELAY_DIVERSION
constexpr int networkGroup
constexpr TemperatureSensing temperatureSensing
constexpr RelayEngine relays
constexpr bool DUAL_TARIFF
constexpr SerialOutputType SERIAL_OUTPUT_TYPE
constexpr uint8_t NO_OF_DUMPLOADS
constexpr bool TEMP_SENSOR_PRESENT
constexpr int16_t REQUIRED_EXPORT_IN_WATTS
constexpr float invDATALOG_PERIOD_IN_MAINS_CYCLES
constexpr float invSUPPLY_FREQUENCY
constexpr uint8_t NO_OF_PHASES
constexpr int16_t DEVICE_DISCONNECTED_RAW
constexpr int16_t OUTOFRANGE_TEMPERATURE
Classes/types needed for dual-tariff support.
void printDualTariffConfiguration()
Print the settings for off-peak period.
void sendResults(bool bOffPeak)
Prints or sends telemetry data logs based on the selected output format.
void logLoadPriorities()
Prints the load priorities to the Serial output.
void printConfiguration()
Print the configuration during startup.
void printForJSON(const bool bOffPeak)
Write telemetry data to Serial in JSON format.
void printForSerialText()
Prints data logs to the Serial output in text format.
volatile float copyOf_energyInBucket_main
volatile uint16_t copyOf_sampleSetsDuringThisDatalogPeriod
volatile uint8_t copyOf_lowestNoOfSampleSetsPerMainsCycle
volatile uint16_t copyOf_countLoadON[NO_OF_DUMPLOADS]
volatile uint16_t absenceOfDivertedEnergyCountInSeconds
void printParamsForSelectedOutputMode()
Print the settings used for the selected output mode.
Public functions/variables of processing engine.
constexpr uint8_t PERSISTENCE_FOR_POLARITY_CHANGE
uint8_t loadPrioritiesAndState[NO_OF_DUMPLOADS]
PayloadTx_struct< NO_OF_PHASES > tx_data
Manages telemetry data and frame formatting.
void sendTelemetryData()
Sends telemetry data using the TeleInfo class.
int freeRam()
Get the available RAM during setup.
Some utility functions for the RF chip.
void send_rf_data()
Send the logging data through RF.
Provides utilities for managing temperature sensors.