3-phase PV router
Loading...
Searching...
No Matches
utils.h File Reference

Some utility functions. More...

#include <Arduino.h>
#include <ArduinoJson.h>
#include "FastDivision.h"
#include "calibration.h"
#include "constants.h"
#include "dualtariff.h"
#include "processing.h"
#include "shared_var.h"
#include "teleinfo.h"
#include "utils_rf.h"
#include "utils_temp.h"
#include "version.h"
Include dependency graph for utils.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int freeRam ()
 Get the available RAM during setup.
 
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.
 
void sendResults (bool bOffPeak)
 Prints or sends telemetry data logs based on the selected output format.
 
void sendTelemetryData (const bool bOffPeak)
 Sends telemetry data using the TeleInfo class.
 

Detailed Description

Some utility functions.

Author
Frédéric Metrich (frede.nosp@m.ric..nosp@m.metri.nosp@m.ch@l.nosp@m.ive.f.nosp@m.r)
Version
0.1
Date
2023-02-09

Definition in file utils.h.

Function Documentation

◆ freeRam()

int freeRam ( )
inline

Get the available RAM during setup.

This function calculates the amount of free RAM available in the system. It is useful for debugging and ensuring that the system has sufficient memory for proper operation.

Returns
int The amount of free RAM in bytes.

Definition at line 516 of file utils.h.

Here is the caller graph for this function:

◆ sendTelemetryData()

void sendTelemetryData ( const bool bOffPeak)

Sends telemetry data using the TeleInfo class.

This function collects various telemetry data (e.g., power, voltage, temperature, etc.) and sends it in a structured format using the TeleInfo class. The data is sent as a telemetry frame, which starts with a frame initialization, includes multiple data points, and ends with a frame finalization.

The function supports conditional features such as relay diversion, temperature sensing, dual tariff information, and different supply frequencies (50 Hz or 60 Hz).

Parameters
bOffPeakIndicates whether the system is in an off-peak tariff period.
  • Power Data: Sends the total power grid data.
  • Relay Data: If relay diversion is enabled (RELAY_DIVERSION), sends the average relay data.
  • Voltage Data: Sends the voltage data for each phase.
  • Temperature Data: If temperature sensing is enabled (TEMP_SENSOR_PRESENT), sends valid temperature readings.
  • Dual Tariff Data: If dual tariff is enabled (DUAL_TARIFF), sends the current tariff state.
  • Absence of Diverted Energy Count: The amount of seconds without diverting energy.
Note
The function uses compile-time constants (constexpr) to include or exclude specific features. Invalid temperature readings (e.g., OUTOFRANGE_TEMPERATURE or DEVICE_DISCONNECTED_RAW) are skipped.
Exceptions
static_assertIf SUPPLY_FREQUENCY is not 50 or 60 Hz.

Definition at line 368 of file utils.h.

Here is the call graph for this function:
Here is the caller graph for this function: