Add idea 015: Bus Stop ETA Beacon
Browse files
ideas/015-bus-stop-eta-beacon.md
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 015 · Bus Stop ETA Beacon
|
| 2 |
+
|
| 3 |
+
**title:** Bus Stop ETA Beacon — an offline, solar "next bus in…" sign that uses real GPS, not a schedule
|
| 4 |
+
**status:** idea / MVP ready
|
| 5 |
+
**license:** MIT
|
| 6 |
+
|
| 7 |
+
## why
|
| 8 |
+
|
| 9 |
+
GTFS schedules lie when buses run late, reroute, or get stuck. Meanwhile riders wait in the rain refreshing an app that needs signal. A solar + LoRa beacon at the stop can show real, crowd-sourced ETAs: volunteer "rider pings" from onboard phones (BT/BLE) + a tiny GPS tracker on a route vehicle relay the actual position to each stop's e-ink sign. No cellular network, no app install, no data plan — just a #digital-clock that tells the truth for once.
|
| 10 |
+
|
| 11 |
+
## what
|
| 12 |
+
|
| 13 |
+
- **Stop sign**: e-ink display (1–7") + ESP32 + LoRa (or Wi-Fi where available), solar panel + LiFePO4 battery.
|
| 14 |
+
- **Vehicle puck**: $25 GPS (NEO-6M/gNSS) + ESP32 riding a school/community shuttle; broadcasts position every 15s over LoRa.
|
| 15 |
+
- **Routing on the sign**: each sign only displays the bus(es) on its own route — distance/speed → ETA.
|
| 16 |
+
- **Fail-degraded**: if no ping for 5 min, sign flips to schedule-based ETA (GTFS) and shows a ⚠️ "live signal lost".
|
| 17 |
+
- **Hop-by-hop**: LoRa range 1–3 km, can chain across a route; no towers, no fees.
|
| 18 |
+
|
| 19 |
+
## plan
|
| 20 |
+
|
| 21 |
+
1. Build a one-vehicle proof: GPS puck + one e-ink sign at the terminal stop.
|
| 22 |
+
2. LoRa frame: route_id, vehicle_id, lat, lon, speed, heading, ts — tiny binary, signed with a CRC.
|
| 23 |
+
3. Sign firmware: parse frames, compute distance along route vs. last-known, display "12 min".
|
| 24 |
+
4. Add schedule fallback + stale-signal warning state.
|
| 25 |
+
5. Multi-vehicle + multi-stop: mesh relay so stops beyond direct range still hear the bus.
|
| 26 |
+
6. Enclosure + solar sizing; pilot on a school route or community shuttle for a term.
|
| 27 |
+
|
| 28 |
+
## code
|
| 29 |
+
|
| 30 |
+
LoRa packet + sign-side ETA logic (~60 lines):
|
| 31 |
+
|
| 32 |
+
```python
|
| 33 |
+
# beacon.py — ESP32 LoRa vehicle puck (MicroPython, SX1276)
|
| 34 |
+
import time, ubinascii, struct
|
| 35 |
+
from machine import Pin, UART
|
| 36 |
+
# LoRa via SPI (RA-02/SX1276) — see your board's wiring; use a lib like sx127x
|
| 37 |
+
|
| 38 |
+
def gps_fix(): # returns (lat, lon, speed_kph) — from ATGM336H/NEO-6M over UART
|
| 39 |
+
u = UART(1, 9600)
|
| 40 |
+
for _ in range(40):
|
| 41 |
+
line = u.readline()
|
| 42 |
+
if line and line.startswith(b"$GPRMC"):
|
| 43 |
+
parts = line.decode(errors="ignore").split(",")
|
| 44 |
+
if parts[2] == "A": # valid fix
|
| 45 |
+
lat = float(parts[3][:2]) + float(parts[3][2:]) / 60.0
|
| 46 |
+
lon = float(parts[5][:3]) + float(parts[5][3:]) / 60.0
|
| 47 |
+
if parts[4] == "S": lat = -lat
|
| 48 |
+
if parts[6] == "W": lon = -lon
|
| 49 |
+
return lat, lon, float(parts[7]) if parts[7] else 0.0
|
| 50 |
+
return None
|
| 51 |
+
|
| 52 |
+
def packet(route, veh, lat, lon, spd):
|
| 53 |
+
# binary: route(1B) veh(1B) lat(4B, 1e6) lon(4B) spd(2B, 0.1kph) crc(2B)
|
| 54 |
+
payload = struct.pack("<BBiiH", route, veh, int(lat*1e6), int(lon*1e6), int(spd*10))
|
| 55 |
+
crc = ubinascii.crc32(payload) & 0xFFFF
|
| 56 |
+
return payload + struct.pack("<H", crc)
|
| 57 |
+
|
| 58 |
+
while True:
|
| 59 |
+
fix = gps_fix()
|
| 60 |
+
if fix:
|
| 61 |
+
lora_send(packet(ROUTE_ID, VEH_ID, *fix)) # your lora_send() from sx127x lib
|
| 62 |
+
time.sleep(15)
|
| 63 |
+
```
|
| 64 |
+
|
| 65 |
+
```python
|
| 66 |
+
# eta.py — …and on the sign: distance-but-no-schedule math
|
| 67 |
+
def eta_minutes(route_m, bus_lat, bus_lon, stop_lat, stop_lon, speed_kph):
|
| 68 |
+
from math import radians, cos, sin, asin, sqrt
|
| 69 |
+
R = 6371.0
|
| 70 |
+
dlat = radians(stop_lat - bus_lat); dlon = radians(stop_lon - bus_lon)
|
| 71 |
+
a = sin(dlat/2)**2 + cos(radians(bus_lat))*cos(radians(stop_lat))*sin(dlon/2)**2
|
| 72 |
+
km = 2 * R * asin(sqrt(a))
|
| 73 |
+
if speed_kph < 2: return "~unknown (idle)"
|
| 74 |
+
return max(1, int(km / speed_kph * 60))
|
| 75 |
+
```
|
| 76 |
+
|
| 77 |
+
## next
|
| 78 |
+
|
| 79 |
+
- Route-arc projection: use stop order + last two fixes to estimate ETA along the actual path.
|
| 80 |
+
- Store-and-forward repeaters for stops out of direct range.
|
| 81 |
+
- Sign sleep schedule: wake 2s before expected bus window, else deep-sleep (e-ink = zero idle power).
|
| 82 |
+
- Pedestrian/cyclist "live" mode (no GPS needed — bits of route from the puck).
|
| 83 |
+
- Accessibility: audible ETA button + high-contrast large digits (see #013 for reading ease).
|
| 84 |
+
- Fleet dashboard on the hub for maintenance, and open LoRa frame spec for other tools.
|