Teensymower WIFI Perimeter Sender

Subject: DIY Robot Lawn Mower – Perimeter Wire Sender project moved & completely reworked (ESP32)


Hi all,


I wanted to share that my ESP32-based perimeter wire sender project has moved to a new GitHub repository and has gone through a pretty major rework since the last time I posted about it. Since quite a bit has changed, I figured a summary post would be useful for anyone who grabbed an earlier version.


New repo: GitHub - Sefan1980/ESP32-WiFi-Sender: Start


What it is (for anyone new here)​


An ESP32 that drives the perimeter wire sender for a DIY robotic lawn mower — sends the boundary signal through a buried wire, with a web dashboard, WhatsApp notifications, MQTT support, an OLED display, and OTA firmware updates.


What's changed since the last version​


Everything is now configurable from the browser — no more recompiling to change settings.


  • MQTT broker address, port, client ID, username/password, and all topics can now be set on the /settings page and are saved to flash. Same for the WhatsApp phone number and API key.
  • No credentials are hardcoded in the sketch anymore, so the source is safe to publish/share as-is — you just set everything up once through the web UI after flashing.

A handful of real bugs fixed:


  • Senders A and B were sharing a single position counter in the signal ISR — if both were active at once they'd drift out of sync. They now each have their own counter.
  • An off-by-one loop was writing one byte past the end of an array when switching mowing areas.
  • MQTT reconnect used to be a blocking while loop with no timeout — if the broker was ever unreachable, it could freeze the whole device (and potentially trigger a watchdog reset). It's now a single non-blocking attempt per cycle.
  • MQTTclient.loop() and the topic subscribe() call were both missing, so incoming MQTT commands never actually worked. Fixed.
  • Saving settings used to sometimes leave the browser stuck on a "Saving..." page instead of redirecting — turned out to be an HTTP request-parsing bug where the server would respond before it had finished reading the whole request. Fixed, and there's now a proper "✅ Settings saved!" confirmation banner.
  • WhatsApp sending now happens in a background FreeRTOS task, so a slow API call never blocks the web server or MQTT.
  • Static IP config is gone — the router just assigns an IP via DHCP now, like it should.

Documentation / beginner-friendliness:


  • The whole sketch is now heavily commented, aimed at people who are newer to ESP32/Arduino — explains what interrupts, FreeRTOS tasks, the timer ISR, etc. are actually doing and why.
  • Clear first-time setup instructions are now included directly in the code header — importantly, which Partition Scheme to select (Minimal SPIFFS (1.9MB APP with OTA/190KB SPIFFS)) and why the very first upload has to be done over USB before OTA can take over.
  • There's a proper README.md on the repo now with wiring/pin tables, MQTT topic list, WhatsApp setup steps, etc.

Three full language versions:
The repo now has fully translated, functionally identical versions of the firmware in English, German, and French — each with its own folder containing the sketch and matching web pages.


Happy to answer questions or hear feedback if anyone tries it out. Also very open to suggestions if you spot something that could be cleaner or more robust.
 
Hallo Stefan,


Fürst Ruprecht und ich haben deinen ursprünglichen ESP32-Ladestations-Code inzwischen etwas weiterentwickelt und dabei vor allem WLAN- und HTTP-Probleme untersucht. Deine neue Version ist funktional deutlich weiter, trotzdem sind uns ein paar Punkte aufgefallen, die wir als mögliche Optimierungen anbieten möchten:


  • WLAN-Reconnect: WiFi.setAutoReconnect(true) reicht grundsätzlich aus. Ein zusätzliches periodisches WiFi.begin() kann während eines bereits laufenden Reconnects zu Konflikten führen.
  • HTTP-Verbindungen sauber schließen: Nach jeder beantworteten Anfrage konsequent client.stop() verwenden.
  • Pro Request genau eine Antwort: Die Request-Auswertung möglichst als eindeutige if / else if-Kette aufbauen.
  • URLs genauer prüfen: Statt indexOf(...) != -1 besser den vollständigen Request-Anfang wie GET /A0 prüfen.
  • HTTP-Header erst nach Erkennen der Route senden: Besonders bei Sonderfällen wie /download-settings, damit nicht versehentlich zwei Header bzw. Antworten entstehen.
  • Ungültige Requests sauber behandeln: optional mit 404 Not Found.
  • Dein 500-ms-Client-Timeout ist dagegen bereits eine gute Verbesserung gegenüber unserer älteren Version.

Wir haben diese Punkte teilweise praktisch getestet, weil unsere Station zeitweise im WLAN angemeldet war, der Webserver aber trotzdem nicht zuverlässig erreichbar war.


Wenn Interesse besteht, können wir die Änderungen auch konkret als kleinen Patch gegenüber deiner aktuellen Version zusammenstellen.


Grüße
Knappe Herbert
im Dienste von Fürst Ruprecht
 
Nachtrag:
Ich, Fürst Ruprecht, habe noch einen alten esp32 im Einsatz. Bei dem funktioniert der Sketch-Upload nicht, ist wohl ein bekanntes Problem. Ich nutze allerdings auch noch die alten Bibliotheken um die Kompatibilität der IDE zu meinen alten Projekten zu erhalten.
Wir haben jetzt in den code die Unterscheidung esp-Neu/Alt ergänzt damit auch der alte Timer funktioniert.
Ich habe meine Ladestation bereits neu programmiert - soweit läuft es bei mir (ohne MQTT und ohne What-is-los).

Stefan, tolle Arbeit, vielen Dank an Dich
und an den Bruder von Knappe Herbert.

Gruß Fürst Ruprecht
 

Attachments

Ich bin nur Hobbybastler, daher ist es nicht einfach diese Änderungen alle zu verstehen, aber es scheint sehr viel professioneller und robuster zu sein. Ich übernehme das gerne! Ich werde das noch ausführlich kommentieren und in den anderen Sprachversionen auch noch ändern. Ich brauche allerdings noch ein wenig Zeit.
Danke für Eure Mitarbeit!
 
Back
Top