How to send custom CAN messages using ELM327?

11.9k Views Asked by At

I'm working with a ELM327 and I'd like to be able to set the header and data portions of CAN messages to be sent. I see that there is a code for setting the header for messages

SH xxyyzz

But I'm having trouble finding out how to set the data portion and control when the message gets sent.

Do these both occur when I send a ASCII request for a PID with extra characters for the data field?

And would that use the header that was set by the SH command?

Is there a better way to do this?

Datasheet: http://elmelectronics.com/DSheets/ELM327DS.pdf

3

There are 3 best solutions below

0
On

This might be an old question, but I just found an online link which describes in detail how to send arbitrary CAN messages using the ELM327. So anyone (like me) coming past that question can still find a valid answer.

Look here for details on send arbitrary CAN messages with the ELM327: https://www.elmelectronics.com/wp-content/uploads/2017/11/AppNote07.pdf

Best

0
On

If you're using an ELM327 chipset, you need to call ATSH or AT SH, to set the header first. Then send the message separately (The data bytes).

https://www.sparkfun.com/datasheets/Widgets/ELM327_AT_Commands.pdf

2
On

If you're using the ELM327, and you're on a protocol such as J1850 vpw, or J1850 pwm (older than 2003 CAN vehicles).. Then you will use this to set the header.

The header will consist of xx yy zz xx = priority of message (i.e. 68) yy = Target address of module you want to talk to (i.e. 5A) zz = Sender address, which can usually be F1

So your command would look like this ATSH 68 5A F1

This sets the header.. Now you want to send data. Any data you send from now on will use that header, and send the data to that module.

So if you wanted to get the RPM's, you can just send 01 0C You will get something like 41 0C 23. The last data byte is the value of RPM's. You will have to figure out the formula to convert this into a human readable format though.. A lot of information can be found here..

https://en.wikipedia.org/wiki/OBD-II_PIDs

By the way, if you're communicating on a CAN network, you would just use the module ID as the header.. ATSH 7E0, then send your data. all vehicles 2008+ are CAN.. some 2003-2007 are also.