Support both Nano bootloaders for flashing over WiFi

- Uploader sends 'FLASH <baud>' first; the ESP32 restarts the Nano and
  bridges at that baud rate, then answers OK
- --baud=auto (default) tries 57600 (old ATmegaBOOT) then 115200 (Optiboot)
- Optional nano_reset GPIO (NPN to Nano RESET) pulses reset after power
  on, needed for Optiboot which skips the bootloader after a power cycle
- Clear errors for outdated ESP32 firmware and missing wires
- README: bootloader table, reset wire, troubleshooting

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
mangavalkandClaude Opus 5.5 committed 2026-10-13 00:44:35 +02:00
1 parent bea5b9daa1
commit cefb76c1ad
8 files changed
+220 -77

No files matched your search

+6 -1
View File
@@ -50,6 +50,9 @@ const int relay = 13; // Pin of the relay, powers the panels and the Nano (LOW =
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
// Optional: GPIO that resets the Nano through an NPN transistor (HIGH = reset), -1 = not wired.
// Needed to flash a Nano with the Optiboot bootloader, which doesn't start after a power cycle.
const int nano_reset = -1;
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;
@@ -57,8 +60,10 @@ const uint32_t NANO_BAUD = 115200;
// Flashing the Nano over WiFi (see README.md, pio run -e nano_ota -t upload)
const uint16_t NANO_FLASH_PORT = 2323;
const uint32_t NANO_BOOTLOADER_BAUD = 57600; // old Nano bootloader
// The bootloader baud rate is chosen by the uploader (57600 old bootloader, 115200 Optiboot)
const uint32_t NANO_POWER_OFF_TIME = 1000; // relay off time to make sure the Nano resets
const uint32_t NANO_RESET_DELAY = 200; // after power on, before the reset pulse
const uint32_t NANO_RESET_PULSE = 50;
int hour = 0;
int minute = 0;