16#include <ArduinoJson.h>
34#if TEMP_SENSOR_PRESENT
58#define PROJECT_PATH (__FILE__)
62#define BRANCH_NAME ("N/A")
65#define COMMIT_HASH ("N/A")
70 DBUGLN(F(
"----------------------------------"));
71 DBUG(F(
"Sketch ID: "));
74 DBUG(F(
"From branch '"));
76 DBUG(F(
"', commit "));
87 DBUGLN(F(
"ADC mode: free-running"));
89 DBUGLN(F(
"Electrical settings"));
91 DBUG(F(
"\tf_powerCal for Grid"));
94 DBUG(F(
"\tf_powerCal for Diversion"));
98 DBUG(
"\tAnti-creep limit (Joules / mains cycle) = ");
100 DBUG(
"\tExport rate (Watts) = ");
105 DBUG(F(
"Datalogging capability "));
108 DBUGLN(F(
"in Human-readable format"));
112 DBUGLN(F(
"in IoT format"));
116 DBUGLN(F(
"in JSON format"));
120 DBUGLN(F(
"is NOT present"));
140 Serial.print(F(
", P:"));
141 Serial.print(
tx_data.powerGrid);
145 Serial.print(F(
"/"));
146 Serial.print(
relays.get_average());
149 Serial.print(F(
", D:"));
150 Serial.print(
tx_data.powerDiverted);
152 Serial.print(F(
", E:"));
155 Serial.print(F(
", V"));
156 Serial.print(F(
":"));
157 Serial.print((
float)
tx_data.Vrms_L_x100 * 0.01f);
169 Serial.print(F(
", T"));
170 Serial.print(idx + 1);
171 Serial.print(F(
":"));
172 Serial.print((
float)
tx_data.temperature_x100[idx] * 0.01f);
176 Serial.print(F(
", (minSampleSets/MC "));
178 Serial.print(F(
", #ofSampleSets "));
184 Serial.print(F(
", NoED "));
189 Serial.println(F(
")"));
210 ArduinoJson::StaticJsonDocument< 256 > doc;
216 doc[
"R"] =
relays.get_average();
219 doc[
"D"] =
tx_data.powerDiverted;
221 doc[
"V"] = (float)
tx_data.Vrms_L_x100 * 0.01f;
232 doc[String(
"T") + (idx + 1)] = (
float)
tx_data.temperature_x100[idx] * 0.01f;
238 serializeJson(doc, Serial);
269 teleInfo.startFrame();
275 teleInfo.
send(
"R",
static_cast< int16_t
>(
relays.get_average()));
280 teleInfo.
send(
"R",
relays.get_relay(idx).isRelayON());
281 }
while (++idx <
relays.get_size());
298 teleInfo.
send(
"T",
tx_data.temperature_x100[idx], idx + 1);
329 static bool startup{
true };
368 extern int __heap_start, *__brkval;
370 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.
Provides utilities for managing temperature sensors.