Bluetooth Connection Issue

I have an issue trying to connect a device via bluetooth to MIT App Inventor...

Basically, I'm making an application which allows me to read the veichle's informations. (oil temperature, tire pressure ecc...)

First of all, Im creating the application with MIT App Inventor, where I try to make a bluetooth connection between my phone and my device...Here I have the first problem, I made a "SCAN" button, so whenever I press it, it actually shows me the list of the nearest devices, but it doesnt allow me to connect to any of them.
Down below there is the "Block" that I made with app Inventor

After that I would really like to know how to receive data from CANBUS to App Inventor, then how to send them to a ThingSpeak server.

Thank you in advice!

Im kinda new into this "world", how do I open your project on app inventor?

If it's an .aia file, do a Project->Import aia file

Its a University project, this looks way complicated than mine should be... This may be the right one, but x1000 semplified

You should find a CANBUS project on the forum - but why send the data to ThingSpeak and not to your App? That's just an added complication?

With regards to Bluetooth, what version of Bluetooth is on:

  1. Your phone
  2. The device

Dear @Cryjaax,
I see that other PU's have already answered you about your topic.
The post that @ABG has linked is one of my old ones, relevant to a connection between an Android device and a "simple" OBD scantool that can be purchased on the web for a few Euros or Dollars (from 4 to 20, it makes nonsense to exceed that amount) via classic BT, not BLE.
All these devices are based on a microcontroller that has buried inside its memory various CANbus protocols, so to be able to connect the diagnostic line of a vehicle. This chip is 99,9% the ELM327. In my post you should find also some documentation about.

Typically the main ECU (Electronic Control Unit) that acts as a gateway towards other ECU's onboard is the Body Computer. Depending upon which data the ECU's network of the vehicle makes available (i.e. the active PID's), you can retrieve on the CANbus several information, like speed, RPM, H2O Temperature, throttle percentage, EGR activation, many others.
Each data is responded as an answer to a specific request: if you want to know the vehicle speed, you shall ask that information by sending to the ELM327 a specific sequence of bytes (characters) that implements the PID related to the Speed data. When the gateway ECU receives that request, it forwards this request to the ABS ECU or to the Engine ECU, and when (after few milliseconds) it receives the answer, it responds to the ELM which, on his turn, forwards the answer via BT to the Android device.
Before getting crazy with a lot of troubles, I suggest you to purchase this OBD scantool, fit it into the OBD port of your vehicle, download a free app from Google Playstore like Torque Lite (free), connect via BT this app to the scantool and verify that is capable to find the diagnostic protocol of your vehicle (there are many, and the ELM327 has already implemented the most common ones).
If all above works, then you are confident that the app that you will develop will be capable to interface the vehicle. Unless that, it's almost impossible that you can create on your own a device (hardware and software) that can interface the specific diagnostic protocol of your vehicle. I did it in the past, with an old convertible car of Renault but to do so I've "cloned" a professional OBD tool and this "nightmare" lasted more or less one year before succeeding.

Lastly, if the diagnostic protocol of your vehicle is the KWP2000 (you can discover it by using the scantool and Torque) by copying my app, you should be in degree to connect your vehicle and customize it to tour needs.
Best wishes.

2 Likes

How can I read my veichles informations, then send them to my MIT App Inventor Application?

Sorry, but I feel that you haven't read my answer.
i then repeat the core of my previous post:

Before getting crazy with a lot of troubles, I suggest you to purchase this OBD scantool, fit it into the OBD port of your vehicle, download a free app from Google Playstore like Torque Lite (free), connect via BT this app to the scantool and verify that is capable to find the diagnostic protocol of your vehicle (there are many, and the ELM327 has already implemented the most common ones).
*If all above works, then you are confident that the app that you will develop will be capable to interface the vehicle. Unless that, you can change your project

Only once you are done with that, you can go further and try to code an app that reads data from your vehicle.

My task here, is to make an application that shows, once connected via Bluetooth, a veichle's informations. Its a university project, which means that it is kinda an emulated project, we will not use a real car to test it, but an emulated system. I've never worked with MIT App Inventor before, although I can understand the logic of it, but I dont really know how it fully works. What I'm askin here, is where should I start, how should I do it, if you have any tips, would be very appreciated.

If you don't have a real vehicle, you shall start from knowing which protocol uses the simulator. Or also the simulator has to be designed ?
In such a case, you shall start by implement a device, most probably a PC with a BT comm's, on which a diagnostic protocol will run (i.e. the Keyword Protocol 2000, aka KWP2K). After you have implemented that, you shall code your app in order to interface such simulator.

But, since to implement a complete KWP2K is a true nightmare and since we already have an app capable of sending requests and of parsing the answers, (I mean my app in the post indicated by @ABG) you can do the opposite.
In other words: you can open my app, see what are the commands sent by my app to the ELM327 and simulate the answers by looking to the code blocks where I parse the responses to show the data.
For example to get the speed value from the simulator, the command is :

image
where 010D is the PID that in the KWP2K protocol corresponds to the Speed data request.
If the command is well understood be the car (in your system, the simulator), the answer that the simulator creates shall contain 410D + the data value.
The blocks that parse the answer form simulator shall look for the presence of "41", like the following:
image
So the simulator shall compose the answer with, for example, 410D0064 to answer to the request by telling 41 = request well understood ; 0D speed data identificator; 0 0high byte of speed; 64 low byte of speed (i.e. 100 Km/h) because the speed data is answered on 2 bytes in hexadecinal base, => 64 hex = 100 dec)
image
On the contrary, whether your professor asks for a complete KWP2K protocol, implementation it would be better to dig very deeply the web to try to find a ready made KWP2K simulator running on a PC rather then code it from scratch on the PC.

That is a great shame - the real world has a lot to offer you know.

1 Like