Last active
August 26, 2022 09:04
-
-
Save nomunomu0504/dc3dc538bbc7738ecdff2a771a0c6c29 to your computer and use it in GitHub Desktop.
OBD2 + Raspi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import obd | |
from obd import OBDStatus | |
import time, csv | |
import os | |
f = open("data.csv", "w") | |
writer = csv.writer(f, lineterminator="\n") | |
connection = obd.OBD() | |
print (connection.status()) | |
if connection.status() == OBDStatus.CAR_CONNECTED: | |
writer.writerow(["rpm", "speed"]) | |
while(True): | |
try: | |
rpm = connection.query(obd.commands.RPM) | |
speed = connection.query(obd.commands.SPEED) | |
writer.writerow([rpm.value.magnitude, speed.value.magnitude]) | |
print (rpm.value.magnitude, speed.value.magnitude) | |
# time.sleep(.2) | |
except KeyboardInterrupt: | |
pass | |
else: | |
connection.close() | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo hciconfig hci0 up | |
sudo rmmod rfcomm | |
sudo modprobe rfcomm | |
sudo rfcomm bind rfcomm0 AA:BB:CC:11:22:33 | |
ls /dev |grep rfcomm | |
sudo rfcomm connect 0 AA:BB:CC:11:22:33 1& | |
sudo python logging.py |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment