A huge update:
It´s nearly done! There´ve been several challenges, but it finally works 
Hardware:
- Arduino Nano
- HC-06 Bluetooth
- L9637D
- Ceramic-Capacitor 10 nF 50 V/DC
- 510Ohm Resistor
Also several different displays, to test. At least I´ve ordered a 128x64 OLED from AdaFruit 0,98".
There are a lot of wiring schematics around. But it´s only important to connect Rx to Rx and Tx to Tx (not twisted!) and use a pullup-resistor to the K-Line (connect K-line with VIN from diagnostic by ~510-550Ohm)
Important: Unconnect Rx if you want to upload your Sketch!
Software:
This has to be splitted into several smaller pieces of work.
AT-Commands
OBD II compatible Bluetooth dongles all work with a ELM327 chip (or a china-clone).
This adapters are used by AT-Commands, which setup the communication protocol. Afterwards the Protocol ID´s were submitted in Hex-values as text.
The cmd´s begin with "AT" + command [+ Value] + '\r'
ATL0\r
- means tunrning Linefeed (\n - 10) off (That does NOT mean, turn CarriageRetrurn | \r - 13 off)!
You have to return: OK\r>\r
The >
is a prompt, which completes a command-set. Exceptions where: Unknown Cmds ?
or Device Info.
Important for my Action Cam: The answer to ATZ
(Reset) must contain the Version. F.e. "ELM327 v1.4". Otherwise the cam will not proceed.
D |
Set to default (Header = false, spaces = false, ect) |
Z |
Reset Device |
H0 / 1 |
turn Header on or off |
I |
Device Info (ELM Version) |
SP |
Protocol Auto |
S0 / 1 |
turn spaces on or off |
L0 / 1 |
turn linefeed on or off |
E0 / 1 |
turn Echo on or off |
M0 / 1 |
use memory (store last CMD) |
PID Lists:
There are every 32 bits lists of the following 32 specified bits:
Request |
Response |
0100 |
4100181B8001 |
0102 |
412000000001 |
0104 |
414008000000 |
0106 |
416000000000 |
0108 |
418000000000 |
The response is not completed with OK
. Only newline and Prompt (>)!
What does it mean?
Take all PID´s from 01 - 20 (32pcs). 00 is reserved for the first PID-List, 20 is the next one.
Now convert the response from 00-request to bits:
181B8001 (ignore 41 [Response is valid] and 00 [Request])
00000100000011000000
Now you can lay it over your PID-list and see which PID is valid 1
or not supported 0
.
My personal challenge was to translate the OBD2 PID´s to the appropriate KDS PID (Kawasaki Diagnostic System). And afterwards to calculate the response to the required format.
Sending Data:
Now you will receive the register and can put the answer through. (Torque-App will ignore the valid PID´s and you will have to return "NO DATA
", Garmin Virb-Cam suits to the valid values)
01
(Show current data) + 0C
(PID) + \r
[sometimes a space only. Don´t really know why]
Remember to answer properly:
41XXYY\r>\r
XX-Requested PID, YY-Value (can also be longer)
ECU-Communication:
Now one of the most interesting part!
I´ve made usage of a code from Tom Mitchell (Kawaduino)
You can get it from BitBucket and see the result on YouTube.
The most important parts are the FastInit()-Function to start communication and diagnostic mode.
And the sendRequest()-Method to create & send the request and receive the response, unpack it and check the checksum.
Conclusion:
It was a hard way to get the hardware work (wrong Bluetooth-module, broken E-L9637D, Pulldown instead of Pullup resistor...).
The software was also very time consuming. To check the Arduino Sketch, I created a ECU-Emulator in C#. It answers requests with configurable responses.
Then I created a Bluetooth-Sniffer to receive what kind of information the Camera or Torque-App requests and how I have to respond.
At least I made a ECU-Sniffer, which requests all supported PIDs from my motorcycle.
When it all worked, the next task was to find out which PID correspond to which sensor. The ECU-Hacking Board (link in my second post) just got knowledge of Speed, RPM, Temp, Battery and Gear. By try and error and some help from a guy with a diagnostic device, I was able to find out about 33 known PIDs. Another 27 are still open.
My further investigations are to find out some calculations, how to use throttle or throttle valve.
After that, I´d like to upload all my code to GitHub. Including:
- ECU-Emulator (Windows Application)
- ECU-Sniffer (Sketch)
- Bluetooth-Sniffer (Sketch)
- ECU-Reader (Sketch) -> The result
- Valid PID-List with formula, etc. (Excel Sheet)
As you can see in the attached pictures:
The finished Arduino Nano:
Test on my bike:
ECU-Emulator with Ardu connected:
My first ride
(
Garmin Virb XE Action-Cam)