|
Aquarium Cooling Controller
ESP32 firmware for aquarium cooling fan control, monitoring, telemetry, and fault handling.
|
Arduino sketch entry point for the aquarium cooling controller. More...
#include <Arduino.h>#include <esp_arduino_version.h>#include <esp_ota_ops.h>#include <Preferences.h>#include "control_engine.h"#include "display_format.h"#include "fan_driver.h"#include "fan_curve.h"#include "fault_monitor.h"#include "fault_policy.h"#include "mqtt_telemetry.h"#include "ota_upload_server.h"#include "rpm_monitor.h"#include "sensor_manager.h"
Functions | |
| void | setup () |
| Sets up hardware, persisted settings, diagnostics, and telemetry. | |
| void | loop () |
| Runs one non-blocking controller iteration. | |
Arduino sketch entry point for the aquarium cooling controller.
The sketch wires the firmware modules together and owns the runtime loop. It sets up persistent temperature-control storage, water-temperature sensing, fan PWM output, tachometer RPM monitoring, fault evaluation, serial diagnostics, and optional MQTT telemetry.
Runtime behavior is locally autonomous by design: cooling control, fan safety monitoring, and diagnostics continue on the ESP32 even when Wi-Fi, MQTT, or external integrations are unavailable.
The serial monitor exposes service commands for status output, target-temperature changes, default reset, control defaults, fault-policy settings, network status, and forced telemetry publishing.
Keep this sketch focused on orchestration. Hardware abstractions and policy decisions live in dedicated modules so Doxygen pages remain navigable and the Arduino loop stays easy to audit.
| void loop | ( | ) |
Runs one non-blocking controller iteration.
Arduino calls this repeatedly. Each iteration services serial commands, advances sensor sampling, recomputes the control snapshot, updates the fan output and RPM monitor, and maintains MQTT connectivity. Diagnostics and telemetry are emitted at kDiagnosticsIntervalMs so the controller loop remains responsive between reporting cycles.
| void setup | ( | ) |
Sets up hardware, persisted settings, diagnostics, and telemetry.
Arduino calls this once after boot. The setup routine brings up serial output, non-volatile preferences, fan PWM, RPM capture, the OneWire sensor bus, and MQTT telemetry. It also prints the hardware configuration and measured fan curve so an installed controller can be inspected from the serial monitor.