HarleyDroid icon indicating copy to clipboard operation
HarleyDroid copied to clipboard

Not connecting to elm327

Open yoyo2k opened this issue 10 years ago • 24 comments

Hello,

Just built the cable as per wiki, and it never connects to the ODB interface.

The ELM327 works in my car w. Torque app, but not on my 2011 Sportster 883R.

Any ideas on how I could fix this?

PS: The Android phone is an up to date HTC One

yoyo2k avatar Aug 07 '14 10:08 yoyo2k

Is your bike turned on ?

Maybe your cable is bad. Please double-check the schematics and verify that the cable is ok.

Then, connect your ELM327 to a PC (Linux is better but Windows will work too), and use a terminal emulator (like minicom on Linux, hyperterminal on Windows, configure it to communicate at 115200 bps 8N1) and issue the following commands by hand one after another. For each command, when you press <Enter> the ELM327 should reply with OK:

ATZ ATE1 ATH1 ATAL ATS0 ATSP2

The last command to send is ATMA (followed by <Enter> of course, which will cause your ELM327 to enter 'monitor' mode, in which it will display all the packets seen on the bus. And you will have many many packets shown (assuming your bike is ON !).

Let's see if this does work.

stelian42 avatar Aug 08 '14 08:08 stelian42

Works like a charm. Also in my car with Torque app.

After sending ATMA command.. alot of numbers appear :). Also, the green and yellow leds are flashing on the elm327 when connected to my computer, which they don’t when trying to connect with Harley Droid.

In settings, I’ve set the interface type to elm327, set to the correct BT obd2 device.

yoyo2k avatar Aug 08 '14 09:08 yoyo2k

Ok, so the cable is OK, the ELM327 is OK, the android phone is OK.

This leaves only HarleyDroid, but I have no idea why it won't work. Do you have any HarleyDroid logs in logcat ?

If you know how to build Android applications using Eclipse you can download the code and activate debug in ELM327Interface.java. Otherwise I can build the apk for you.

stelian42 avatar Aug 08 '14 09:08 stelian42

PS: My Harley Droid version is the one from Google Play (maybe it helps)

yoyo2k avatar Aug 08 '14 09:08 yoyo2k

The Google Play version is the same as the one in git.

stelian42 avatar Aug 08 '14 09:08 stelian42

I’ll install alogcat and get back with a log Could please build one as I don’t have an android build env.

yoyo2k avatar Aug 08 '14 09:08 yoyo2k

Could please build one as I don’t have an android build env.

APK sent by mail.

stelian42 avatar Aug 08 '14 10:08 stelian42

Also make sure that Torque is not on or running in the background or trying to grab the ELM327. Check the settings. It might be trying to reset it for your car. Another way is to find a bluetooth simple terminal program so you can issue the commands ATZ... ATMA on the phone and see if it can connect - if it can't connect, it might be something else grabbing bluetooth. This will also insure you are paired properly.

tz1 avatar Aug 08 '14 13:08 tz1

I don’t have torque running, and those commands work on my mac.. and if torque can use the eml327 then there is no issue with either pairing or serial connection.

Any suggestions of such an app that I can install on my phone and do as I did on my computer?

yoyo2k avatar Aug 08 '14 14:08 yoyo2k

After running the new apk from Stelian w. debugging I get Error configuring ELM327

yoyo2k avatar Aug 08 '14 14:08 yoyo2k

https://play.google.com/store/search?q=bluetooth%20terminal&c=apps I've used sena and the "bluetooth terminal" apps (there are three, but all do the same job).

tz1 avatar Aug 09 '14 02:08 tz1

Ok.. more notes..

