16#include <ArduinoJson.h>
54#define PROJECT_PATH (__FILE__)
58#define BRANCH_NAME ("N/A")
61#define COMMIT_HASH ("N/A")
66 DBUGLN(F(
"----------------------------------"));
67 DBUG(F(
"Sketch ID: "));
70 DBUG(F(
"From branch '"));
72 DBUG(F(
"', commit "));
83 DBUGLN(F(
"ADC mode: free-running"));
85 DBUGLN(F(
"Electrical settings"));
87 DBUG(F(
"\tf_powerCal for Grid"));
90 DBUG(F(
"\tf_powerCal for Diversion"));
94 DBUG(
"\tAnti-creep limit (Joules / mains cycle) = ");
96 DBUG(
"\tExport rate (Watts) = ");
101 DBUG(F(
"Datalogging capability "));
104 DBUGLN(F(
"in Human-readable format"));
108 DBUGLN(F(
"in IoT format"));
112 DBUGLN(F(
"in JSON format"));
116 DBUGLN(F(
"is NOT present"));
136 Serial.print(F(
", P:"));
137 Serial.print(
tx_data.powerGrid);
141 Serial.print(F(
"/"));
142 Serial.print(
relays.get_average());
145 Serial.print(F(
", D:"));
146 Serial.print(
tx_data.powerDiverted);
148 Serial.print(F(
", E:"));
151 Serial.print(F(
", V"));
152 Serial.print(F(
":"));
153 Serial.print((
float)
tx_data.Vrms_L_x100 * 0.01f);
165 Serial.print(F(
", T"));
166 Serial.print(idx + 1);
167 Serial.print(F(
":"));
168 Serial.print((
float)
tx_data.temperature_x100[idx] * 0.01f);
172 Serial.print(F(
", (minSampleSets/MC "));
174 Serial.print(F(
", #ofSampleSets "));
180 Serial.print(F(
", NoED "));
185 Serial.println(F(
")"));
206 ArduinoJson::StaticJsonDocument< 256 > doc;
212 doc[
"R"] =
relays.get_average();
215 doc[
"D"] =
tx_data.powerDiverted;
217 doc[
"V"] = (float)
tx_data.Vrms_L_x100 * 0.01f;
228 doc[String(
"T") + (idx + 1)] = (
float)
tx_data.temperature_x100[idx] * 0.01f;
234 serializeJson(doc, Serial);
265 teleInfo.startFrame();
271 teleInfo.
send(
"R",
static_cast< int16_t
>(
relays.get_average()));
276 teleInfo.
send(
"R",
relays.get_relay(idx).isRelayON());
277 }
while (++idx <
relays.get_size());
294 teleInfo.
send(
"T",
tx_data.temperature_x100[idx], idx + 1);
325 static bool startup{
true };
364 extern int __heap_start, *__brkval;
366 return (
int)&v - (__brkval == 0 ? (int)&__heap_start : (int)__brkval);
Calibration values definition.
constexpr float powerCal_grid
constexpr float powerCal_diverted
Container for datalogging.
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 TemperatureSensing temperatureSensing
constexpr RelayEngine relays
constexpr SerialOutputType SERIAL_OUTPUT_TYPE
constexpr bool TEMP_SENSOR_PRESENT
constexpr int16_t REQUIRED_EXPORT_IN_WATTS
constexpr float invSUPPLY_FREQUENCY
constexpr uint8_t ANTI_CREEP_LIMIT
constexpr int16_t DEVICE_DISCONNECTED_RAW
constexpr int16_t OUTOFRANGE_TEMPERATURE
Classes/types needed for dual-tariff support.
void sendResults(bool bOffPeak)
Prints or sends telemetry data logs based on the selected output format.
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 uint16_t copyOf_divertedEnergyTotal_Wh_forDL
volatile int32_t copyOf_energyInBucket_long
volatile uint16_t copyOf_sampleSetsDuringThisDatalogPeriod
volatile uint8_t copyOf_lowestNoOfSampleSetsPerMainsCycle
volatile uint16_t absenceOfDivertedEnergyCountInSeconds
void printParamsForSelectedOutputMode()
Print the settings used for the selected output mode.
Public functions/variables of processing engine.
Manages telemetry data and frame formatting.
void sendTelemetryData()
Sends telemetry data using the TeleInfo class.
int freeRam()
Get the available RAM during setup.
PayloadTx_struct< TEMP_SENSOR_PRESENT ? temperatureSensing.get_size() :0 > tx_data
Provides utilities for managing temperature sensors.