Speed and heading for yard tractors: compute on the tracker or after the data lands?
We run 14 yard tractors moving trailers around the plant. Each has a box I had built: Arduino Mega, SIM800L, u-blox NEO-6M. It sends lat and lng every 30 seconds over GPRS to Hermetry and the map card looks great.
Now logistics wants speed (we have a 15 km/h yard limit) and direction of travel. My contractor says “do it in the cloud from consecutive points”. The other contractor says “do it on the box”. I have to pay one of them. Which is right?
From two points it’s just distance over time? Haversine formula, 30 s apart. Seems easy to do anywhere.
Does sending more values cost more data? Our SIM plan for the parking sensors is tiny.
Neither contractor, sort of. The NEO-6M already gives you both. The $GPRMC sentence has speed over ground (in knots) and course over ground, and the receiver gets speed from Doppler, which is far better than differencing two fixes 30 s apart. Two fixes 30 s apart will show a tractor that went down and back an aisle as standing still.
With TinyGPS++ it’s two lines:
float kmh = gps.speed.kmph(); // already converted from knots
float hdg = gps.course.deg();
snprintf(buf, sizeof buf,
"{"lat":%.6f,"lng":%.6f,"speed_kmh":%.1f,"course_deg":%.0f}",
gps.location.lat(), gps.location.lng(), kmh, hdg);
Send them as numbers in the same message as lat/lng. Same message, same cost, so @roberts.r it’s a few bytes more, not another message. Then an alarm rule on speed_kmh > 15 with a debounce of 2 readings so one GPS jump doesn’t fire it.
If you ever do need something computed after the fact (distance per shift, say), that goes in the root flow before Save telemetry as a derived key.
Paid neither, my maintenance tech did it in an afternoon with your snippet. Course is jumpy below 2 km/h so we only show it when speed_kmh > 2. First week: 6 alarms, all the same driver. Logistics is happy.
TIL the GPS does Doppler. Way smarter than my haversine idea.
- You must be logged in to reply to this topic.
Join the conversation
Sign in to ask and answer, like helpful posts and mark the reply that solved your problem. Every contribution earns points and levels.

