Chadley Maggott
Chadley Maggott

Reputation: 366

Cannot read data from ELM327 device with PySerial

I am trying to communicate with a ELM327 device using PySerial. However I am not able to read any data from the device. Here is the results of what I have tried in the terminal interpreter.

>>> import serial
>>> ELM327 = serial.Serial('/dev/serial/by-id/usb-1a86_USB2.0-Serial-if00-port0', 38400, timeout=5)
>>> ELM327.write(b'AT Z\r\n')
6
>>> ELM327.read()
b''
>>> ELM327.write(b'AT RV\r\n');
7
>>> ELM327.read()
b''
>>> ELM327.write(b'AT\r\n');
4
>>> ELM327.read()
b''

I have tried the same by changing the device to /dev/ttyUSB0 but get exactly the same results. I am running this as the super user as well. I also tried swapping out the \r\n with just \r and \n respectively. It is a ELM327 v1.5a device I'm trying to connect to. Any insight is much appreciated.

Upvotes: 1

Views: 344

Answers (1)

DrMickeyLauer
DrMickeyLauer

Reputation: 4684

This looks like you are not using the correct bitrate. You are sending the correct commands (although I'd skip the spaces and the \n), but the device is obviously not correctly receiving them otherwise it would have ECHOed them to you.

Upvotes: 0

Related Questions