3

I'm attempting to connect via node.js to an ELM327 Bluetooth OBD-II adapter using Eric Smekens node-bluetooth-obd package, but I'm getting an error I'm not sure how to debug. I am doing this on a Beagle Bone Black running Ubuntu. I'm able to pair with the device using bluez-simple-agent:

sudo bluez-simple-agent hci0 00:0D:18:A0:4E:35

And I've updated the MAC address in the second line of the Readme.md example to match the MAC address of the device:

var btOBDReader = new OBDReader('00:0D:18:A0:4E:35', 14);

However, when I run the script, I get this error:

Error with OBD-II device: Error: Cannot connect

I'm still pretty new with bluetooth comms, so I don't really know where to start debugging this. Any suggestions?

Community
  • 1
  • 1
tomgersic
  • 401
  • 6
  • 12
  • So you paired the devices? Might be worth trying that your bluetooth connection works. Try to connect to the device using a terminal, using sudo rfcomm connect (exact usage can be find here: http://manpages.ubuntu.com/manpages/lucid/man1/rfcomm.1.html). Maybe you have to bind your bluetooth connection to a serial connection first. If you are able to connect in terminal, let me know. – Eric Smekens Oct 01 '13 at 06:58
  • @EricSmekens Hmm, you seem to be right. I thought bluez-simple-agent was doing the pairing, but rfcomm keeps returning "Can't connect RFCOMM socket: Invalid exchange" initially, and then "Can't connect RFCOMM socket: Connection refused". I have a feeling it's failing on PIN, but I can't seem to find a way to get it to either prompt for a PIN or to use a PIN stored somewhere else. Have tried adding a PIN code under /var/lib/bluetoooth/ as specified [here](http://forums.gentoo.org/viewtopic-t-797762-start-0.html). – tomgersic Oct 03 '13 at 01:52
  • Are you running Ubuntu Server or the GUI version? In the gui-version it is fairly easy to pair, and if PIN is required, it will show up. (Atleast in my cases). Never had problems with pairing, but I know I was required to bind the adapter to a channel that was not already taken. You can use hcitool dev and hcitool scan to find MAC of your own bt-device and bt-devices near. http://forums.gentoo.org/viewtopic-t-797762-start-0.html Last step shows how that can be done in file, but I always did use rfcomm bind command. (Previous comment-link). Please let me know if you have some progession! – Eric Smekens Oct 03 '13 at 06:15
  • @EricSmekens I've finally been able to get everything working. Used a Raspberry Pi instead of the Beaglebone Black, which seemed to pair better with the OBDII device. I am still having one problem, though. Certain queries work great, like "rpm" and "requestdtc", but others, like "vin" and "temp" return just "{}". Also, if I try to combine multiple addPollers, as you have in the example, all I'll get back is "{}", but if I do one at a time, I get a good response, like { mode: '41', pid: '0C', name: 'rpm', value: 706 }. Any idea why some work and others don't? – tomgersic Oct 21 '13 at 00:45
  • It could be that your car doesn't support those requests. VIN is very experimental in my module, and that could use some work and testing. Temperature should work however, I'm going to look into this, but I can't test it with hardware at the moment. – Eric Smekens Oct 21 '13 at 06:45
  • Thanks @EricSmekens one other interesting thing I've noticed is that sometimes the RPM query works great, but other times I get an empty response from the same query. – tomgersic Oct 24 '13 at 16:49
  • Sounds like it's a problem with timing in that case. Would love to debug it, but I kinda regret the fact I don't have much time to work on this OBD-II library. Maybe, later on, I will try this on my Raspberry Pi too, but I really can't promise anything. – Eric Smekens Oct 25 '13 at 06:26
  • @EricSmekens Yeah, it turned out that it was a problem with timing. Changing writeDelay to a larger value seemed to help a lot. Would probably make sense to wait for '>' after each write operation rather than just having a delay. – tomgersic Nov 10 '13 at 17:32
  • Yeah, might be an option. Will not work when disable echo'ing etc. But if you have modifications or more ideas about the node-packages, you're welcome to make issues dor PR on github. – Eric Smekens Nov 10 '13 at 17:50

0 Answers0