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");
70 static uint8_t previousState{ HIGH };
71 if (previousState != pinState)
73 DBUGLN(!pinState ? F(
"Trigger override!") : F(
"End override!"));
76 previousState = pinState;
81 bOverrideLoad = !pinState;
113 static auto previousState{ HIGH };
114 if (previousState != pinState)
116 DBUGLN(!pinState ? F(
"Trigger diversion OFF!") : F(
"End diversion OFF!"));
119 previousState = pinState;
173 static bool pinOffPeakState{ HIGH };
176 if (pinOffPeakState && !pinNewState)
179 DBUGLN(F(
"Change to off-peak period!"));
190 const auto ulElapsedTime{
static_cast< uint32_t
>(millis() -
ul_TimeOffPeak) };
198 b_overrideLoadOn[
i] = !pinState || (currentTemperature_x100 <= iTemperatureThreshold_x100);
207 if (!pinOffPeakState && pinNewState)
209 DBUGLN(F(
"Change to peak period!"));
212 pinOffPeakState = pinNewState;
214 return (LOW == pinOffPeakState);
244 static uint8_t pinRotationState{ HIGH };
247 if (pinRotationState && !pinNewState)
249 DBUGLN(F(
"Trigger rotation!"));
253 pinRotationState = pinNewState;
271 bOverrideLoad = !pinState;
299 DEBUG_PORT.begin(9600);
315 DBUG(F(
">>free RAM = "));
378 if (8500 == tmp && (abs(tmp -
tx_data.temperature_x100[idx]) > 500))
383 tx_data.temperature_x100[idx] = tmp;
450 static uint8_t perSecondTimer{ 0 };
451 static bool bOffPeak{
false };
452 static int16_t iTemperature_x100{ 0 };
Calibration values definition.
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 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.
Public functions/variables of processing engine.
volatile bool b_reOrderLoads
volatile int32_t copyOf_sumP_atSupplyPoint[NO_OF_PHASES]
volatile int32_t copyOf_sum_Vsquared[NO_OF_PHASES]
volatile uint16_t copyOf_sampleSetsDuringThisDatalogPeriod
volatile bool b_overrideLoadOn[NO_OF_DUMPLOADS]
volatile bool b_newMainsCycle
volatile bool b_datalogEventPending
volatile bool b_diversionOff
constexpr uint16_t initialDelay
PayloadTx_struct< NO_OF_PHASES > tx_data
volatile uint16_t absenceOfDivertedEnergyCount
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.