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 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..
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.
You can use ScanXL Professional and our OBDNet API to control the data logging engine and stream the data straight into your VB.NET application. This streaming works on the same computer or even across the internet. If you would like more information about our OBDNet API, please contact [email protected].
Brian @ Palmer Performance Engineering, Inc.
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?
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
This is a great tip, thanks Malcom! I'll give it a try..
— 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.
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?