2026-10-12 23:55:15 +02:00
|
|
|
#include <Arduino.h>
|
|
|
|
|
#include "BROSE9323.h"
|
|
|
|
|
#include "bitmaps.h"
|
|
|
|
|
|
|
|
|
|
// WiFi / MQTT credentials (gitignored, copy secrets.example.h -> secrets.h)
|
|
|
|
|
#if __has_include("secrets.h")
|
|
|
|
|
#include "secrets.h"
|
|
|
|
|
#else
|
|
|
|
|
#error "Missing src/esp32/secrets.h - copy src/esp32/secrets.example.h to secrets.h and fill it in"
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
// fixes
|
|
|
|
|
#include <SPI.h>
|
|
|
|
|
#include <Adafruit_I2CDevice.h>
|
|
|
|
|
// fonts
|
|
|
|
|
#include <Fonts/FreeSerif12pt7b.h>
|
|
|
|
|
#include <Fonts/FreeSerifItalic12pt7b.h>
|
|
|
|
|
// #include <Font2x5FixedMonoNum.h>
|
|
|
|
|
|
|
|
|
|
#include <WiFi.h>
|
|
|
|
|
#include <ESPmDNS.h>
|
|
|
|
|
#include <WiFiUdp.h>
|
|
|
|
|
#include <ArduinoOTA.h>
|
|
|
|
|
#include <WiFiMulti.h>
|
|
|
|
|
|
|
|
|
|
// wdt?
|
|
|
|
|
#include <esp_task_wdt.h>
|
|
|
|
|
#include <rom/rtc.h>
|
|
|
|
|
|
|
|
|
|
// hassio
|
|
|
|
|
#include <ArduinoHA.h>
|
|
|
|
|
|
|
|
|
|
byte mac[] = {0x34, 0x86, 0x5d, 0x3a, 0x08, 0x28};
|
|
|
|
|
|
|
|
|
|
// EthernetClient client;
|
|
|
|
|
WiFiClient client;
|
|
|
|
|
HADevice device(mac, sizeof(mac));
|
|
|
|
|
HAMqtt mqtt(client, device);
|
|
|
|
|
|
|
|
|
|
HASwitch flipDotDisplay("FlipDotDisplayClock");
|
|
|
|
|
bool hassioDisplayStatus = true;
|
|
|
|
|
|
|
|
|
|
HASwitch powerSwitch("FlipDotDisplayPower");
|
|
|
|
|
bool power = true;
|
|
|
|
|
|
|
|
|
|
const int led1 = BUILTIN_LED; // Pin of the LED
|
2026-10-13 00:12:28 +02:00
|
|
|
const int relay = 13; // Pin of the relay, powers the panels and the Nano (LOW = on)
|
2026-10-13 00:16:24 +02:00
|
|
|
// Link to the Nano on UART2. Serial (UART0) stays free for USB / debug output.
|
|
|
|
|
HardwareSerial &nanoSerial = Serial2;
|
|
|
|
|
const int nano_rx = 16; // UART2 RX, wired to the Nano TX (through a 5V -> 3.3V divider)
|
|
|
|
|
const int nano_tx = 17; // UART2 TX, wired to the Nano RX
|
2026-10-13 00:12:28 +02:00
|
|
|
bool relay_on = false;
|
|
|
|
|
// Max wait for the Nano's READY after power on (also the wait when Nano TX is not wired to our RX)
|
|
|
|
|
const uint32_t NANO_BOOT_TIMEOUT = 3000;
|
2026-10-12 23:55:15 +02:00
|
|
|
|
|
|
|
|
int hour = 0;
|
|
|
|
|
int minute = 0;
|
|
|
|
|
int second = 0;
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
WiFiMulti wifiMulti;
|
|
|
|
|
|
|
|
|
|
const char *ssid = WIFI_SSID;
|
|
|
|
|
const char *password = WIFI_PASSWORD;
|
|
|
|
|
|
|
|
|
|
BROSE9323 display(84, 19, 28);
|
|
|
|
|
|
|
|
|
|
uint32_t next_display;
|
|
|
|
|
|
|
|
|
|
// ntp
|
|
|
|
|
#define MYTZ "CET-1CEST,M3.5.0,M10.5.0/3"
|
|
|
|
|
const char *ntpServer = "pool.ntp.org";
|
|
|
|
|
const long gmtOffset_sec = 3600;
|
|
|
|
|
const int daylightOffset_sec = 3600;
|
|
|
|
|
// const int daylightOffset_sec = 0;
|
|
|
|
|
|
|
|
|
|
bool wifiStatus = false;
|
|
|
|
|
bool otaPanicMode = true;
|