Traducido del English por IA ·
Tres cosas en ese payload; yo tropecé con dos de ellas con rastreadores de carretillas elevadoras.La columna Longitude de la tarjeta de mapa tiene por defecto lng, y Latitude tiene lat. Tú envías lon, así que cada fila no tiene longitud y se omite. O bien renombras la clave en el dispositivo, o bien pones la columna Longitude en lon en la tarjeta. Yo renombraría en el dispositivo para que cada placa futura funcione sin más.Envías los números como cadenas porque construiste el JSON con String(). El texto con forma de número a menudo funciona en comparaciones, pero envía números reales de todos modos. Y String(float) da dos decimales por defecto, lo que equivale a más o menos un kilómetro. Todos tus remolques quedarían en el mismo punto.Y no publiques cuando el fix no sea válido, o verás remolques aparcados en 0,0 frente a África cada vez que una placa arranque en un cobertizo.
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 con %f funciona en el core de ESP8266, a diferencia del Uno. La configuración de las tarjetas está en 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.