I installed Bluetooth terminal and while I cannot see on the screen the replies I can see a led on the elm light up so the command gets sent. Which is not the case for Harley droid, although I managed to connect twice ( I don't know how it managed to connect, I just kept pressing the connect button ).

yoyo2k avatar Aug 09 '14 16:08 yoyo2k

PS: as far as I can see there's no rule of thumb for connecting Harley droid, just by luck it sent commands to the elm.

yoyo2k avatar Aug 09 '14 16:08 yoyo2k

From what I see in your logs, HarleyDroid connects fine to the ELM327, sends the first "AT", and gets no response. The timeout then expires and the connection is closed. This seems to be consistent with what you see in the Bluetooth terminal.

On the other hand, the logs you send are quite verbose on the Bluetooth side, I wonder if there isn't another service which uses the Bluetooth at the same time. Maybe you have other Bluetooth devices and application installed ?

You are also the first user reporting such an issue, I really think this is related to your setup. I suggest you first try to make the Bluetooth terminal work first (connect, send "AT", expect "OK"). As long as this will not work in the Bluetooth terminal there is no way HarleyDroid will.

You can try reporting this to the Android developers (bugzilla or mailing list), maybe the logs will help them find the issue.

stelian42 avatar Aug 11 '14 09:08 stelian42

Yeah, I know it’s something weird with my setup, but any other obd app lights the elm327 like a christmas tree.

As tz pointed out I tried with SENA (the app didn’t work for me) and Bluetooth Terminal (Worked but no echoes - elm leds flickering). I found another app obdelm327 (https://github.com/takyonxxx/ECU-Obd-Elm327-Bluetooth/) that has ability to send commands and it worked, as soon as I entered the ATMA command, the leds on the elm started flickering (no echoes because it cannot decode HDLAN).

I’m open to suggestions.

yoyo2k avatar Aug 11 '14 11:08 yoyo2k

I see that obdelm327 uses createRfcommSocketToServiceRecord() in order to open the Bluetooth connection, whereas HarleyDroid uses createRfCommSocket() (createRfcommSocketToServiceRecord() was (is ???) unreliable on some phones). Could this be the problem.

I am building a new apk using createRfcommSocketToServiceRecord() and will send it to you privately to test.

stelian42 avatar Aug 11 '14 12:08 stelian42

like this? …. try { tmp = device.createRfcommSocketToServiceRecord(SPP_UUID); //Method m = device.getClass().getMethod("createRfcommSocket", new Class[] { int.class }); //mSock = (BluetoothSocket) m.invoke(device, 1); } catch (Exception e) { Log.e(TAG, "create bluetooth socket: "+ e); throw new IOException("createRfcommSocket() failed"); } ….

already tried. But it is connecting, but timesout at the first AT command (the connection gets closed somehow)

yoyo2k avatar Aug 11 '14 12:08 yoyo2k

This was indeed what I was suggesting. Other than the different connection method, the write() is done in the same manner. The read() is done differently (obdelm327 does raw read() on the input stream while I use a BufferedReader(). Maybe you should try modifying HarleyDroid to do raw reads instead, and see if the reply from the ELM327 comes through.

stelian42 avatar Aug 11 '14 12:08 stelian42

Honestly I don't think it's that because there's no activity on the elm's leds.

Recap. The socket is created and connected to the correct device. But something happens right when the first AT command gets sent and times out and the socket is closed.

I re-implemented today the BT connection and tomorrow I 'll implement a new J1850interface to go with it and see what happens.

It's my first time doing something for Android so it takes a little longer..

yoyo2k avatar Aug 11 '14 18:08 yoyo2k

You've got an itch to scratch ! Go ahead and take your time ! :)

On Mon, Aug 11, 2014 at 11:19:05AM -0700, yoyo2k wrote:

Honestly I don't think it's that because there's no activity on the elm's leds.

Recap. The socket is created and connected to the correct device. But something happens right when the first AT command gets sent and times out and the socket is closed.

I re-implemented today the BT connection and tomorrow I 'll implement a new J1850interface to go with it and see what happens.

It's my first time doing something for Android so it takes a little longer..


Reply to this email directly or view it on GitHub: https://github.com/stelian42/HarleyDroid/issues/7#issuecomment-51819114

Stelian Pop [email protected]

stelian42 avatar Aug 11 '14 19:08 stelian42

Finally... after sifting through tons of logs and running between the bike and the computer I finally saw the timeout given after the first command was sent. There's no reply and when an exception is raised by readLine the connect thread catches it and closes the connection.

Why is an AT command given instead of ATZ?

PS: Thanks for your help

yoyo2k avatar Aug 13 '14 12:08 yoyo2k

Though I don't know if help, I have 2 different ELM327 adapter, one works well, the other doesn't , they talk like this;

good one(I started the app while running): 20140810151540704,RAW,>ATMA,,, 20140810151540705,CRC,>ATMA,,, 20140810151540713,RAW,281B100217D888,,, 20140810151540718,RPM,1526,,, 20140810151540775,RAW,4829100217046F,,, 20140810151540776,SPD,46,,, 20140810151540785,RAW,281B100217B480,,, 20140810151540787,RPM,1517,,, 20140810151540817,RAW,A83B10032087,,, 20140810151540819,GER,5,,, 20140810151540826,RAW,A883611200F9,,, 20140810151540842,RAW,281B100217ECB6,,, 20140810151540843,RPM,1531,,, 20140810151540906,RAW,4829100216BF80,,,

bad one: 20140810171557495,RAW,>ATMA,,, 20140810171557497,CRC,>ATMA,,, 20140810171557537,RAW,281B10020000D5,,, 20140810171557543,RAW,A883611200F9,,, 20140810171557610,RAW,281B10020000D5,,, 20140810171557647,RAW,281B10020000D5,,, 20140810171557683,RAW,68FF4003D8,,, 20140810171557687,UNK,68FF4003D8,,, 20140810171557745,RAW,281B10020000D5,,, 20140810171557812,RAW,281B10020000D5,,, 20140810171557817,RAW,A83B10030000,,, 20140810171557880,RAW,281B10020000D5,,, 20140810171557944,RAW,281B10020000D5,,, 20140810171558006,RAW,281B10020000D5,,, 20140810171558017,RAW,281B10020000D5,,, 20140810171558023,RAW,6888100344,,, 20140810171558032,RAW,C888100EBA,,, 20140810171558034,UNK,C888100EBA,,,

What I could do next?

kazuoa avatar Aug 19 '14 13:08 kazuoa

Hi, sorry for the delay.

Your patch seem ok, shouldn't harm the setups which were already working.

Thanks for investigating into this.

Stelian Pop [email protected]

stelian42 avatar Aug 21 '14 21:08 stelian42

Hi,

On Tue, Aug 19, 2014 at 06:03:16AM -0700, kazuoa wrote:

Though I don't know if help, I have 2 different ELM327 adapter, one works well, the other doesn't , they talk like this;

bad one: [...] 20140810171557537,RAW,281B10020000D5,,,

This seems to be OK, its meaning is 'RPM = 0'. You should normally have a 'RPM,0' line following the RAW line...

Stelian Pop [email protected]

stelian42 avatar Aug 21 '14 21:08 stelian42