Git Product home page Git Product logo

aster94 / keyword-protocol-2000 Goto Github PK

View Code? Open in Web Editor NEW
227.0 42.0 59.0 3.58 MB

The KWP2000 is a communications protocol used for on-board vehicle diagnostics systems (OBD) by Suzuki (SDS), Kawasaki (KDS), Yamaha (YDS), Honda (HDS) and possibly more. It is standardized by ISO 14230

License: GNU General Public License v3.0

C++ 83.40% C 7.01% Python 9.59%
suzuki kds yamaha ecu communication-protocol honda kawasaki obd

keyword-protocol-2000's Introduction

Keyword Protocol 2000

The KWP2000 is a communications protocol used for on-board vehicle diagnostics systems (OBD) by Suzuki (SDS), Kawasaki (KDS), Yamaha (YDS), Honda (HDS) and more. It is standardized by the ISO 14230 and it is compatible with the ISO 9141. Both uses a single line called the K-line through it we send some Parameter IDs, knowns as PIDs, to the Electronic Control Unit (ECU). This way we have total control on the motorbike: we are able to ask for sensors data (such as rpm, gear, speed, temperatures, etc.), see error codes and clear them, upload/download and more.

If you want to read more about this protocol and OBD-II you can see the protocol explained.

Projects

Check out these nice projects:

If you want to show your project make a pull request

Supported Hardware

Any microcontroller (MCU) that uses the Arduino framework could be used.

The K-line works at 12V so you need an integrated circuit (IC) as interface, for example:

  • L9637
  • MC33660
  • MC33199

Or, you can also use operational amplifiers/level shifter/transistors.

List of Vehicles

The library would work on Suzuki and Kawasaki motorbikes. I didn't had the possibility to test on Yamaha and Honda bikes but I am willing to do, if you own any one of the two open an issue and I will write some code for it.

This is a list of motorcycles that have been successfully tested:

Motorbike Year Tested
GSX-R600 2011 ✔️
Versys 650 2012 ✔️

If your motorbike is not in this list open an issue and tell me if the library worked 😁

Installation

Simply search for KWP2000 in the Arduino/PlatformIO Library Manager or download this repository and add it to your library folder

Usage

Hardware

You have to find the K-line of your bike. Usually it's under the rider's seat. You just need to connect the K-line, VCC and GND to the driver IC you bought

Example of the wiring for the L9636:

Alt text

Dealer Mode - Only for Suzuki:

If you wish also to be able to enter easily into this mode add an optocoupler with a ~330omh resistor between the MCU and the dealer pin

Alt text

Software

