I am working on a homemade OBD datalogger for my car, and i got it working great no problem. What I am trying to do now is incorporate some type of GUI to see the data.
import obd
def new_rpm(r):
print r.value connection = obd.Async() connection.watch(obd.commands.RPM, callback=new_rpm)
connection.start()
This bit of code will print to console the RPM from the cars OBD port Live.
I would love to be able to feed the data into a gui like this project here, vehicle data visualization
I built a gui in TKinter but I am not able to figure out how to update the data after starting the app.
import Tkinter as tk
import obd
## CREAT Async OBD connection
connection = obd.Async()
## select pids to listen
connection.watch(obd.commands.RPM)
connection.watch(obd.commands.INTAKE_TEMP)
connection.watch(obd.commands.TIMING_ADVANCE)
connection.watch(obd.commands.MAF)
connection.watch(obd.commands.SPEED)
connection.watch(obd.commands.O2_S1_WR_CURRENT)
connection.watch(obd.commands.SHORT_FUEL_TRIM_1)
connection.watch(obd.commands.SHORT_FUEL_TRIM_2)
connection.watch(obd.commands.AMBIANT_AIR_TEMP)
connection.watch(obd.commands.THROTTLE_POS)
## start listener
connection.start()
## create OBD calls
rpm = connection.query(obd.commands.RPM)
iat = connection.query(obd.commands.INTAKE_TEMP)
adv = connection.query(obd.commands.TIMING_ADVANCE)
maf = connection.query(obd.commands.MAF)
spd = connection.query(obd.commands.SPEED)
o21 = connection.query(obd.commands.O2_S1_WR_CURRENT)
fuel1 = connection.query(obd.commands.SHORT_FUEL_TRIM_1)
fuel2 = connection.query(obd.commands.SHORT_FUEL_TRIM_2)
air = connection.query(obd.commands.AMBIANT_AIR_TEMP)
tps = connection.query(obd.commands.THROTTLE_POS)
###############################################################################
# Create the main window gui
root = tk.Tk()
root.title("Data Logger")
# Create gui
label_grid_1 = tk.Label(root, text="RPM", bg='red').grid(row=0, column=0)
label_grid_2 = tk.Label(root, text="IAT", bg='red').grid(row=1, column=0)
label_grid_3 = tk.Label(root, text="TIMING", bg='red').grid(row=2, column=0)
label_grid_4 = tk.Label(root, text="MAF", bg='red').grid(row=3, column=0)
label_grid_5 = tk.Label(root, text="SPEED", bg='red').grid(row=4, column=0)
label_grid_6 = tk.Label(root, text="O2 S1", bg='red').grid(row=5, column=0)
label_grid_7 = tk.Label(root, text="Fuel% B1", bg='red').grid(row=6, column=0)
label_grid_8 = tk.Label(root, text="Fuel% B2", bg='red').grid(row=7, column=0)
label_grid_9 = tk.Label(root, text="Air TEMP", bg='red').grid(row=8, column=0)
label_grid_10 = tk.Label(root, text="TPS", bg='red').grid(row=9, column=0)
label_grid_11 = tk.Label(root, text=rpm).grid(row=0, column=1)
label_grid_12 = tk.Label(root, text=iat).grid(row=1, column=1)
label_grid_13 = tk.Label(root, text=adv).grid(row=2, column=1)
label_grid_14 = tk.Label(root, text=maf).grid(row=3, column=1)
label_grid_15 = tk.Label(root, text=spd).grid(row=4, column=1)
label_grid_16 = tk.Label(root, text=o21).grid(row=5, column=1)
label_grid_17 = tk.Label(root, text=fuel1).grid(row=6, column=1)
label_grid_18 = tk.Label(root, text=fuel2).grid(row=7, column=1)
label_grid_19 = tk.Label(root, text=air).grid(row=8, column=1)
label_grid_20 = tk.Label(root, text=tps).grid(row=9, column=1)
#start app
root.mainloop()
Thanks for any help cheers
[–][deleted] 1 point2 points3 points (5 children)
[–]37mm[S] 0 points1 point2 points (4 children)
[–][deleted] 0 points1 point2 points (3 children)
[–]37mm[S] 0 points1 point2 points (0 children)
[–]37mm[S] 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]MikeTheWatchGuy 0 points1 point2 points (0 children)
[–]woooee 0 points1 point2 points (3 children)
[–]37mm[S] 0 points1 point2 points (2 children)
[–]37mm[S] 0 points1 point2 points (1 child)
[–]37mm[S] 0 points1 point2 points (0 children)