24static_assert(__cplusplus >= 201703L,
"**** Please define 'gnu++17' in 'platform.txt' ! ****");
25static_assert(__cplusplus >= 201703L,
"See also : https://github.com/FredM67/PVRouter-3-phase/blob/main/Mk2_3phase_RFdatalog_temp/Readme.md");
71 static uint8_t previousState{ HIGH };
72 if (previousState != pinState)
74 DBUGLN(!pinState ? F(
"Trigger override!") : F(
"End override!"));
77 previousState = pinState;
82 bOverrideLoad = !pinState;
114 static auto previousState{ HIGH };
115 if (previousState != pinState)
117 DBUGLN(!pinState ? F(
"Trigger diversion OFF!") : F(
"End diversion OFF!"));
120 previousState = pinState;
174 static bool pinOffPeakState{ HIGH };
177 if (pinOffPeakState && !pinNewState)
180 DBUGLN(F(
"Change to off-peak period!"));
191 const auto ulElapsedTime{
static_cast< uint32_t
>(millis() -
ul_TimeOffPeak) };
208 if (!pinOffPeakState && pinNewState)
210 DBUGLN(F(
"Change to peak period!"));
213 pinOffPeakState = pinNewState;
215 return (LOW == pinOffPeakState);
245 static uint8_t pinRotationState{ HIGH };
248 if (pinRotationState && !pinNewState)
250 DBUGLN(F(
"Trigger rotation!"));
254 pinRotationState = pinNewState;
272 bOverrideLoad = !pinState;
300 DEBUG_PORT.begin(9600);
316 DBUG(F(
">>free RAM = "));
379 if (8500 == tmp && (abs(tmp -
tx_data.temperature_x100[idx]) > 500))
384 tx_data.temperature_x100[idx] = tmp;
451 static uint8_t perSecondTimer{ 0 };
452 static bool bOffPeak{
false };
453 static int16_t iTemperature_x100{ 0 };
Calibration values definition.
constexpr float f_voltageCal[NO_OF_PHASES]
constexpr float f_powerCal[NO_OF_PHASES]
Configuration values to be set by the end-user.
constexpr bool RELAY_DIVERSION
constexpr bool OVERRIDE_PIN_PRESENT
constexpr uint32_t ROTATION_AFTER_SECONDS
constexpr uint8_t dualTariffPin
constexpr TemperatureSensing temperatureSensing
constexpr uint8_t forcePin
constexpr RelayEngine relays
constexpr bool DUAL_TARIFF
constexpr uint8_t diversionPin
constexpr SerialOutputType SERIAL_OUTPUT_TYPE
constexpr bool EMONESP_CONTROL
constexpr uint8_t NO_OF_DUMPLOADS
constexpr bool TEMP_SENSOR_PRESENT
constexpr int16_t iTemperatureThreshold
constexpr bool WATCHDOG_PIN_PRESENT
constexpr bool DIVERSION_PIN_PRESENT
constexpr uint8_t rotationPin
constexpr uint8_t watchDogPin
constexpr uint8_t DATALOG_PERIOD_IN_SECONDS
constexpr uint8_t NO_OF_PHASES
constexpr uint8_t SUPPLY_FREQUENCY
constexpr int16_t DEVICE_DISCONNECTED_RAW
constexpr auto rg_OffsetForce
void updatePowerAndVoltageData()
Updates power and voltage data for all phases.
void handlePerSecondTasks(bool &bOffPeak, int16_t &iTemperature_x100)
Handles tasks that need to be executed every second.
bool proceedLoadPrioritiesAndOverridingDualTariff(const int16_t ¤tTemperature_x100)
Handles load priorities and overriding during dual tariff periods.
void checkDiversionOnOff()
Checks and updates the diversion state based on the diversion pin.
bool forceFullPower()
Forces all loads to full power if the override pin is active.
void proceedRotation()
Proceeds with load priority rotation.
bool proceedLoadPrioritiesAndOverriding(const int16_t ¤tTemperature_x100)
Handles load priorities and overriding logic.
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 loop()
Main processor loop.
void setup()
Called once during startup.
void printConfiguration()
Print the configuration during startup.
void initializeProcessing()
Initializes the processing engine, including ports, load states, and ADC setup.
void processTemperatureData()
Processes temperature data from DS18B20 sensors.
Header file for the main application.
volatile int32_t copyOf_sum_Vsquared[NO_OF_PHASES]
volatile bool b_datalogEventPending
volatile bool b_overrideLoadOn[NO_OF_DUMPLOADS]
volatile bool b_reOrderLoads
volatile uint16_t copyOf_sampleSetsDuringThisDatalogPeriod
volatile int32_t copyOf_sumP_atSupplyPoint[NO_OF_PHASES]
volatile uint16_t absenceOfDivertedEnergyCountInSeconds
volatile bool b_newMainsCycle
volatile bool b_diversionEnabled
Public functions/variables of processing engine.
constexpr uint16_t initialDelay
PayloadTx_struct< NO_OF_PHASES > tx_data
Some basics classes/types.
int freeRam()
Get the available RAM during setup.
constexpr bool getPinState(uint8_t pin)
Get the Pin State.
constexpr void togglePin(uint8_t pin)
Toggle the specified pin.
Some utility functions for the relay output feature.
Compile-time validations.