Bus and metro arrival board
Build it step by step
0 of 7 doneTest the display
Run the Adafruit ILI9341 example.
Join Wi-Fi
Print the IP address.
Find a feed
Read your agency's developer page.
Fetch and print it
Show the raw JSON in the serial monitor.
Parse the next three
Print route and minutes.
Draw the board
Large text, colour by urgency.
Mount it by the door
Use a small stand or frame.
How do you build a bus and metro arrival board?
A display by the door shows the next buses or trains from an open transit feed, so you leave at the right time. You need ESP32 DevKit V1, 2.8 inch TFT touch (ILI9341, SPI) and 5 V 2 A USB adapter. It takes 7 steps and about 180 minutes.
- Level
- Intermediate
- Time
- About 180 min
- Parts
- 3
Parts list
- Development BoardsBuyESP32 DevKit V1 × 1
- DisplaysBuy
- PowerBuy
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| TFT VCC and GND | ESP32 3V3 and GND | Power (check your module's regulator and voltage) |
| TFT CS | ESP32 GPIO5 | Chip select |
| TFT RESET | ESP32 GPIO4 | Reset |
| TFT DC | ESP32 GPIO2 | Data or command |
| TFT SDI (MOSI) | ESP32 GPIO23 | SPI data |
| TFT SCK | ESP32 GPIO18 | SPI clock |
| TFT LED | ESP32 3V3 | Backlight |
| TFT SDO (MISO) | ESP32 GPIO19 | Optional read line |
Code
City transit feeds differ a lot: some are open JSON, some need a free key, and many use the GTFS Realtime format, which is not JSON. Find your agency's developer page, get a key if needed, and keep it out of shared code. If the feed is not simple JSON, run a small script on a home computer that converts it to the format used here and serves it, then point the ESP32 at that. setInsecure() skips the certificate check, which is a trade-off; for a feed with a private key, load the server's certificate instead. Check the feed's terms for request limits; 30 seconds is gentle. Times shown in red are those you cannot catch if you need LEAVE_MINUTES to reach the stop. Arduino IDE with the ESP32 boards package, board "ESP32 Dev Module".
Runs on a virtual ESP32 Dev Module in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).
// Arrival board. Libraries: Adafruit ILI9341, Adafruit GFX, ArduinoJson (v7). Board: ESP32 Dev Module.
#include <WiFi.h>
#include <WiFiClientSecure.h>
#include <HTTPClient.h>
#include <ArduinoJson.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
const char* WIFI_SSID = "YOUR_WIFI_NAME";
const char* WIFI_PASS = "YOUR_WIFI_PASSWORD";
// Many city feeds need a key. Use your own feed address and key, and keep them out of shared code.
// This sketch expects JSON like {"arrivals":[{"route":"21","minutes":4},{"route":"5A","minutes":9}]}
// If your feed looks different, change the parsing in fetchArrivals().
const char* FEED_URL = "https://example.com/arrivals?stop=YOUR_STOP&key=YOUR_KEY";
const int LEAVE_MINUTES = 6; // minutes you need to reach the stop
Adafruit_ILI9341 tft(5, 2, 4); // CS, DC, RST (hardware SPI)
String route[3]; int mins[3]; int n = 0;
void fetchArrivals() {
WiFiClientSecure client; client.setInsecure(); // trade-off: skips the certificate check
HTTPClient http;
if (!http.begin(client, FEED_URL)) return;
if (http.GET() == 200) {
JsonDocument doc;
if (!deserializeJson(doc, http.getString())) {
n = 0;
for (JsonObject a : doc["arrivals"].as<JsonArray>()) {
if (n >= 3) break;
route[n] = a["route"].as<String>(); mins[n] = a["minutes"]; n++;
}
}
}
http.end();
}
void draw() {
tft.fillScreen(ILI9341_BLACK);
tft.setTextColor(ILI9341_WHITE); tft.setTextSize(3); tft.setCursor(10, 8); tft.print("Next arrivals");
for (int i = 0; i < n; i++) {
uint16_t col = (mins[i] <= LEAVE_MINUTES) ? ILI9341_RED : ILI9341_GREEN; // red = leave now
tft.setTextColor(ILI9341_WHITE); tft.setTextSize(4); tft.setCursor(10, 60 + i * 55); tft.print(route[i]);
tft.setTextColor(col); tft.setCursor(150, 60 + i * 55); tft.print(mins[i]); tft.print(" min");
}
if (n == 0) { tft.setTextSize(2); tft.setCursor(10, 80); tft.print("No data"); }
}
void setup() {
tft.begin(); tft.setRotation(1);
WiFi.begin(WIFI_SSID, WIFI_PASS);
while (WiFi.status() != WL_CONNECTED) delay(300);
}
void loop() { fetchArrivals(); draw(); delay(30000); } // every 30 secondsTest checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| Power on | Arrivals appear within 30 seconds |
| A bus within 6 minutes | Time shows in red |
| Feed offline | Shows No data, then recovers |
| Wait a minute | Minutes count down on the next update |
If it does not work
Blank screen
Check the CS, DC and RST pins against the sketch.
Colours wrong
Check the library and the display controller (ILI9341).
No data
Check the feed address, key and the JSON shape.
JSON parse fails
Use ArduinoJson version 7 or adapt for version 6.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the bus and metro arrival board?
ESP32 DevKit V1, 2.8 inch TFT touch (ILI9341, SPI) and 5 V 2 A USB adapter.
How long does the bus and metro arrival board take to build?
About 180 minutes for a intermediate maker, in 7 steps.
How do I know the bus and metro arrival board works?
Power on: Arrivals appear within 30 seconds. A bus within 6 minutes: Time shows in red. Feed offline: Shows No data, then recovers.
Blank screen: what should I check?
Check the CS, DC and RST pins against the sketch.
Colours wrong: what should I check?
Check the library and the display controller (ILI9341).
No data: what should I check?
Check the feed address, key and the JSON shape.
JSON parse fails: what should I check?
Use ArduinoJson version 7 or adapt for version 6.
