3-phase PV router
Loading...
Searching...
No Matches
main.cpp File Reference

Main code for the PVRouter 3-phase project. More...

#include <Arduino.h>
#include "config.h"
#include "calibration.h"
#include "processing.h"
#include "types.h"
#include "utils.h"
#include "utils_relay.h"
#include "validation.h"
#include "main.h"
Include dependency graph for main.cpp:

Go to the source code of this file.

Functions

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 handlePerSecondTasks (bool &bOffPeak, int16_t &iTemperature_x100)
 Handles tasks that need to be executed every second.
 
void loop ()
 Main processor loop.
 
bool proceedLoadPrioritiesAndOverriding (const int16_t &currentTemperature_x100)
 Handles load priorities and overriding logic.
 
bool proceedLoadPrioritiesAndOverridingDualTariff (const int16_t &currentTemperature_x100)
 Handles load priorities and overriding during dual tariff periods.
 
void proceedRotation ()
 Proceeds with load priority rotation.
 
void processTemperatureData ()
 Processes temperature data from DS18B20 sensors.
 
void setup ()
 Called once during startup.
 
void updatePowerAndVoltageData ()
 Updates power and voltage data for all phases.
 

Detailed Description

Main code for the PVRouter 3-phase project.

Author
Frédéric Metrich (frede.nosp@m.ric..nosp@m.metri.nosp@m.ch@l.nosp@m.ive.f.nosp@m.r)

This file contains the main logic for the PVRouter, including the setup and loop functions, as well as interrupt service routines (ISRs) and utility functions for managing load priorities, temperature sensing, and telemetry data.

  • Interrupt-Driven Analog Conversion: Uses an ISR to process ADC data for voltage and current sensors.
  • Load Management: Includes functions for load priority rotation, forced full power, and dual tariff handling.
  • Telemetry: Sends telemetry data in various formats (e.g., IoT, EmonCMS).
  • Temperature Sensing: Supports DS18B20 sensors for temperature monitoring.
  • Watchdog: Toggles a pin to indicate system activity.
Version
0.1
Date
2023-02-15

Definition in file main.cpp.

Function Documentation

◆ processTemperatureData()

void processTemperatureData ( )

Processes temperature data from DS18B20 sensors.

This function reads temperature values from all connected DS18B20 sensors, filters out invalid readings, and updates the telemetry data structure with valid temperature values. Invalid readings are identified as 85.00°C (encoded as 8500) with a delta greater than 5.00°C (encoded as 500) from the previous reading. After processing, it requests new temperature measurements for the next cycle.

Note
This function assumes that temperature values are stored as integers multiplied by 100 for precision.
Precondition
The temperatureSensing object must be initialized and configured with the connected DS18B20 sensors.
Postcondition
The tx_data.temperature_x100 array is updated with the latest valid temperature readings.

Definition at line 370 of file main.cpp.

Here is the caller graph for this function: