Regular expression for OBD fuel consumption calculation

RafsQ2 years ago

Good morning,
I would like to know how to create the regular expression in Traccar in order to calculate fuel consumption. I use a Sinotrack ST-902 OBD device. It is already active and sending me the location correctly, but I want to calculate the average fuel consumption on trips.
Is it possible?

Anton Tananaev2 years ago

How do you want to calculate it?

RafsQ2 years ago

I want to calculate it based on displacement.
This will vary by car, correct?
I wanted it to pull the amount of fuel in the tank via OBD and do this calculation based on displacement. This way I could have an average of how much the car consumes and be able to pull it in the report to link to fuel notes.

Anton Tananaev2 years ago

Does your device report the displacement?

RafsQ2 years ago

Yes, perfectly. Displacement and speed.

Anton Tananaev2 years ago

Can I have a screenshot of the data?

RafsQ2 years ago

Report? Which fields? Which data do you need?

Anton Tananaev2 years ago

You said your device is reporting the displacement data. I'm just asking for a screenshot as a proof.

RafsQ2 years ago
2023-04-10 14:30:57  INFO: [T1e3e5ba7: h02 < IP SERVER] 24911792535614305610042312107438060431322502000164fffffbff00c81b0d0c06000002d40b01791c85f8
2023-04-10 14:33:17  INFO: [T1e3e5ba7] id: 921792476, time: 2023-04-10 14:33:16, lat: -16.17906, lon: -48.22042, course: 124.0

In the logs, I have this return here. At the moment, it is in my car and as I move, it updates my direction smoothly, showing the address and speed perfectly.

The only thing I want to add is this fuel consumption issue so that I can have an additional item on the report.

Anton Tananaev2 years ago

Where do you see the displacement? Maybe you should also clarify what you mean by displacement.

RafsQ2 years ago

I just want it to calculate the fuel consumption based on my location and displacement from one point to another. That's it.

The GPS function is working 100%.

Anton Tananaev2 years ago

OK, so location displacement, not fuel displacement? Then you can use "totalDistance" in your expression. I'm pretty sure we have examples on the forum, so you should be able to find it.

RafsQ2 years ago

What I want is to use the distance traveled to give me the fuel consumption. I couldn't find it on the forum.

Anton Tananaev2 years ago

Just one example I found in 5 seconds of Google search:

https://www.traccar.org/forums/topic/help-with-computed-attributes/