Go to PIDs.h and de-comment (delete the // symbols) your motorbike, then upload the basic_working example.

Development

I made a ECU Emulator written in python for the development of new functions and tests.

Documentation

Generally the functions return true if everything went fine, a negative number if there where any error, false if nothing changed

This documentation has been automatically generated with doxygen + doxylite, an automatic documentation generator, I will make the formatting nicer later.

See it here documentation

Disclaimer

I do not assume and hereby disclaim any liability to any party for any damage to propriety or person

Influence:

Donate

If you liked the library and wish to donate you can sent to PayPal

keyword-protocol-2000's People

Contributors

aster94 avatar per1234 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

keyword-protocol-2000's Issues

Not working with Yamaha YZF R125 Gen 1 (2008-2013)

I could not get this to work. I was hoping for this to work to broadcast ECU data on a race bike to a mobile laptimer app. I also tried commenting out the function configureKline() which stated maybe Yamaha and Honda should not run this in the comment. Any ideas?

Connecting with Yamaha ECU

Hello I am trying to connect to a Yamaha YXZ 1000R ECU but so far no success. Is there any way you can help me ?

Can't connect with M5Stack and Emulator

I'm trying to run basic_sample on M5Stack and something goes wrong when i try to connect with Emulator.
here is what i see:
Emulator
Starting ECU Emulator Port already opened Port Info: Serial<id=0x3de1e80, open=True>(port='COM7', baudrate=115200, bytesize=8, parity='O', stopbits=1, timeout=2, xonxoff=False, rtscts=False, dsrdtr=False) You should send me the init sequence! not this: ['0x0', '0x0', '0x0', '0x0', '0x0']
Debug
`
User Input: i

Initialize K-line
Starting sequence

Sending Echo
81
FD
11
F1
ED
81
4

Receiving:
2D - unexpected header
FF - ECU is communicating with this address
Unexpected response: Initialization failed
`

It cannot be compiled,it shows error: 'Serial3' was not declared in this scope...etc

I didn't modify your source code, I installed direct compilation from Arduino library, and then I got an error.
I looked for relevant information on the Internet. They said that the selected development board model may be wrong.
My software and hardware environment is Arduino: 1.8.19 (Windows 10), development board: "Arduino Leonardo".
I'm wondering what development board do you use.
Look forward to your reply.

Here is the Error Output
`
Arduino: 1.8.19 (Windows 10), development board: "Arduino Leonardo"
basic_ working:12:14: error: 'Serial3' was not declared in this scope
#define bike Serial3
^
C:\Users\Administrator\Desktop\Keyword-Protocol-2000-master\examples\basic_ working\basic_ working. ino:19:14: note: in expansion of macro 'bike'
KWP2000 ECU(&bike, TX_PIN, YOUR_MOTORBIKE);
^~~~
C:\Users\Administrator\Desktop\Keyword-Protocol-2000-master\examples\basic_ working\basic_ working. ino:12:14: note: suggested alternative: 'Serial'
#define bike Serial3
^
C:\Users\Administrator\Desktop\Keyword-Protocol-2000-master\examples\basic_ working\basic_ working. ino:19:14: note: in expansion of macro 'bike'
KWP2000 ECU(&bike, TX_PIN, YOUR_MOTORBIKE);
^~~~
basic_ working:19:28: error: 'YOUR_ MOTORBIKE' was not declared in this scope
KWP2000 ECU(&bike, TX_PIN, YOUR_MOTORBIKE);
^~~~~~~~~~~~~~
C:\Users\Administrator\Desktop\Keyword-Protocol-2000-master\examples\basic_ working\basic_ working. ino: In function 'void setup()':
basic_ working:23:56: error: no matching function for call to 'KWP2000::enableDebug(Serial_, debug_enum, long int)'
ECU. enableDebug(&debug, DEBUG_LEVEL_VERBOSE, 115200);
^
In file included from C:\Users\Administrator\Desktop\Keyword-Protocol-2000-master\examples\basic_ working\basic_ working. ino:2:0:
C:\Users\Administrator\Documents\Arduino\libraries\KWP2000\src/KWP2000. h:83:8: note: candidate: void KWP2000::enableDebug(HardwareSerial
, uint8_t, uint32_t)
void enableDebug(HardwareSerial debug_serial, const uint8_t debug_level = DEBUG_LEVEL_DEFAULT, const uint32_t debug_baudrate = 115200);
^~~~~~~~~~~
C:\Users\Administrator\Documents\Arduino\libraries\KWP2000\src/KWP2000. h:83:8: note: no known conversion for argument 1 from 'Serial_
' to 'HardwareSerial*'
exit status 1
'Serial3' was not declared in this scope

Open in file - > Preferences
Show detailed output during compilation option
This report will contain more information.
`

Ecu Emulator

Can you please give a small description of how to use the ECU emulator, do I need to use a null-modem cable to connect to it?

Can it be used in cars?

Hi
My car is Suzuki, which uses K-line to obtain diagnostic data. Can this library only work on motorbike? Are the PID commands of cars and motorbike compatible?
There is another question. For the hardware diagram, is the VCC powered from the 16 pin of the OBD? Why should the K-line and the VCC be connected together?
l9637_wiring

Masalah Honda Keihin k-line dengan pyserial

hai,Ingin membaca sepeda motor saya menggunakan Pyserial ,tetapi ada masalah dengan Pyserial , kenapa data tidak Keluar , Code perintah untuk membaca table telah benar namun jika saya membuka HondaECU dan menjalankan promgram saya kembali data itu mau untuk Tampil tetapi jika saya mematikan kontak dan menghidupan kontak ,data tidak akan mau keluar sebelum saya membuka HondaECU dan menjalankan program saya kembali ,apakah kamu bisa membantu ku ?ini Code yang saya gunakan

ser = serial.Serial('COM5',10400,timeout=0.1)
while True:
request = 'FE 04 72 8C'
ser.write(bytes.fromhex(request))
print(f"Request: [{request.replace(' ', ', ')}]")
time.sleep(0,2)
request = '72 05 00 F0 99'
ser.write(bytes.fromhex(request))
print(f"Request: [{request.replace(' ', ', ')}]")
request = '72 05 71 17 01'# Table 17
RPM= response_hex[18:22]
response_dec = int(RPM, 16)
ser.write(bytes.fromhex(request))
print(f"Request: [{request.replace(' ', ', ')}]")

ini sebagai contoh code yang saya gunakan,saya menggunakan baudrate 10400 rekomendasi dari situs/forum yang saya baca , sepeda motor saya menggunakan table 17 dan itu sudah pasti ,mohon maaf jika ada perkataan saya yang tidak mengenakkan sekian trimakasih

Doubt

Capacitor is 100nanoF?

Not Working for Honda

Hi,
I'm trying to getting this code working. I started to define Honda. but i get an error that i can't build the solution. You described that Honda is the same as Yamaha. so i tried that.
The build works, but i can't get connected.

so i looked what's differents between Honda and Yamaha.

I've seen that there are typo's in YAMAHA and it sometimes spells YAMAYA.
so for Yamaha it doe not get in the:

`#elif defined(YAMAHA)

handleRequest(request_sens, LEN(request_sens));`

And there is (i think) a problem. Request_sens is not declared. and when i declared it:

`#if defined(HONDA)
#if defined(BIKE_CHOOSED)
#error "two or more bikes choosed, please see src/PIDs.h"
#else
#define BIKE_CHOOSED
#endif // BIKE_CHOOSED
// see above
#endif // HONDA

const uint8_t request_sens[] = {0x80,0x02}
`
everything els fails to build the solution.

i got it connected correctly with some test scripts. And get some of a response.
can you help me out?
tnx stefan

Isolate the KWP2000 protocol from the OBD protocol

Thanks for this library I saw you've gone through a lot of trouble to make it.
although this is a good library but it is useless for other cars or devices thatuse KWP2000 since it is just like a tutorial on how to display particular car or motocycle data.
it would be much more helpfull if you can isolate the KWP2000 protocol reading and transmission parts from the OBD and display parts.
I want to use it to see the traffic to see which data is been sent and later send the data but I can't make it work with KWP200.cpp since it have a lot of code which I don't know what it does.
I hope that you make a simple example for receiving frames in a loop and displaying them in hex on serial and sending a single frame example. (just like the MCP2515 can bus library which have only the protocol part to communicate with the MCP2515 Controller with that you can use it for any Can Bus Network)

Thanks

What's the max request freq for data KWP

I'd like to parse data from kwp2000 fast init ECU.
I'd like to know the max request per second it can handle. I know CAN bus has no real limitación in this way with a use case like mine. I'm working with 9600bps serial speed.
Can anybody help me?

Suzuki M109R

Looking to use this project on my Suzuki M109R. Hopefully you can help me get the proper HW interface built/bought and programs setup/built/configured to pull Diags from my ECU. At the very least some suggestions on reading for helping understand the fundamentals.

Compilation error: 'Serial3' was not declared in this scope

Hi, it doesn't work with arduino nano. Here is such a mistake
FQBN: arduino:avr:nano:cpu=atmega328old
Using board 'nano' from platform in folder: C:\Users\ANDREAS\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6
Using core 'arduino' from platform in folder: C:\Users\ANDREAS\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6

Detecting libraries used...
C:\Users\ANDREAS\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR -IC:\Users\ANDREAS\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino -IC:\Users\ANDREAS\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\variants\eightanaloginputs C:\Users\ANDREAS\AppData\Local\Temp\arduino\sketches\DD420099BF8F7ED02C7B25D704E2BE58\sketch\basic_working.ino.cpp -o nul
Alternatives for KWP2000.h: [[email protected]]
ResolveLibrary(KWP2000.h)
-> candidates: [[email protected]]
C:\Users\ANDREAS\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR -IC:\Users\ANDREAS\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino -IC:\Users\ANDREAS\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\variants\eightanaloginputs -Ic:\Users\ANDREAS\Documents\Arduino\libraries\KWP2000\src C:\Users\ANDREAS\AppData\Local\Temp\arduino\sketches\DD420099BF8F7ED02C7B25D704E2BE58\sketch\basic_working.ino.cpp -o nul
C:\Users\ANDREAS\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR -IC:\Users\ANDREAS\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino -IC:\Users\ANDREAS\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\variants\eightanaloginputs -Ic:\Users\ANDREAS\Documents\Arduino\libraries\KWP2000\src c:\Users\ANDREAS\Documents\Arduino\libraries\KWP2000\src\KWP2000.cpp -o nul
Generating function prototypes...
C:\Users\ANDREAS\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR -IC:\Users\ANDREAS\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino -IC:\Users\ANDREAS\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\variants\eightanaloginputs -Ic:\Users\ANDREAS\Documents\Arduino\libraries\KWP2000\src C:\Users\ANDREAS\AppData\Local\Temp\arduino\sketches\DD420099BF8F7ED02C7B25D704E2BE58\sketch\basic_working.ino.cpp -o C:\Users\ANDREAS\AppData\Local\Temp\3594476015\sketch_merged.cpp
C:\Users\ANDREAS\AppData\Local\Arduino15\packages\builtin\tools\ctags\5.8-arduino11/ctags -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives C:\Users\ANDREAS\AppData\Local\Temp\3594476015\sketch_merged.cpp
Компиляция скетча...
"C:\Users\ANDREAS\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-IC:\Users\ANDREAS\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino" "-IC:\Users\ANDREAS\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\variants\eightanaloginputs" "-Ic:\Users\ANDREAS\Documents\Arduino\libraries\KWP2000\src" "C:\Users\ANDREAS\AppData\Local\Temp\arduino\sketches\DD420099BF8F7ED02C7B25D704E2BE58\sketch\basic_working.ino.cpp" -o "C:\Users\ANDREAS\AppData\Local\Temp\arduino\sketches\DD420099BF8F7ED02C7B25D704E2BE58\sketch\basic_working.ino.cpp.o"
C:\Users\ANDREAS\AppData\Local\Temp.arduinoIDE-unsaved2023813-2476-1h7eo93.5f3c\basic_working\basic_working.ino:12:14: error: 'Serial3' was not declared in this scope
#define bike Serial3
^
C:\Users\ANDREAS\AppData\Local\Temp.arduinoIDE-unsaved2023813-2476-1h7eo93.5f3c\basic_working\basic_working.ino:19:14: note: in expansion of macro 'bike'
KWP2000 ECU(&bike, TX_PIN, YOUR_MOTORBIKE);
^~~~
C:\Users\ANDREAS\AppData\Local\Temp.arduinoIDE-unsaved2023813-2476-1h7eo93.5f3c\basic_working\basic_working.ino:12:14: note: suggested alternative: 'Serial'
#define bike Serial3
^
C:\Users\ANDREAS\AppData\Local\Temp.arduinoIDE-unsaved2023813-2476-1h7eo93.5f3c\basic_working\basic_working.ino:19:14: note: in expansion of macro 'bike'
KWP2000 ECU(&bike, TX_PIN, YOUR_MOTORBIKE);
^~~~
C:\Users\ANDREAS\AppData\Local\Temp.arduinoIDE-unsaved2023813-2476-1h7eo93.5f3c\basic_working\basic_working.ino:19:28: error: 'YOUR_MOTORBIKE' was not declared in this scope
KWP2000 ECU(&bike, TX_PIN, YOUR_MOTORBIKE);
^~~~~~~~~~~~~~

Используем библиотеку KWP2000 версии 1.3.0 из папки: C:\Users\ANDREAS\Documents\Arduino\libraries\KWP2000
exit status 1

Compilation error: 'Serial3' was not declared in this scope

Can anyone help me the wire thing?

Sorry guys I am totally blank on the electronic field, despite the Circuit diagram showed in README, I can not figure out how to wire these lines. Can anybody show me one? Thanks in advance.

Connect with Honda

Hi,
Want to readout my bike using an Arduino.
I used some code to connect to it. But I can’t do anything past the handshake.
So I want to use you library. Can you help out?

Displaying messages on an OLED rather than Serial window

This is a great tool! Thank you for publishing this! I'm planning to use this on my '06 Ninja 6R.
I've made a portable ESP32 device with an OLED display for tapping the K-line. I want to adapt the library to allow messages on my OLED instead of on the computer's Serial window, which you do with the "_debug->print(" lines. My 1.3" OLED uses the library U8g2lib, which is great. I'm not fully confident that I'll code this change well, but I'm willing to try anything. Have you considered any message display alternatives to the Serial window?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.