This week is focused on Interface and Application Programming. The objectives were to compare development toolchains for creating graphical user interfaces (GUIs), and write a computer application that communicates with an embedded input/output device. I developed a Python-based Go-Kart Telemetry Dashboard application using the Tkinter library that reads serial data from the ESP32-C3 board and updates live virtual dials for speed, throttle, and battery voltage.
The group assignment was to review and compare different software platforms and frameworks for interface programming. We built simple serial text loggers using Python, JavaScript, and Processing. The complete group analysis is available on the Fablab Dilijan Group Assignment Page.
| Platform / Library | Language | Pros | Cons | Suitability |
|---|---|---|---|---|
| Tkinter | Python | Built-in, lightweight, fast to implement, native OS rendering. | Limited modern widget styling, widgets can look dated. | Chosen for simple, robust local desktop serial telemetry. |
| Processing | Java-like / Python | Incredibly easy to draw shapes, graphics-focused, built-in serial libraries. | Lacks complex UI structures (input forms, grids) by default. | Good for quick 2D coordinate animations. |
| Web Serial API | HTML5 / JavaScript | Runs directly in the browser, no local installation, rich CSS styling. | Browser compatibility limits (Chrome/Edge only), security restrictions. | Best for cross-platform browser dashboards. |
I wrote a desktop application in Python 3 using **PySerial** for data collection and **Tkinter** for the user interface. The app parses a comma-separated data stream from the microcontroller, extracting variables to render a live graphical dashboard.
The microcontroller sends text packets over the USB virtual COM port in CSV format:
$THROTTLE,SPEED,VOLTAGE\r\n
Example frame: $78,35,41.8 (representing 78% throttle, 35 km/h, and 41.8V battery level).
This script opens the COM port, runs an asynchronous background thread to read the incoming serial data, and uses Tkinter callbacks to update the graphic dials and text boxes:
# Python 3 Telemetry GUI - Tkinter & PySerial
import tkinter as tk
from tkinter import ttk
import serial
import threading
import sys
# Configure Serial connection
SERIAL_PORT = 'COM3' # Change to '/dev/ttyUSB0' on Linux
BAUD_RATE = 115200
try:
ser = serial.Serial(SERIAL_PORT, BAUD_RATE, timeout=0.1)
except Exception as e:
print(f"Error opening port {SERIAL_PORT}: {e}")
ser = None
class TelemetryApp(tk.Tk):
def __init__(self):
super().__init__()
self.title("Go-Kart Live Telemetry")
self.geometry("400x300")
self.configure(bg="#222")
# Heading
self.header = tk.Label(self, text="KART TELEMETRY STATUS", font=("Arial", 16, "bold"), fg="cyan", bg="#222")
self.header.pack(pady=10)
# Speed Label
self.speed_val = tk.StringVar(value="0 km/h")
self.speed_lbl = tk.Label(self, textvariable=self.speed_val, font=("Arial", 28, "bold"), fg="white", bg="#222")
self.speed_lbl.pack(pady=10)
# Throttle Progress Bar
self.bar_lbl = tk.Label(self, text="Throttle Level:", font=("Arial", 10), fg="white", bg="#222")
self.bar_lbl.pack()
self.progress = ttk.Progressbar(self, orient="horizontal", length=300, mode="determinate")
self.progress.pack(pady=10)
# Voltage Label
self.volt_val = tk.StringVar(value="Voltage: 0.0V")
self.volt_lbl = tk.Label(self, textvariable=self.volt_val, font=("Arial", 12), fg="yellow", bg="#222")
self.volt_lbl.pack(pady=10)
# Run background thread for serial read
self.running = True
self.thread = threading.Thread(target=self.read_serial, daemon=True)
self.thread.start()
def read_serial(self):
while self.running:
if ser and ser.in_waiting > 0:
try:
line = ser.readline().decode('utf-8').strip()
if line.startswith("$"):
# Parse CSV data: e.g. "$78,35,41.8"
data = line[1:].split(",")
if len(data) == 3:
throttle = int(data[0])
speed = int(data[1])
voltage = float(data[2])
# Update Tkinter variables safely
self.progress['value'] = throttle
self.speed_val.set(f"{speed} km/h")
self.volt_val.set(f"Battery: {voltage} V")
except Exception as e:
pass
def destroy(self):
self.running = False
if ser:
ser.close()
super().destroy()
if __name__ == "__main__":
app = TelemetryApp()
app.mainloop()
Download the Python telemetry GUI source code script:
| File Name | Format | Description | Download Link |
|---|---|---|---|
| telemetry_dashboard.py | Python Script (.py) | Tkinter graphical dashboard interface script for plotting serial data. | 📥 Download PY |
pySerial), spawns a daemon thread to read incoming JSON data frames from the dashboard MCU, and schedules UI redraws, as detailed in Communication.This week focused on software interfaces, data formatting, and desktop integrations. Here is a summary of the accomplishments:
Compared lightweight desktop libraries (Tkinter), drawing engines (Processing), and browser solutions (Web Serial API).
Integrated PySerial libraries in Python to bind local COM ports and read incoming raw byte streams from the board.
Implemented robust string parsing logic in Python to separate comma-delimited strings into specific variables.
Created graphical labels and progress bars in Python to render live throttle meters and numeric battery voltage values.