Build a cyberpunk-themed car dashboard powered by an ESP32 microcontroller and a vibrant ILI9341 touchscreen display. This project combines real-time vehicle data visualization with a futuristic neon aesthetic, complete with audio feedback from a piezo buzzer for alerts and notifications.
This guide provides a complete parts list, wiring diagram for connecting the TFT display and buzzer to the ESP32, step-by-step assembly instructions, and fully commented firmware that handles WiFi connectivity, web-based configuration, and dynamic dashboard screens. Makers will learn how to drive a color display, manage vehicle telemetry data, and create an interactive interface that can be customized for different car monitoring applications.
Wiring diagram
Gather all the parts
Assemble it in 2 steps
1. Connect the screen with USB unplugged
Connect VCC to 3V3 and GND to GND. Connect MOSI to GPIO23 (data to screen), MISO to GPIO19 (data back), and SCK to GPIO18 (clock). Connect TFT_CS to GPIO25 (select), TFT_DC to GPIO26 (data or command), and TFT_RST to GPIO4 (reset). On the catalog module connect TFT_BL and TOUCH_CS to 3V3 to enable the backlight and leave touch inactive.
- Check that your module accepts 3.3 V power and that its backlight input is not a bare LED pin before connecting it.
2. Connect the passive piezo buzzer
Connect the positive lead to GPIO27 (tone signal) and the negative lead to GND. Use USB power only; do not connect the board to vehicle wiring.
Review all connections
1. Connections between "tft" and "ESP32"
2. Connections between "buzzer" and "ESP32"
Deploy the firmware
#include <Arduino.h>
#include <WiFi.h>
#include <WiFiMulti.h>
#include <WebServer.h>
#include <ESPmDNS.h>
#include <Preferences.h>
#include <HTTPClient.h>
#include <time.h>
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
// ==================== HARDWARE PINS ====================
#define TFT_CS 25
#define TFT_DC 26
#define TFT_RST 4
#define BUZZER_PIN 27 // LONG PIN (+) -> GPIO 27, SHORT PIN (-) -> GND
// ==================== CYBERPUNK COLOR PALETTE ====================
#define CYBER_BG 0x0000
#define CYBER_CYAN 0x07FF
#define CYBER_MAGENTA 0xF81F
#define CYBER_YELLOW 0xFFE0
#define CYBER_GREEN 0x07E0
#define CYBER_RED 0xF800
#define CYBER_DARK 0x18E3
// ==================== GLOBAL OBJECTS ====================
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);
WiFiMulti wifiMulti;
WebServer server(80);
Preferences prefs;
// ==================== STATE & CAR DATA ====================
String LATITUDE = "10.3350"; // Vedapatti, Dindigul
String LONGITUDE = "77.9350";
int currentScreen = 0;
unsigned long lastScreenSwitch = 0;
unsigned long bootMillis = 0;
unsigned long lastWeatherFetch = 0;
bool breakAlertTriggered = false;
bool warmupDone = false;
// Odometer & Service Data (Editable on Phone Web Dashboard)
long currentOdoKm = 84500;
long lastServiceOdoKm = 74500; // 10,000 km already driven -> shows 0 km left (DUE!)
long lastFilterOdoKm = 74500;
String insuranceExpiry = "15-08-2027";
String pucExpiry = "20-05-2027";
int fastagBalance = 850;
float avgMileage = 18.5;
float dieselPrice = 94.5;
float plannedTripKm = 120.0;
int daysSinceLastDrive = 3;
bool buzzerMuted = false;
int selectedMelody = 1;
String navDirection = "NONE";
String navDistance = "";
String currentTemp = "29.5";
String acAdvice = "AC: NORMAL MODE";
// ==================== PASSIVE BUZZER AUDIO ====================
void playTone(int freq, int duration) {
if (buzzerMuted) return;
if (freq > 0) tone(BUZZER_PIN, freq, duration);
delay(duration + 15);
noTone(BUZZER_PIN);
}
void playStartupMelody() {
if (selectedMelody == 1) {
playTone(523, 100); playTone(659, 100); playTone(784, 120); playTone(1047, 250);
} else if (selectedMelody == 2) {
playTone(523, 120); playTone(587, 120); playTone(659, 120); playTone(784, 240);
} else {
playTone(880, 90); playTone(1175, 160);
}
}
// ==================== FLASH STORAGE ====================
void loadData() {
prefs.begin("sunny_odo", false);
currentOdoKm = prefs.getLong("cur_odo", 84500);
lastServiceOdoKm = prefs.getLong("svc_odo", 74500);
lastFilterOdoKm = prefs.getLong("flt_odo", 74500);
insuranceExpiry = prefs.getString("ins_dt", "15-08-2027");
pucExpiry = prefs.getString("puc_dt", "20-05-2027");
fastagBalance = prefs.getInt("fastag", 850);
avgMileage = prefs.getFloat("mileage", 18.5);
dieselPrice = prefs.getFloat("dprice", 94.5);
plannedTripKm = prefs.getFloat("tripkm", 120.0);
daysSinceLastDrive = prefs.getInt("idle", 3);
buzzerMuted = prefs.getBool("mute", false);
selectedMelody = prefs.getInt("melody", 1);
LATITUDE = prefs.getString("lat", "10.3350");
LONGITUDE = prefs.getString("lon", "77.9350");
}
void saveData() {
prefs.putLong("cur_odo", currentOdoKm);
prefs.putLong("svc_odo", lastServiceOdoKm);
prefs.putLong("flt_odo", lastFilterOdoKm);
prefs.putString("ins_dt", insuranceExpiry);
prefs.putString("puc_dt", pucExpiry);
prefs.putInt("fastag", fastagBalance);
prefs.putFloat("mileage", avgMileage);
prefs.putFloat("dprice", dieselPrice);
prefs.putFloat("tripkm", plannedTripKm);
prefs.putInt("idle", daysSinceLastDrive);
prefs.putBool("mute", buzzerMuted);
prefs.putInt("melody", selectedMelody);
prefs.putString("lat", LATITUDE);
prefs.putString("lon", LONGITUDE);
}
// ==================== WEATHER & AC ADVISOR ====================
void fetchWeather() {
if (WiFi.status() != WL_CONNECTED) return;
HTTPClient http;
String url = "http://api.open-meteo.com/v1/forecast?latitude=" + LATITUDE +
"&longitude=" + LONGITUDE + "¤t_weather=true";
http.begin(url);
if (http.GET() == 200) {
String body = http.getString();
int cwIdx = body.indexOf("\"current_weather\":");
if (cwIdx > 0) {
int tIdx = body.indexOf("\"temperature\":", cwIdx);
int cIdx = body.indexOf("\"weathercode\":", cwIdx);
if (tIdx > 0) currentTemp = body.substring(tIdx + 14, body.indexOf(",", tIdx));
if (cIdx > 0) {
int wCode = body.substring(cIdx + 14, body.indexOf("}", cIdx)).toInt();
float tempVal = currentTemp.toFloat();
if (wCode >= 51) acAdvice = "RAIN >> AC ON (DEFOG)";
else if (tempVal >= 32.0) acAdvice = "HOT >> AC RECIRCULATE";
else if (tempVal >= 21.0 && tempVal <= 26.5) acAdvice = "COOL >> AC OFF (ECO)";
else acAdvice = "AC: NORMAL MODE";
}
}
}
http.end();
}
// ==================== CYBERPUNK HUD FRAME ====================
void drawCyberFrame(String headerTag, uint16_t accentColor) {
tft.fillScreen(CYBER_BG);
tft.drawRect(4, 4, 312, 232, accentColor);
tft.drawRect(6, 6, 308, 228, CYBER_DARK);
tft.fillRect(4, 4, 185, 22, accentColor);
tft.setTextColor(CYBER_BG);
tft.setTextSize(1);
tft.setCursor(12, 11);
tft.print("// " + headerTag);
for (int i = 0; i < 3; i++) {
if (i == currentScreen) tft.fillRect(265 + (i * 14), 10, 10, 10, CYBER_YELLOW);
else tft.drawRect(265 + (i * 14), 10, 10, 10, accentColor);
}
}
// ==================== DISPLAY SCREENS ====================
void drawStartupScreen() {
tft.fillScreen(CYBER_BG);
tft.drawRect(6, 6, 308, 228, CYBER_MAGENTA);
tft.drawRect(10, 10, 300, 220, CYBER_CYAN);
tft.setTextColor(CYBER_CYAN);
tft.setTextSize(3);
tft.setCursor(48, 50);
tft.print("NISSAN SUNNY");
tft.setTextColor(CYBER_MAGENTA);
tft.setTextSize(2);
tft.setCursor(32, 88);
tft.print("K9K PURE DRIVE DIESEL");
tft.drawFastHLine(25, 118, 270, CYBER_YELLOW);
tft.setTextColor(CYBER_YELLOW);
tft.setTextSize(2);
tft.setCursor(32, 135);
tft.print("ODO : " + String(currentOdoKm) + " KM");
tft.setTextColor(CYBER_GREEN);
tft.setCursor(32, 165);
tft.print("IDLE: " + String(daysSinceLastDrive) + " DAYS PARKED");
long oilLeft = (lastServiceOdoKm + 10000) - currentOdoKm;
if (oilLeft <= 500) {
tft.setTextColor(CYBER_RED);
tft.setTextSize(1);
tft.setCursor(32, 200);
tft.print("! SERVICE ALERT: 10,000 KM OIL SERVICE DUE !");
}
playStartupMelody();
delay(2200);
}
void drawScreen1_Cockpit() {
drawCyberFrame("SYS.COCKPIT // HUD-01", CYBER_CYAN);
struct tm timeinfo;
char timeStr[10] = "--:--";
char dateStr[25] = "VEDAPATTI // DGL";
if (getLocalTime(&timeinfo, 0)) {
strftime(timeStr, sizeof(timeStr), "%H:%M", &timeinfo);
strftime(dateStr, sizeof(dateStr), "%a %d %b %Y", &timeinfo);
}
tft.setTextColor(CYBER_MAGENTA);
tft.setTextSize(2);
tft.setCursor(20, 38);
tft.print(dateStr);
tft.setTextColor(CYBER_YELLOW);
tft.setTextSize(6);
tft.setCursor(20, 68);
tft.print(timeStr);
tft.drawFastHLine(14, 125, 292, CYBER_CYAN);
tft.setTextColor(CYBER_CYAN);
tft.setTextSize(2);
tft.setCursor(20, 138);
tft.print("AMBIENT: " + currentTemp + " C");
tft.setTextColor(CYBER_GREEN);
tft.setTextSize(2);
tft.setCursor(20, 168);
tft.print(acAdvice);
unsigned long elapsedSec = (millis() - bootMillis) / 1000;
tft.setTextSize(1);
if (elapsedSec < 45) {
tft.setTextColor(CYBER_MAGENTA);
tft.setCursor(20, 205);
tft.print(">> K9K TURBO WARM-UP: " + String(45 - elapsedSec) + "s LEFT <<");
} else {
if (!warmupDone) {
warmupDone = true;
playTone(1047, 120);
}
tft.setTextColor(CYBER_CYAN);
tft.setCursor(20, 205);
String net = (WiFi.status() == WL_CONNECTED) ? (WiFi.SSID() + " [" + WiFi.localIP().toString() + "]") : "OFFLINE MODE";
tft.print("LINK: " + net);
}
}
void drawScreen2_TripAndFuel() {
drawCyberFrame("TELEMETRY // HUD-02", CYBER_MAGENTA);
unsigned long mins = (millis() - bootMillis) / 60000;
int hrs = mins / 60;
int remMins = mins % 60;
tft.setTextSize(2);
tft.setTextColor(CYBER_CYAN);
tft.setCursor(20, 42);
tft.print("DRIVE TIME : " + String(hrs) + "h " + String(remMins) + "m");
tft.setTextColor(fastagBalance < 300 ? CYBER_RED : CYBER_GREEN);
tft.setCursor(20, 76);
tft.print("FASTAG BAL : Rs." + String(fastagBalance));
tft.setTextColor(CYBER_YELLOW);
tft.setCursor(20, 110);
tft.print("MILEAGE : " + String(avgMileage, 1) + " km/L");
float estCost = (plannedTripKm / avgMileage) * dieselPrice;
tft.setTextColor(CYBER_MAGENTA);
tft.setCursor(20, 144);
tft.print("TRIP(" + String((int)plannedTripKm) + "km) : Rs." + String((int)estCost));
tft.drawFastHLine(14, 178, 292, CYBER_DARK);
tft.setTextSize(1);
if (hrs >= 2) {
tft.setTextColor(CYBER_RED);
tft.setCursor(20, 195);
tft.print("! FATIGUE ALERT: 2+ HRS CONTINUOUS DRIVE !");
} else {
tft.setTextColor(CYBER_CYAN);
tft.setCursor(20, 195);
tft.print("ODOMETER: " + String(currentOdoKm) + " KM // K9K DIESEL");
}
}
void drawScreen3_Maintenance() {
drawCyberFrame("K9K SERVICE // HUD-03", CYBER_YELLOW);
long oilLeft = (lastServiceOdoKm + 10000) - currentOdoKm;
long filterLeft = (lastFilterOdoKm + 10000) - currentOdoKm;
tft.setTextSize(2);
tft.setTextColor(oilLeft <= 500 ? CYBER_RED : CYBER_CYAN);
tft.setCursor(20, 42);
if (oilLeft <= 0) tft.print("OIL SVC : DUE NOW! (" + String(abs(oilLeft)) + "km)");
else tft.print("OIL SVC : " + String(oilLeft) + " KM LEFT");
tft.setTextColor(filterLeft <= 500 ? CYBER_RED : CYBER_GREEN);
tft.setCursor(20, 76);
if (filterLeft <= 0) tft.print("DSL FLTR: DUE NOW!");
else tft.print("DSL FLTR: " + String(filterLeft) + " KM LEFT");
tft.setTextColor(CYBER_YELLOW);
tft.setCursor(20, 110);
tft.print("INS EXP : " + insuranceExpiry);
tft.setTextColor(CYBER_MAGENTA);
tft.setCursor(20, 144);
tft.print("PUC EXP : " + pucExpiry);
tft.drawFastHLine(14, 178, 292, CYBER_DARK);
tft.setTextSize(1);
tft.setTextColor(CYBER_CYAN);
tft.setCursor(20, 195);
tft.print("CURRENT ODO: " + String(currentOdoKm) + " KM (LAST SVC: " + String(lastServiceOdoKm) + ")");
}
void drawNavigationScreen() {
tft.fillScreen(CYBER_BG);
tft.drawRect(4, 4, 312, 232, CYBER_GREEN);
tft.fillRect(4, 4, 312, 26, CYBER_GREEN);
tft.setTextColor(CYBER_BG);
tft.setTextSize(2);
tft.setCursor(20, 9);
tft.print("NAV LINK // ACTIVE ROUTE");
tft.setTextColor(CYBER_YELLOW);
tft.setTextSize(3);
tft.setCursor(25, 85);
if (navDirection == "LEFT") tft.print("<< TURN LEFT");
else if (navDirection == "RIGHT") tft.print("TURN RIGHT >>");
else if (navDirection == "UTURN") tft.print("U-TURN AHEAD");
else tft.print("^^ STRAIGHT");
tft.setTextColor(CYBER_CYAN);
tft.setTextSize(3);
tft.setCursor(25, 145);
tft.print("DIST: " + navDistance);
}
// ==================== CYBERPUNK WEB CONTROL PANEL ====================
void handleRoot() {
long oilLeft = (lastServiceOdoKm + 10000) - currentOdoKm;
String html = "<!DOCTYPE html><html><head><meta name='viewport' content='width=device-width,initial-scale=1'>";
html += "<style>body{font-family:monospace;background:#090a0f;color:#00f3ff;padding:15px;}";
html += "h2{color:#ff00ff;border-bottom:1px solid #00f3ff;padding-bottom:8px;}";
html += ".status{background:#141824;padding:10px;border-left:4px solid #ffe600;margin-bottom:12px;}";
html += "input,select,button{width:100%;padding:10px;margin:6px 0;background:#141824;color:#fff;border:1px solid #00f3ff;font-size:15px;}";
html += "button{background:#00f3ff;color:#000;font-weight:bold;cursor:pointer;} .btn-pink{background:#ff00ff;color:#fff;border:none;}</style>";
html += "<script>function syncGPS(){if(navigator.geolocation){navigator.geolocation.getCurrentPosition(function(p){";
html += "window.location.href='/gps?lat='+p.coords.latitude.toFixed(4)+'&lon='+p.coords.longitude.toFixed(4);});}}</script></head><body>";
html += "<h2>// NISSAN SUNNY CYBER-HUD</h2>";
html += "<div class='status'>10K SERVICE STATUS: <b>" + (oilLeft <= 0 ? String("DUE NOW!") : (String(oilLeft) + " KM REMAINING")) + "</b></div>";
html += "<button class='btn-pink' onclick='syncGPS()'>[ SYNC LIVE PHONE GPS ]</button>";
html += "<form action='/save' method='POST'>";
html += "CURRENT ODOMETER (KM):<input type='number' name='cur_odo' value='" + String(currentOdoKm) + "'>";
html += "LAST 10K SERVICE ODO (KM):<input type='number' name='svc_odo' value='" + String(lastServiceOdoKm) + "'>";
html += "LAST DIESEL FILTER ODO (KM):<input type='number' name='flt_odo' value='" + String(lastFilterOdoKm) + "'>";
html += "INSURANCE EXPIRY DATE:<input type='text' name='ins_dt' value='" + insuranceExpiry + "'>";
html += "PUC EXPIRY DATE:<input type='text' name='puc_dt' value='" + pucExpiry + "'>";
html += "FASTAG BALANCE (Rs):<input type='number' name='fastag' value='" + String(fastagBalance) + "'>";
html += "AVG MILEAGE (km/L):<input type='text' name='mileage' value='" + String(avgMileage) + "'>";
html += "DIESEL PRICE (Rs/L):<input type='text' name='dprice' value='" + String(dieselPrice) + "'>";
html += "PLANNED TRIP (km):<input type='number' name='tripkm' value='" + String((int)plannedTripKm) + "'>";
html += "DAYS SINCE LAST DRIVE:<input type='number' name='idle' value='" + String(daysSinceLastDrive) + "'>";
html += "STARTUP TONE:<select name='melody'><option value='1'>Cyber Chime</option><option value='2'>Sa-Ri-Ga-Pa</option><option value='3'>Double Beep</option></select>";
html += "AUDIO MUTE:<select name='mute'><option value='0'>SOUND ON</option><option value='1'>MUTED</option></select>";
html += "<button type='submit'>[ UPLOAD TO HUD ]</button></form>";
html += "<form action='/deduct' method='POST'><button class='btn-pink' type='submit'>[ TOLL DEDUCT -Rs.65 ]</button></form>";
html += "</body></html>";
server.send(200, "text/html", html);
}
void handleGPS() {
if (server.hasArg("lat") && server.hasArg("lon")) {
LATITUDE = server.arg("lat");
LONGITUDE = server.arg("lon");
saveData();
fetchWeather();
playTone(1047, 100);
}
server.sendHeader("Location", "/");
server.send(303);
}
void handleSave() {
if (server.hasArg("cur_odo")) currentOdoKm = server.arg("cur_odo").toInt();
if (server.hasArg("svc_odo")) lastServiceOdoKm = server.arg("svc_odo").toInt();
if (server.hasArg("flt_odo")) lastFilterOdoKm = server.arg("flt_odo").toInt();
if (server.hasArg("ins_dt")) insuranceExpiry = server.arg("ins_dt");
if (server.hasArg("puc_dt")) pucExpiry = server.arg("puc_dt");
if (server.hasArg("fastag")) fastagBalance = server.arg("fastag").toInt();
if (server.hasArg("mileage")) avgMileage = server.arg("mileage").toFloat();
if (server.hasArg("dprice")) dieselPrice = server.arg("dprice").toFloat();
if (server.hasArg("tripkm")) plannedTripKm = server.arg("tripkm").toFloat();
if (server.hasArg("idle")) daysSinceLastDrive = server.arg("idle").toInt();
if (server.hasArg("melody")) selectedMelody = server.arg("melody").toInt();
if (server.hasArg("mute")) buzzerMuted = (server.arg("mute").toInt() == 1);
saveData();
playTone(1047, 100);
server.sendHeader("Location", "/");
server.send(303);
}
void handleDeduct() {
fastagBalance -= 65;
if (fastagBalance < 0) fastagBalance = 0;
saveData();
playTone(784, 150);
server.sendHeader("Location", "/");
server.send(303);
}
void handleNavAPI() {
if (server.hasArg("dir")) {
navDirection = server.arg("dir");
navDistance = server.arg("dist");
if (navDirection != "NONE") {
playTone(659, 90);
playTone(880, 140);
drawNavigationScreen();
}
}
server.send(200, "text/plain", "OK");
}
// ==================== MAIN SETUP & LOOP ====================
void setup() {
Serial.begin(115200);
pinMode(BUZZER_PIN, OUTPUT);
loadData();
tft.begin();
tft.setRotation(1);
bootMillis = millis();
drawStartupScreen();
WiFi.mode(WIFI_STA);
wifiMulti.addAP("Nandha Gopinath 4G", "12345678");
wifiMulti.addAP("RANJU", "RANJANI93");
wifiMulti.addAP("Prajai's S22+", "90429270277");
unsigned long wifiStart = millis();
while (wifiMulti.run() != WL_CONNECTED && millis() - wifiStart < 8000) {
delay(250);
}
if (WiFi.status() == WL_CONNECTED) {
configTime(19800, 0, "pool.ntp.org"); // IST (+5:30)
MDNS.begin("sunny"); // Access at http://sunny.local
fetchWeather();
}
server.on("/", handleRoot);
server.on("/gps", handleGPS);
server.on("/save", HTTP_POST, handleSave);
server.on("/deduct", HTTP_POST, handleDeduct);
server.on("/nav", handleNavAPI);
server.begin();
drawScreen1_Cockpit();
}
void loop() {
server.handleClient();
if (!breakAlertTriggered && (millis() - bootMillis >= 7200000UL)) {
breakAlertTriggered = true;
playTone(587, 150); playTone(784, 250);
}
if (millis() - lastWeatherFetch > 900000UL) {
lastWeatherFetch = millis();
fetchWeather();
}
if (navDirection == "NONE" && (millis() - lastScreenSwitch > 8000)) {
lastScreenSwitch = millis();
currentScreen = (currentScreen + 1) % 3;
if (currentScreen == 0) drawScreen1_Cockpit();
else if (currentScreen == 1) drawScreen2_TripAndFuel();
else if (currentScreen == 2) drawScreen3_Maintenance();
}
}Remix this project
Make it yours in one click
Open a full copy of this project in your own Schematik workspace, diagram, code, parts, and assembly steps included. Swap the sensor, add features, or redesign the whole thing with AI. The author's original stays untouched.




