Page 1 of 3 123 LastLast
Results 1 to 10 of 25

Thread: OBD2 ELM 327 VB.NET code wanted

  1. #1
    Low Bitrate
    Join Date
    Aug 2010
    Posts
    68

    OBD2 ELM 327 VB.NET code wanted

    Hi guys,

    I have an ELM327 bluetooth reader which is currently working fine with almost every program in the market, Digimoto, Pcmscan, OBDgauge for mobile, Racechrono and other.. I would like to make a program myself in order to customize it right for my needs. What I'm searching for is some sample code for VB.NET in order to initialize, send and receive data from and to the OBD scanner. I also used some code from the internet on VB6 but the computer crashes on bsod when it sends the ate0 command to the OBD reader. The computer and the reader are connected via COM5. Any ideas? Any code available? I've found some code on the net for .net but it is not working. The car's protocol is ISO, not CAN if this helps.

    Thank you

  2. #2

  3. #3
    Low Bitrate
    Join Date
    Aug 2010
    Posts
    68
    Thank you for your reply.. Unfortunately this is the code I've tried but it does nothing, the ELM327 won't reply at all although I'm using the same port as digimoto etc..

  4. #4
    SuperMod - OBDII GPS Logger forum
    Auto Apps:loading...

    Join Date
    Mar 2009
    Location
    Los Angeles
    Posts
    924
    Have you tried doing this stuff manually first? The ELM327 datasheet and PuTTY are enough to let you try stuff out by hand, and it's always good to try that before committing it to code.

    Gary (-;
    OBDGPSLogger, for logging OBDII and/or GPS data
    OBDSim, an OBDII/ELM327 software simulator
    mp3car forums: obdgpslogger, obdsim

  5. #5

  6. #6
    Low Bitrate
    Join Date
    Aug 2010
    Posts
    68
    Guys I finally managed to make it work! The only thing changed was the .Readexisting commang of the serial port instead of Readline that obd-example sample code had.. And it is working!

    One thing I noticed is that you have to stall your code a lil bit in order for the ELM to take its time and response, so I'll have to add a timer for that as well..

    PPE, is that API for free or you need money? how much?

  7. #7
    North of the land of Hey Huns
    Auto Apps:loading...

    Join Date
    Jun 2004
    Location
    Westminster, MD
    Posts
    2,127
    Nitroking: the best way to do it is to keep reading until you receive a '>' from the ELM since all messages should end with that. That way you get messages as fast as possible, as with a timer it could take longer than it really needs to.
    "stop with the REINSTALLS, what do you think we got some lame-o installer!!!" - mitchjs
    RevFE
    My Shop

  8. #8
    Low Bitrate
    Join Date
    Aug 2010
    Posts
    68
    This is a great tip, thanks Malcom! I'll give it a try..

  9. #9
    VENDOR - ScanTool Vitaliy's Avatar
    Join Date
    Dec 2006
    Location
    Phoenix, AZ
    Posts
    624
    Quote Originally Posted by Nitroking View Post
    This is a great tip, thanks Malcom! I'll give it a try..
    Adding a timeout is a good idea too, since you'll find that occasionally your device will swallow random bytes out of the data stream. It's one of the "features" of the Chinese ELM327 Bluetooth clones.

    Vitaliy
    OBDLink MX: world's smallest, fastest, most advanced OBD/Bluetooth adapter with SW and MS CAN support. Read the review to learn more.
    Need to look up a diagnostic trouble code? Try the most up-to-date, free DTCsearch.com!

    You cannot send me a private message using this forum. Use my email instead: vitaliy[@]scantool.net.

  10. #10
    Low Bitrate
    Join Date
    Aug 2010
    Posts
    68
    That's true.. But I've noticed that if I stall the code for 300ms it is working fine.. Most of the problems with the data occur while the car is warming up from ice cold. Then the ELM327 returns the PID no, eg. 010C and nothing else, only what YOU send to it but no bytes. After 2 minutes or so it's working flawlessly. One of my other checks will be to check the length of the str returned, if it is 13 or 16 (depending on the query) then proceed to transformation, else retry.

    Malcom, how can I read until I find the > character? Can I do serialport.readexisting more than one time? How? The _datareceived event is called by the .write method so how can I read inside the _datareceived procedure as much as I want? I think that once the .readexisting has answered that's all you get, if you are not patient you loose. That's why I use the 300ms delay, System.Threading.Thread.Sleep(300) (no timer finally) which has proved to be reliable enough and so I can get 3 responses/sec average which I'm happy with.

    By the way, where can I find the original ELM327 datasheet?

    Cheers

Page 1 of 3 123 LastLast

Similar Threads

  1. Problem Connecting to ELM 327
    By Scoop in forum CF Bug Reports
    Replies: 6
    Last Post: 06-13-2010, 06:36 AM
  2. Replies: 70
    Last Post: 10-15-2007, 06:21 PM
  3. All I wanted to know about OBD2 (programming) but was afraid to ask
    By It's A Honda in forum Engine Management, OBD-II, Engine Diagnostics, etc.
    Replies: 2
    Last Post: 12-03-2006, 06:35 PM
  4. How do I use the Base plugin sources ?
    By guino in forum RR FAQ
    Replies: 1
    Last Post: 04-24-2006, 04:43 PM
  5. GPS code for RR wanted
    By FiGu in forum Road Runner
    Replies: 5
    Last Post: 04-05-2006, 05:59 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •