Hello, im from spain, so, excuse my english.
I'm a computing student.
I'm trying to replicate your app in AppInventor about OBD2 app. So, i have so many questions.
How you did it? I have no idea about programming in Appinventor, i need a bit of help.
How you toke the variables that output from the ELM and you translate it as other variables in your program. Thank you.

Hello Javier,
no problem for the English, because I'm Italian, so I'm not of mother tongue either :slight_smile:
First of all, if you are not familiar with AI2, I suggest you to start with a simpler application.
Anyway, let's see if I can help you a bit.
The ELM is a customized microprocessor that implements various diagnostic protocols, based on the CAN low speed (Controller Area Network @250 kbaud), so to be interfaced with a certain number of Electronic Control Units (ECU) on board of vehicles. The commands to the ELM are sent in a modem-like messaging system, in other words with AT messages sent by the app by means of a Bluetooth link (not BLE!).
The ELM that I've used is embedded into an off-the-shelf (commercial) EOBDII interface that you can buy on the web with prices ranging from 4 to 15 Euro. The web is plenty of them.
If you have already one, or if you buy one, the first thing is to download from the playstore the app Torque (free) so to verify if the ELM works well with your vehicle. That is: if the protocol of your vehicle is within those included in the ELM capability (typically the KWP 2000 or the UDS). If Torque is not capable to connect your vehicle, it could be possible that your vehicle is too old or too recent and the protocol it uses isn't included in those that the ELM understands. In such a case things can become very hard ... :frowning_face:
Having verified that, the next step is to understand which is the initialization procedure (the sequence of CAN commands that are entering the diagnostic protocol of the ECU that you want to interface) of your car.
For example: if you want to create a digital dashbord, like I did, the ECU to interface is the Engine Control Unit, from which you can obtain speed, RPM, coolant temperature, and many others.
Typically the initialization sequence is proprietary of the car maker (the vehicle brand: Peugeot, Renault, FIAT, VW, etc. etc.) so it is not easy to find on the standard literature, by googling the web.
To overcome this I made a "sniffer" by using two HC05 Arduino shields: I did put these two HC05 in between the ELM and Torque so I've been capable to steal the messages between Torque and the ECU of my car, and I stored the sequence of messages on a PC. Then it has been just a matter of replicating that sequence to simulate the Torque behaviour, entering the diagnostic protocol.
Once entered, cyclically (approx every 250 milliseconds) I send simple commands to get the desired data from the engine ECU. The commands understood by the ECU are called "services". The list of services for the KWP2000 is in the attached file. But please be aware that not all the services are implemented by all vehicles. Most probably the very "basic" ones are always implemented, like speed, RPM, load, temperature....but not all the hundreds of services in the list.
OBD_PIDs.pdf (723.5 KB)
ELM327DS.pdf (452.7 KB)

At the very end: I don't want to scare you, but this is not the simplest application from which you can start...because it is mixing the BT interface, the use of clocks to synchronize various activities between the app and the Tx and the Rx toward the ELM, the knowledge of the CAN diagnostic protocols (this is the most difficult, due to lack of information available, free and open), the knowledge on how to use of the ELM327, ..

Let's say: if you plan to come to Torino, I'll be glad to spend a (complete) day with you sitting side by side showing you what I did in detail (hoping that one day is enough !!!)

Hola y buenas noches.Ugo.

PS in my original post there are already many details about the "sniffer" and the AT messages. Have you already got a sight on it ?
.OBDII CANBUS interface

Ciao, ciao.


Ty vey much abou the information the reason of the hurry is because i have to do a final work to one course and i have just 1 month. So if you dont care i wanna to use the base of your app, but i would want to personalizate it, the problem is that i dont understand anything of the code and blocks that you use. And the other problem, to test your app, i just need your app and the elm right?
If it is like that i will work over your app, well, probably under your app... haha. But when you put in a block for example: when B_ATS0. click do call ATS0send. What does this block means, and their variables. Do i explain myself? Ty again.
And i would be so gratefull to go Torino but I'm a bit away... haha. Ty.

Hola Javier,
sure, I was joking about your trip to Torino...

About your specific questions:
any of the buttons is intended to raise (send) a command to the ELM device connected to the EOBD port of a car.

The commands can be of configuration type (the AT commands) or of service request (PID).
The AT commands are used by the ELM to configure itself and to open the diagnostic session according to the protocol of the ECU being connected.

When the command is of service request type, the header of the message contains the identification of the CAN service (the PID). For example if you want to ask the Engine Control Unit to tell you the RPM, once correctly initialized, you have to send the command 010C (the PID):
With this PID you ask the Engine ECU to give you back the RPM value. 010C is the PID that on the CAN bus, protocol KWP2000, is interpreted as "give me the RPM value".
Once sent to the ELM 327 the command, it is forwarded by the ELM to the ECU, the ECU responds to the ELM, and the ELM sends back on the BT, to the app, the value.
To allow all this flow, a delay is needed: to this purpose the clock1 allows some time before expecting the answer. One received the answer the clock1 disables itself. (all this is explained into the pdf document that I sent you in my previous answer :-)); the variable CANcommand is used to distinguish if the command sent was of AT type or PID type.
Here below you can find the clock1 code, in which you can see what is used for : if the command is a PID type, the ECU, in the KWP2000 protocol, answers by setting the bit #6 of the high byte (i.e. OR 0x4000) that is: it responds with a 0x410C.On the contrary, if the message sent to the ELM was of AT type, is was interpreted as a command to the ELM itself and it is not sent by the ELM to the ECU (i.e. they are interpreted and the corresponding diagnostic sequence is sent autonomously by the ELM to the ECU).

