RS232 to OBD2 Message Format

Hi

I am wanting to create a custom obd2 formatted message so that i can send it to a display that accepts obd2 messages and have my data appear on the display

Currently the display accepts obd2 messages to display a range of information however it does not display the custom information i want to have displayed

my display would not be connected to a vehicle obd2 / canbus in any way it would be stand alone simply taking the obd2 data i am sending it using the same message format it would expect to receive from the vehicle yet the values displayed would be custom values based on my own input not from the vehicles

Just wondering if the above is possible and if someone could point me in the right direction i would appreciate it.

Ideally if there is an rs232 serial to obd2 format converter that would be the perfect solution

looking forward to any thoughts

Claude,
tell us more about the display. e.g. the brand/ model and where the messages come from that you currently use.
Also, why are you looking at RS232, which is quite a different thing?
I’d be more inclined to pick a project that used an Arduino (or Raspberry Pi) to display ‘stuff’ and add the OBDII protocol to that.

https://github.com/sandeepmistry/arduino-OBD2 or
https://www.elektormagazine.com/labs/obd2-for-arduino or
https://www.instructables.com/id/OBD-Pi
may be places to start.

“Search engines are your friend”

Dave

1 Like

Claude,
I see you’ve another discussion going on…Arduino DigitalRead Generating Strange Results. is this part of the same project?

1 Like

Yes but the digital topic for this project can close

I have moved to reading serial data

Now my challenger is when enter a value 110 I get bytes output to serial monitor when o want the actual value 110 whatever numeric speed I send to it only any of these set values

40,50,60,70,80,90,100,110

Claude Raiola
0414 228 948

show us the code… you probably need to put the 110 in quotes, “110”… or convert the number to a string.

1 Like

Hey Claude,

Just some clarification on terminology; OBD 2 is the connector specification (which includes where the connector has to be in the vehicle). CANBUS is a 2-wire communications protocol which has become standard in the automotive industry (among others).

Obd 2 requires canbus, but there’s a bunch of other pins in there too, and there’s a little bit of wiggle room in the OBD2 standard so not all manufacturers implementations are the same.

The Devil is in the details on these sorts of projects so it’s important to be very specific.

Ok so I have made progress from the bytes being outputted BUT not look at the hyro glifics in place of the bytes

The value I am passing is a random set of numbers in this instance it is 10055

In real world the values will be in units of 10 starting at 40 up to 110 only 1 number sent each time

14:37:33.476 -> blaaa

14:37:34.507 -> blaaa

14:37:35.494 -> blaaa

14:37:36.479 -> blaaa

14:37:38.496 -> y**⸮⸮⸮VVV⸮**

String x="";

void setup()

{

Serial.begin(9600);

}

void loop()

{

if(Serial.available()>0)

{

x = Serial.readString();

Serial.println(x);

}

else {

Serial.println(“blaaa”);

}

delay(1000);

}

In contrast I receive the following output

15:56:32.260 -> blaaa

15:56:33.271 -> 121

15:56:34.272 -> 189

15:56:35.274 -> 246

15:56:36.295 -> 246

15:56:37.297 -> 86

15:56:38.299 -> 86

15:56:39.300 -> 86

15:56:40.301 -> 235

15:56:41.288 -> 0

15:56:42.311 -> blaaa

15:56:43.291 -> blaaa

When I use this code

String x="";

void setup()

{

Serial.begin(9600);

}

void loop()

{

if(Serial.available()>0)

{

x = Serial.read();

Serial.println(x);

}

else {

Serial.println(“blaaa”);

}

delay(1000);

}

Regards

Claude Raiola

0414 228 948

Thanks

I have a off the shelf display that connects to obd2 and displays pre defined data in pre defined locations on the display. All data coming from the obd2 cable the display is connected to which the other end is connected to car obd2 socket

The above works as expected

I want to buy a second identical display to the one above

However I do not want it connected to the car rather connected to my own custom output. So my custom device needs to be able to mimic the identical obd2 message format that the initial display receives eg:

Obd2 format message for engine revs speed so the display thinks it’s the engine revs speed message it’d receiving and displays the message where engine revs speed usually displays.

HOWEVER the actual value I am passing inside the engine revs speed message is vehicle current bearing as in direction 0 to 360

So the above is hopefully detailed enough so others know what I am trying to achieve and hopefully can point me in the right direction

Claude Raiola
0414 228 948

To further clarify the source of the data that advises the direction being travelled is in rs232 format so I am bound by having to use that data format

Claude Raiola
0414 228 948

Further comment

At this point I do not need to read obd2 data and display it as I already have a obd2 display off the shelf that does that

I am trying to send obd2 formatted data to a second obd2 display that is not connected to the vehicle system in any way

So replicate obd2 formatted data within my own project so I can use my own custom values to appear on the display, the display thinking the message is coming from the obd2 of the car and it will therefore display my info on an obd2 display as if the data was coming from the car.

Claude Raiola
0414 228 948

Claude,
The difference is how you are reading the Serial Data. Back to a couple of basic things:

  1. Serial data is sent as characters which generally make a ‘sentence’ or as you attempt in the first code a ‘string’. That data is usually formatted in a specific way and in particular ends with a special (non-printing) character, usually a ‘CR’ (Carriage Return) and often as well an ‘LF’ (Line Feed).
  2. these characters are actually send as ‘8 bit’ ‘bytes’. You should look up ASCII, that’s a standard for how those bytes map to actual letters an numbers.
  3. Your second code gets those ‘bytes’ and prints them as decimal numbers.
    In your code you need to work with the second version, get each character until you get the CR (or other character that defines the end of the ‘sentence’), put that in a string, then display it.

