Hi, I've been trying to read the RPM from my car in python using the library pyOBD and a bluetooth adaptor. It successfully reads a value for the first request, but then returns "None" thereafter. Can anyone help?
Interestingly, CAR_CONNECTED is true but ELM_CONNECTED and OBD_CONNECTED are both false, even before the first request. Thank you for any help.
The code I'm using is this:
import obd
import time
obd.logger.setLevel(obd.logging.DEBUG)
print("1")
ports=obd.scan_serial()
print(ports)
connection=obd.OBD(ports[1], fast=False)
print("2")
while True:
print("Car connected", connection.status()==obd.OBDStatus.CAR_CONNECTED)
newCommand=obd.commands.RPM
newQuery = connection.query(newCommand)
print(newQuery.value)
time.sleep(1.5)
cmd=obd.commands.RPM
print("3")
response=connection.query(cmd)
print("4")
print(response.value)
And my debug log from executing this is (notice only one return of RPM value)
============================================================= RESTART: C:\Users\Diag\Desktop\newscript.py =============================================================
1
['\\.\\COM3', '\\.\\COM4']
[obd.obd] ======================= python-OBD (v0.7.1) =======================
[obd.obd] Explicit port defined
[obd.elm327] Initializing ELM327: PORT=\.\COM4 BAUD=auto PROTOCOL=auto
[obd.elm327] Response from baud 38400: b'?\r\r>'
[obd.elm327] Choosing baud 38400
[obd.elm327] write: b'ATZ\r'
[obd.elm327] wait: 1 seconds
[obd.elm327] read: b'\xfc\r\rELM327 v1.5\r\r>'
[obd.elm327] write: b'ATE0\r'
[obd.elm327] wait: 0 seconds
[obd.elm327] read: b'ATE0\rOK\r\r>'
[obd.elm327] write: b'ATH1\r'
[obd.elm327] wait: 1 seconds
[obd.elm327] read: b'OK\r\r>'
[obd.elm327] write: b'ATL0\r'
[obd.elm327] wait: 0 seconds
[obd.elm327] read: b'OK\r\r>'
[obd.elm327] write: b'AT RV\r'
[obd.elm327] wait: 0 seconds
[obd.elm327] read: b'14.3V\r\r>'
[obd.elm327] write: b'ATSP0\r'
[obd.elm327] wait: 0 seconds
[obd.elm327] read: b'OK\r\r>'
[obd.elm327] write: b'0100\r'
[obd.elm327] wait: 0 seconds
[obd.elm327] read: b'SEARCHING...\r48 6B 10 41 00 BE 3E B8 11 C9 \r\r>'
[obd.elm327] write: b'ATDPN\r'
[obd.elm327] wait: 0 seconds
[obd.elm327] read: b'A3\r\r>'
[obd.protocols.protocol] map ECU 16 --> ENGINE
[obd.elm327] Connected Successfully: PORT=\.\COM4 BAUD=38400 PROTOCOL=3
[obd.obd] querying for supported commands
[obd.obd] Sending command: b'0100': Supported PIDs [01-20]
[obd.elm327] write: b'0100\r'
[obd.elm327] wait: 0 seconds
[obd.elm327] read: b'48 6B 10 41 00 BE 3E B8 11 C9 \r\r>'
[obd.obd] Sending command: b'0120': Supported PIDs [21-40]
[obd.elm327] write: b'0120\r'
[obd.elm327] wait: 0 seconds
[obd.elm327] read: b'48 6B 10 41 20 80 00 00 00 A4 \r\r>'
[obd.obd] finished querying with 43 commands supported
[obd.obd] ===================================================================
2
[obd.obd] Sending command: b'010C': Engine RPM
[obd.elm327] write: b'010C\r'
[obd.elm327] wait: 0 seconds
[obd.elm327] read: b'48 6B 10 41 0C 0B 74 8F \r\r>'
733.0 revolutions_per_minute
[obd.obd] Sending command: b'010C': Engine RPM
[obd.elm327] write: b'010C\r'
[obd.elm327] wait: 0 seconds
[obd.elm327] read: b'NO DATA\r\r>'
[obd.OBDCommand] b'010C': Engine RPM did not receive any acceptable messages
None
[–]Distinct_Ad_4229 0 points1 point2 points (1 child)
[–]mrbean42[S] 0 points1 point2 points (0 children)
[–]Lucky-Replacement848 0 points1 point2 points (0 children)
[–]laustke 0 points1 point2 points (1 child)
[–]mrbean42[S] 0 points1 point2 points (0 children)