You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit f306be5
Browse filesBrowse the repository at this point in the historyBrowse files
Brendan Whitfield
committed
made the readme short and sweet (moved stuff to the wiki)
A python module for handling realtime sensor data from OBD-II vehicle ports
5
-
6
-
This library is forked from:
7
-
8
-
+ https://github.com/peterh/pyobd
9
-
+ https://github.com/Pbartek/pyobd-pi
4
+
A python module for handling realtime sensor data from OBD-II vehicle ports.
10
5
11
6
Installation
12
7
------------
@@ -23,59 +18,23 @@ Dependencies
23
18
+ OBD-II adapter (ELM327 Bluetooth Adapter or ELM327 USB Cable)
24
19
25
20
26
-
Usage
27
-
-----
28
-
29
-
After installing the library, simply import 'obd', and create a new OBD connection object. By default, python-OBD will scan for Bluetooth and USB serial ports (in that order), and will pick the first connection it finds. The port can also be specified manually by passing a connection string to the OBD constructor. You can also use the scanSerial helper retrieve a list of connected ports::
30
-
31
-
import obd
32
-
33
-
connection = obd.OBD() # create connection object
34
-
35
-
# OR
36
-
37
-
connection = obd.OBD("/dev/ttyUSB0") # create connection with USB 0
38
-
39
-
# OR
40
-
41
-
ports = obd.scanSerial() # return list of valid USB or RF ports
42
-
print ports
43
-
connection = obd.OBD(ports[0]) # connect to the first port in the list
44
-
45
-
46
-
Once a connection is made, python-OBD will load a list of the available commands in your car. A "Command" in python-OBD is an object used to query specific information from the vehicle. A command object contains its name, units, codes, and decoding functions. To get the value of a sensor, call the query() function with that sensor's command as an argument::
47
-
48
-
import obd
49
-
50
-
connection = obd.OBD()
51
-
52
-
for command in connection.supportedCommands:
53
-
print str(command) # prints the command name
54
-
response = connection.query(command) # sends the command, and returns the decoded response
55
-
print response.value, response.unit # prints the data and units returned from the car
56
-
21
+
Basic Usage
22
+
-----------
57
23
58
-
Commands can also be accessed explicitly, either by name, or by code value. The has_command() function will determine whether or not your car supports the requested command::
24
+
After installing the library, simply import 'obd', and create a new OBD connection object. Commands can then be sent to the car using the `query` function::
59
25
60
26
import obd
61
27
62
-
connection = obd.OBD()
63
-
64
-
65
-
c = obd.commands.RPM
66
-
67
-
# OR
28
+
connection = obd.OBD() # auto-connects to USB or RF port
68
29
69
-
c = obd.commands['RPM']
30
+
cmd = obd.commands.RPM # select an OBD command (sensor)
70
31
71
-
# OR
32
+
response = connection.query(cmd) # send the command, and parse the response
72
33
73
-
c = obd.commands[1][12] # mode 1, PID 12 (decimal)
74
-
75
-
76
-
if connection.has_command(c): # check for existance of sensor
77
-
print connection.query(c).value # get and print value of sensor
34
+
print(response.value)
35
+
print(response.unit)
78
36
37
+
For more in-depth documentation, `visit the Wiki! <http://github.com/brendanwhitfield/python-OBD/wiki>`
79
38
80
39
Here are a few of the currently supported commands (note: support for these commands will vary from car to car):
81
40
@@ -101,21 +60,9 @@ Here are a few of the currently supported commands (note: support for these comm
101
60
+ Engine fuel rate
102
61
+ etc... (for a full list, see `commands.py <http://github.com/brendanwhitfield/python-OBD/blob/master/obd/commands.py#L106>`_)
103
62
63
+
This library is forked from:
104
64
105
-
Debug
106
-
-----
107
-
108
-
python-OBD also contains a debug object that can be used to print status messages and errors. Console printing is disabled by default, but can be enabled manually. A custom debug handler can also be set::
0 commit comments