Do a search for ‘Arduino serial data’, or something similar and read up on that.

Dave

2 Likes

Claude, as for your project as a whole, trying to use OBD is a complicating factor.
Look at the RS232 shields in the other post, and add a small display e.g. https://core-electronics.com.au/gravity-i2c-lcd1602-arduino-lcd-display-module-green.html.

If you want something ‘nicer’ search for arduino LCD or OLED and use a smaller Arduino like a Feather and a Featherwing.

Dave

1 Like

So when I convert to Serial.readstring the output changes to a single string however is not readable text its more like hyro gliphics

The value being passed is 110 in this example

From

14:09:21.605 -> 103

14:09:22.592 -> 103

14:09:23.577 -> 6

14:08:19.207 -> gg

String x="";

void setup()

{

Serial.begin(115200);

}

void loop()

{

if(Serial.available()>0)

{

x = Serial.readString();

Serial.println(x);

}

else {

Serial.println(“blaaa”);

}

delay(1000);

Regards

Claude Raiola

0414 228 948

Using the following code when I pass a value in this case 90

The output I get is y⸮⸮V⸮

The output is being sent from a tracking device that uses rs232 format

The above are the settings for serial data transfer on the tracking device

String readString;

void setup() {

Serial.begin(115200);

}

void loop() {

while (Serial.available()) {

delay(2); //delay to allow byte to arrive in input buffer

char c = Serial.read();

readString += c;

}

if (readString.length() >0) {

Serial.println(readString);

readString="";

}

}

Regards

Claude Raiola

0414 228 948

Claude,can we go back a few steps.
have you added an RS232 board? and if so where from? did they have examples of how to use it?

Do you have any information about what the tracker actually sends? not just that it’s 112500 etc.
Have you tried using a terminal emulator on your PC to capture some of the tracker output?

         14:09:21.605 -> 103

Where does the 14:09:21.605 come from? That looks like a timestamp from somewhere and your code does not seem to do that.

Which leads to the question, Where did you get the code you are using?

Also to make reading it clearer can you try to separate the output from your code?
like use the </> to mark the different pieces of text in your messages.

Dave

Hi

Before I answer the questions let me first confirm

The output from the tracker tx port is in rs232 uart format

I have been able to test the output using serial mon and can confirm the output is working and passing the data as expected

See the image below

image0.jpeg

When connecting to arduino uno I connect to the rx port which from my reading accepts serial data instead of ttl format

I have a serial to ttl adaptor but assume it’s not needed if I am connecting to the rx port of the arduino uno

So as of this email we can confirm the output from the device in rs232 format is outputting correctly. One hurdle fattened

Claude Raiola
0414 228 948

Here is an up dated screen shot showing the config setting of the connection as well as the successful data being sent / received

image0.jpeg

Claude Raiola
0414 228 948

Hi Claude,

You seem to mixing and matching terminology and aren’t being clear about important details, which is making it very difficult for us to provide assistance as there’s a lot of miscommunication going on. I also take it you’re replying to your email instead of looking at the forum thread. Please use the forum, it makes it much easier to format your response like Dave has suggested.

Please read through the below links and then we can have a more sensible conversation. Some important things to note:
RS232 is not UART
UART is only one specific type of Serial Communication Protocol
UART can be implemented in both RS232 and TTL
CAN Bus is not OBDII
OBDII is not an encoding format or communication protocol.
Variable type matters. 110 as a number is not the same as “110” as a string of ASCII encoded characters.
110 Base10 in Base2 is: 1101110
The ASCII encoded string “110” in binary is: 001100010011000100110000
If you don’t clearly specify your variable/encoding type on the receiving end it’s no wonder you’re getting garbled information out.

Hi

May i first apologise for any miss communication as its far from my intention

I have been trying to output data from my tracking device to either

  1. a display that accepts OBD2 data source. this obd2 data display is non arduino its an off the shelf produict
  2. an arduino board us an arduino uno which will have its own arduino display.

So the the constant in the above is the output from the tracking device.

When i approached the supplier their tech support dvised the reason for the unexpected data being outputted was due to arduino needing to be in ttl format yet the output from the tracker is rs232

The device outputs the rs232 and uses the UART protocol, i can confirm this as its indicated in the firmware software tool for the device the supplier supplied.

So as of today i have been able ot take the output form the device that is outputted in rs232 using uart protocol and proven the output is as expected by reading the outpout via Serial Mon software.

So we know that the source data being output is correct

My challenge is to get arduino to be able to output that data correctly

I trust the above draws a line in the sand from the earlier miscommunication identified with obd2 topic and rs232 / uart

I will from here on only reply via the form and not via email as requested

It goes without saying i am very appreciative of the patients and professional support your team has provided me with any of my technical questions.

Once i have been able to achieve arduino outputting the rs232 /uart data then that will provide a solid foundation to address the obd2 topic if i decide to per sue it as it will also be relying on the the same source data coming form the tracking device

Just FYI, Dave and I aren’t from Core Electronics. We’re just guys in the community who help because we like to help.

You keep saying OBD2 data source, but like I said, OBD2 isn’t a data format and there’s lots of different implementations - so what is the data format your screen actually requires? What is the format and encoding of the Engine speed data you intend to simulate? You need to find this out to get to your end goal (although like Dave said above there are probably better ways to get there).

For all intents and purposes here, the only difference between TTL and RS232 is the voltage they operate at eg. 0v/5v and -12v/+12v respectively.

If you connect your arduino directly to an RS232 signal you’ll destroy it - that’s what RS232 to TTL converters are for so you can connect TTL components to RS232 components without letting the smoke out…