After having sent the PID command and having received the answer, the received value is then scaled according to the KWP2000 rules (normalized). For example the RPM is received on two bytes and then the true RPM value is (high byte *256) + low byte
Last but not least, the answers to the AT command need a different timeout with respect to the PID ones, therefore a different TimeInterval is set (for clock1) whenever an AT or PID command is sent.

As you can see it can become a "neverending story" to explain all the details. Anyway, i suggest you yo read carefully the pdf that I annexec earlier and to buy a EOBDII interface on the web before spending so much time.
When selecting the EOBDII device, be careful to choose one which is compatible with your car. Typically the vendors also give a "compatibility table" in their announcements, so you can verify "a priori" if your car is connectable.

One step beyond.
Ciao, Ugo.

EDITED on 15 Jan
Dear Javier according to forum's general rules, would you mind to convert this "personal" mail exchange into a topic for the community ? If you agree I can ask a Power User to do that. So also other guys can take advantage of everything we are discussing.
Waiting your approval.
Buen finde.

1 Like

Hi, just two things, I have understood better than before about all around your app, now i will work and investigate about it, so ty, but i still asking with your app just like it is right now it will work in my phone with the elm and any of my car (Opel astra h, Renault Clio 3, Peugeot Partner, Audi a3)? Just exporting your app using it in my phone and conect de elmto the car? Will it work? if it not, What i have to do? Thanks you.
And of course, you are able to make publi this discussing, ty so much again.

If i can ask, in what car have you probed it?

Dear Javier,
I've implemented and tested on my Citroen Xsara Picasso.
And also a slightly modified version (the one implementing the digital cockpit) on a Peugeot 207 CC.

As I suggested in the previous posts, the first step, to "catch" the correct sequence that opens a diagnostic session and then be able to start a periodical query to your vehicle, is to buy an EOBDII - BT device, install on your phone the free app Torque Lite, and verify if that app is capable to interface your car (it should be with at least one of yours).
As you can easily understand, I cannot guarantee that the sequence of my cars (that I discovered by using the "sniffer") could work with someone of yours, but at least you can try with the sequence that automatically sends out my app, that is working with the Xsara, or the one indicated in the picture here below, that is working with the 207 CC.


Once you will have succeeded to connect your car, please be aware that the ECU (whichever: Engine, ABS, Clima, etc.) will cease the diagnostic session if it does not receive further commands within 5 seconds. Therefore, once successfully opened the diagnostic session, you will have to periodically send at least one command to which the ECU will respond and that will maintain open the session (Torque Lite, to this purpose, sends automatically a "live" message to the ECU).
Another hint is: you can use Tera Term connected via BT to the ELM device and you can send "manually" the commands of my sequences, so to verify 'at a glance' if they are recognized by your car. If so, you will see the answers of the ECU on TeraTerm terminal screen.

Lastly: thanks for allowing me to publish this post. I'll ask to a Power User to do it.
Buona suerte !!!
Ciao, Ugo.

Dear @Javier_Riopa_Rodrigu,
unfortunately the Power Users cannot make public what is a "direct" mail exchage, though done via MIT AI2.
The only one that can do it is you, as owner of the topic. The PU's suggested me that you open a topic on the matter with the contents of our exchanges.
Obviously it is not mandatory and if it is too complicated or it is too much time consuming, we can let it as it is. Probably I will be appointed to become a PU, therefore I will be enabled to do myself.
Anyway, I hope you can proceed in your project.
I have also another question: since this project is for your (school/university) course, has it been asked specifically by the professor or can you choose a different project ? In the second case, there is also another project that is a bit less complicated but it is anyway full of features, because it covers items related to Bluetooth, Arduino, SMS sending and receiving and IoT (internet of Things = home automation). It is under the community library as

Buona suerte para ti.
Ciao, Ugo.

I'm already working on the project, i will make it, or i will try, if i can't do this, i have another project on my that is enough to make the course away, but i want to do this.
I forgot answer to your last message because i have read it so much times and try to understand and make a investigation about all of concepts.
And i didnt understand you about make public this, are you saying that the admins can't?
I dont know how to make this public, you can do our conversation public if you want in the way you want, if you are able in any way.

Dear @Javier_Riopa_Rodrigu,
take it easy about the publication. We'll do at the end of the job.
Kind regards, Ugo.

When this topic is ready in your opinion, it should be added to

Given that you are in a hurry Javier, I strongly recommend that you reserve a day (8 hours or so) learning App Inventor. It would make life much easier for you.

See the Tips and Tricks page of my website:

Hello @Abraham,
I think we can still wait a while, 'till Javier gives us the answer on the status of his project, than we can add it to the FAQ.

Hello @Javier_Riopa_Rodrigu,
how things are going ? Do you need further info about this topic ?

Kind regards.

Hello, sorry for the late.
I appreciate so much your help, but for reasons of time, and knowledge, i wasn't able to put this on working. As i said, i had a project to safe me in case this would happen, so im free in this way.
It's so difficult because my teachers has no idea about anything of this world, and everything i know, thanks at you as much, it's not enought to make an app about this. So thanks you, again, i learned a lot really, but no time man, sorry.
Tnk you again, Bye!.

PD: If you want to publicate any of this conversations you are free!

1 Like

Dear @Javier_Riopa_Rodrigu,
ok then, best wishes for your school courses and projects.
Hasta luego !

1 Like