How aaronalam1987/esp32-aquarium-controller works
Project type and purpose
• This is an embedded IoT project (ESP32-based aquarium controller) with two firmware images:
• Master device (controls sensors, relays, web server, settings)
• Slave device (wirelessly drives relays via ESP-NOW)
• Purpose: automatically monitor/control temperature, lighting, pump/valve relays; provide local (LCD+buttons) and remote (web GUI) control.
File structure
• Top-level PlatformIO project:
• / & lib/ – shared headers and libraries
• src/ – master firmware modules (main.cpp, equipmentControl, tempMonitor, wifiFunctions, etc.)
• test/ – unit/integration test placeholders
• slave_device/ subfolder: separate PlatformIO project with its own include, lib, src (main.cpp) and test
• Config: platformio.ini defines targets, board, frameworks
• Key patterns: modular services (xxxControl.cpp), hardware abstraction (espnow, wifiFunctions, timeFunctions), menu/settings layers.
Extract README insights
• Hardware: 20×4 LCD, DS18B20 temp probe, 8-channel relay board, RTC
• Features: heating/cooling control, water-change/feed mode, time-based lighting, web server for monitoring/control, EEPROM persistence, optional wireless slave
a. Main components
1. Master Firmware (ESP32)
• Initialization & config (main.cpp, settings)
• Sensor monitoring (tempMonitor, inputMonitor)
• Control logic (tempControl, lightControl, equipmentControl)
• User interface (menuControl, optionMenus + LCD + buttons)
• Comm interfaces
– Wi-Fi + Async WebServer (wifiFunctions)
– ESP-NOW broadcast (espnow)
• Persistence layer (EEPROM via settings module)
• Time source (RTC via timeFunctions)
2. Slave Firmware (ESP32)
• ESP-NOW listener (lib/espnow)
• Relay driver (slave/src)
3. Hardware peripherals
• DS18B20 temperature probe (OneWire bus)
• 8-channel relay boards (GPIO outputs)
• 20×4 LCD + buttons (I2C or GPIO)
• RTC (I2C)
• Power supply
4. External systems
• Web client (browser/mobile)
• Network (Wi-Fi router)
b. Relationships & data flows
• Sensors → Master sensor modules → Control logic → Relays (local or via ESP-NOW → Slave → relays)
• Buttons → menuControl → settings/control modules → EEPROM
• RTC → timeFunctions → lighting schedules
• Master WebServer ↔ Web client: command & telemetry over HTTP/WS
• Master → ESP-NOW → Slave: relay commands
c. Architectural patterns & principles
• Layered design: hardware abstraction layer (HAL), service modules, UI layer, persistence layer
• Separation of concerns: each “xxxControl” handles one domain
• Event-driven (button presses, timer interrupts, web requests, ESP-NOW packets)
• Modular code reuse (shared include/lib for both master & slave)
d. Key technologies & frameworks
• PlatformIO build system
• ESP-IDF or Arduino-ESP32 core (defined in platformio.ini)
• AsyncWebServer for HTTP UI
• ESP-NOW for peer-to-peer wireless control
• EEPROM for flash-based settings
• OneWire & DS18B20 libraries
• LiquidCrystal or equivalent LCD library