-   OpenGauge / MPGuino FE computer (
-   -   OBD MPGuino gauge (

jmonroe 06-01-2008 05:08 PM

OBD MPGuino gauge
Anyone interested in developing an OBD Arduino based fuel economy gauge should post here. So far, I have been working on one based around an ELM323 OBD to RS232 adapter. Some previous discussion on this was on the other thread (

Currently, I was able to connect to the ELM and send it commands. However, when sending OBD commands (010c), the response is "ELM INIT:...>" without ERROR or OK and no real data is received.

dcb 06-01-2008 05:46 PM

I'm definately interested, but I have to wait. Just a couple thoughts in case this takes off w/out me.

There are so many things that you can display from the obd port that this probably would be a good 4x20 LCD candidate.

Since this is a "higher end" version than the injector based gauge, it's probably ok that it costs a little more (i.e. elm chips, bigger LCD, etc).

Also, I *think* all cars are coming out with the CAN bus now, don't know if that is just North America or what. I did see an atmel CAN processor recently (OBD support built in), but do not know how 'duino compatable that will be, if 'duino is even in the cards for the obd effort (would be nice to not have to learn another platform).

Anyway, there is a lot of interest in the obd approach. It can obviously be a useful tool for your average driver. I do hope something comes of it, at least for the hobby crowd who want complete control of the display AND mpg feedback. The scangauge is not terribly expensive though, so building your own obd mpg gauge will probably be even more of a niche than the injector based version.

Magister 06-05-2008 04:39 PM


New comer here, I wanted an SGII but I find it pricey, then I discovered your project, pretty cool!

I will have to buy a *duino kit to test, with an LCD screen. And I guess an ELM323 for my car. A few months ago I started to look at various obd2 solution including ELM, jeff interface, palm, 486 laptop, etc.

(I am currently working on a digital and analog I/O low level module on an Atmel AT91, an ARM 32bits RISC, so I know the stuff, and if I have time I will work on your code too).

Great project guys, continue!!

I am wondering if we really need an ELM chip, or if we just communicate directly in the OBD-II protocol, like the "Atmel AVR 2004 Design Contest Project" at
Maybe wait also for the Atmel 328P to have more RAM?

We should bring also the "xarias" guy here for some help.

Here's how to connect the OBD-II connector directly to an Atmel:
(see Microcontroller-OBD interface, second picture)

LostCause 06-10-2008 12:09 AM

A nice pricepoint might be tough. Anything much above $50 and the SGII starts to make more sense.
  • RS232 Freeduino ~$15
  • 16 x 2 LCD ~$10
  • ELM 323 ~$15
  • Assorted Parts ~$3
  • OBD-II plug ~$7 (5 minimum) :eek:
Junkyard, maybe? It does drop down to $3 after the first 200...:p

If it's possible, I say drop the ELM. The ELM327 will help with the "one size fits all" aspect as it does every interface...but $30...eek.

- LostCause

Magister 06-10-2008 09:36 AM

I doubt you need an ELM323, on AVRFreaks a couple of people did it without an ELM. Search "obd" on their forums, some people even give some C codes to do it. It seems the ELM is slow too.

I'm sure we can drop the ELM.

To init the OBDII you send 0x33 at 5 bauds then you switch to 10400 bauds and send some commands, plug the Atmel directly on the OBDII like this:
(ISO protocol only)

You could also switch to an AT90CAN128 to speak CAN to your car I guess?

LostCause 06-10-2008 11:20 PM

Lightner's article, posted above by Magister, is very well written and in depth. He offers schematics to properly handle the vehicle's 12V power supply and an in depth examination of the J1850 VPW protocol. The end of his article claimed circuit cellar (magazine running the story) would cover all the protocols in the future, but I haven't been able to find them.

In any case, I found the calculations necessary to convert OBD-II PID's to MPG. The information is also posted in the main instrumentation forum. All from Bruce Lightner's mind:

The calculation depends on whether your car has a MAF sensor or not.

MAF Sensor:

MPG = (14.7 * 6.17 * 454 * VSS * 0.621371) / (3600 * MAF / 100)
= 710.7 * VSS / MAF

14.7 - grams of air to 1 gram of gasoline - ideal air/fuel ratio
6.17 - pounds per gallon - density of gasoline
4.54 - grams per pound - conversion
VSS - vehicle speed in kilometers per hour
0.621371 - miles per hour/kilometers per hour - conversion
3600 - seconds per hour - conversion
MAF - mass air flow rate in 100 grams per second
100 - to correct MAF to give grams per second

No MAF (Uses MAP and Intake Temp to approximate MAF):

MAF = (IMAP/120)*(VE/100)*(ED)*(MM)/(R)

MAP - Manifold Absolute Pressure in kPa
IAT - Intake Air Temperature in Kelvin
R - Specific Gas Constant (8.314 JM/K)
MM - Average molecular mass of air (28.97 g/M)
VE - volumetric efficiency measured in percent
ED - Engine Displacement in liters

This method requires tweaking of the VE for accuracy.

I have no idea if these are the methods the SGII uses. The accuracy will be off due to approximations (AFR ~14.7, etc). All the information is from the brilliant mind of Bruce Lightner.

- LostCause

RuHaSs 06-11-2008 06:18 AM

Here are a few open source projects on OBDII maybe can get some ideas.

Magister 06-11-2008 09:25 AM


Originally Posted by RuHaSs (Post 33649)
Here are a few open source projects on OBDII maybe can get some ideas.

Use an ELM, I don't know if we want it.

very interesting, and the schematics are available as well as the sources!

Magister 06-19-2008 01:04 PM

Ok it seems we do not need a "jeff interface" or transistors to connect the K line to the TX/RX of the chip, a single Motorola/Freescale chip already exist that does everything: the MCZ33290EF

The MC33290 is a serial link bus interface device designed to provide bi–directional half–duplex communication interfacing in automotive diagnostic applications. It is designed to interface between the vehicle’s on–board microcontroller and systems off–board the vehicle via the special ISO K line. The MC33290 is designed to meet the “Diagnostic Systems ISO9141” specification.
It's the chip used in the Blafusel "KL interface serial cable" and also a obd2-lcd device.

To use it, it's very easy, PD0 and PD1 are direct connect to the Atmel chip:
(picture of their PDF available at

So I tried to get one here in Montréal but can not find one, it's a $1.46 chip but as a special order they want to charge me $8 for it, WTF indeed!

If someone bought some at digikey or your local electronics parts store, I will be glad to paypal you $2 to ship one to me in a standard envelop :)

Magister 06-23-2008 12:53 PM

I ordered:

- a Freeduino serial V2.0 + LCD display at NKC ($17+$10)
- an OBD plug at ($5)
- a sample MCZ33290EF from Freescale ($0)

I should be in business, I will find a 510 ohms resistor somewhere here and some push buttons, it's the only component needed.

I even started to write some codes, I started with standard C but why re-invent the wheel to support digital I/O and all, it's in the Wiring/IDE already. So I went back to the standard IDE, and it will be easier to share with other people.

It compiles, obviously it's not tested, copy/paste in IDE :)

EDIT July 3rd: Maybe I will not update this post anymore, for all information go to the homepage of the project at

Source is available here:

To keep compatibility with already existing cable, the OBD-II to DB9F cable is wired like this:


DB9F                        OBD-II
1---------------5 (Signal ground)
2---------------4 (Chassis ground)
4---------------7 (ISO K line)
6---------------10 (J1850 bus-, future use)
7---------------2  (J1850 bus+, future use)
9---------------16 (Battery)

Do not plug it into a PC!!! This goes to an interface only!!!

You can make it yourself with an OBD-II plug available at for $5+$3sh.
Use at least AWG24 wires especially for Battery and Chassis ground.

Or buy an already made cable at for $10+$5sh

The cable goes into an interface to adapt the ISO signal for the Arduino input.
It concists of a small IC, a resistor, a DB9M that will be plugged with the cable mentionned above, and a few wires that connect to the Arduino board.
Schematic is like this:


Arduino pin 3 -------------5|TX  ISO|4-----------------+------- DB9M pin 4 (ISO K Line)
                            |      |                  |
Arduino pin 2 -------------6|RX  GND|3--DB9M pin 1    / between MC pin 4 and pin 1
                            |      |                  \ goes a 510 ohms resistor
Arduino 5V pin output -----7|VDD  NC|2--              /
                            |      |                  |
Arduino 5V pin output -----8|CEN VBB|1-----------------+------- DB9M pin 9 (12V Battery)

The Arduino is powered by the 12V line coming from the cable too

Arduino 12V input ------------------ DB9M pin 9 (12V Battery)
Arduino GND input ------------------ DB9M pin 2 (Chassis Ground)

All times are GMT -4. The time now is 06:37 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2023, vBulletin Solutions Inc.
Content Relevant URLs by vBSEO 3.5.2
All content copyright