Von English mit KI übersetzt ·
Drei Dinge in dieser Payload. Bei zweien bin ich bei Gabelstapler-Trackern selbst hängengeblieben.Die Spalte Longitude der Kartenansicht ist standardmäßig auf lng eingestellt, Latitude auf lat. Du sendest lon, also hat jede Zeile keine Länge und wird übersprungen. Entweder benennst du den Schlüssel auf dem Gerät um oder setzt die Spalte Longitude in der Karte auf lon. Ich würde auf dem Gerät umbenennen, damit jedes künftige Board einfach funktioniert.Du sendest die Zahlen als Strings, weil du das JSON mit String() aufbaust. Zahlenähnlicher Text funktioniert in Vergleichen oft, trotzdem solltest du echte Zahlen senden. Und String(float) liefert standardmäßig zwei Nachkommastellen, das sind etwa einen Kilometer. Alle deine Anhänger stünden dann am selben Ort.Und veröffentliche nicht, wenn der Fix ungültig ist, sonst stehen Anhänger jedes Mal, wenn eines der Boards im Schuppen startet, vor der Küste Afrikas bei 0,0.
if (gps.location.isValid() && gps.location.age() < 3000) {
char buf[96];
snprintf(buf, sizeof(buf), "{"lat":%.6f,"lng":%.6f,"spd_kmh":%.1f}",
gps.location.lat(), gps.location.lng(), gps.speed.kmph());
client.publish("v1/telemetry", buf);
}
snprintf mit %f funktioniert im ESP8266-Core, anders als auf einem Uno. Die Karteneinstellungen findest du unter Map cards.
Three things in that payload, I tripped on two of them with forklift trackers.
The map card’s Longitude column defaults to lng, Latitude to lat. You send lon, so every row has no longitude and gets skipped. Either rename the key on the device or set Longitude column to lon in the card. I’d rename on the device so every future board just works.
You’re sending the numbers as strings because you built the JSON with String(). Number-like text often works in comparisons, but send real numbers anyway. And String(float) gives two decimals by default, which is about a kilometre. Your trailers would all sit in the same spot.
And don’t publish when the fix isn’t valid or you’ll get trailers parked at 0,0 off Africa every time one boots in a shed.
if (gps.location.isValid() && gps.location.age() < 3000) {
char buf[96];
snprintf(buf, sizeof(buf), "{"lat":%.6f,"lng":%.6f,"spd_kmh":%.1f}",
gps.location.lat(), gps.location.lng(), gps.speed.kmph());
client.publish("v1/telemetry", buf);
}
snprintf with %f works on the ESP8266 core, unlike on an Uno. Card settings are on Map cards.

