A custom hardware integration for tracking Midttrafik buses in real-time. This project consists of a Deno-based backend that processes bus data and an ESP8266-based hardware client that displays departure times using RGB LEDs.
- Real-time Tracking: Fetches live departure times for specific stops.
- Smart Walking Time: Calculates exactly when you need to leave based on configured walking times to the stops.
- Hardware Display: Visual feedback using RGB LEDs on an ESP8266.
- Departure Alarm: Notify when it's time to leave.
/arduino-live-tracker: Contains the C++ code for the ESP8266./src: TypeScript source code for the backend (API wrappers, types, utilities).
-
Install Deno: Ensure you have Deno installed on your system.
-
Environment Setup: Create a
.envfile in the root directory based on.env.example. You will need:MIDTTRAFIK_API_BASE_URL=your_midttrafik_api_url
-
Run the Server: Start the backend server which processes the API data and serves it to the hardware client.
deno run -A server.ts
The server listens on port
4242.Alternatively, run the CLI tool to see departures in the terminal:
deno run -A main.ts
The hardware client is built for an ESP8266 microcontroller.
Prerequisites:
- ESP8266 Board (e.g., NodeMCU, Wemos D1 Mini)
- 2x RGB LEDs (connected to
D3) - Button (connected to
D2) - Buzzer (connected to
D1) - Arduino IDE with ESP8266 board support.
Setup:
-
Navigate to
arduino-live-tracker/. -
Copy
conf.h.exampletoconf.h. -
Fill in your configuration:
#define BUS_API_URL "http://<your-server-ip>:4242/" #define WIFI_SSID "your_wifi_ssid" #define WIFI_PASSWORD "your_wifi_password"
-
Open
arduino-live-tracker.inoin Arduino IDE. -
Install required libraries via Library Manager:
ArduinoJsonAdafruit NeoPixelPinButton
-
Upload the sketch to your board.
The device stays awake for a configured time (default 5 minutes) after a button press, fetching data every 30 seconds. The RGB LEDs indicate the departure status for the monitored stops, helping you decide when to start walking.