How to build a Boost and Air Fuel Ratio LCD Gauge

How to build a Boost & Air Fuel Ratio LCD Gauge

By Paul Vang

 

Description:  This tutorial will demonstrate how to build an LCD boost and AFR (air fuel ratio) gauge and displaying it on a 20×2 Hitachi LCD screen.  An Innovate LC-1 will feed the wideband 0-5v for 8-22afr readings.  The boost reading was setup to work with a Honda MAP sensor however any map sensor can be used with some change in the code.

The LCD will display Air fuel ratio with an indicator bar ranging from 8-22afr.  The LCD will also display current boost/vacuum and peak boost.  There will be 4 buttons to enable the menu, navigate and clear the peak boost.

Video Clip of the assembled project working:

Parts needed:

  1. Arduino Uno
  2. 4 Push buttons
  3. 4 10k resistor
  4. 1 10k potentiometer
  5. 20×2 LCD (Hitachi compatible)
  6. Misc wires
  7. Usb cable for the Uno
  8. Arduino IDE version 1.0.1 to 1.0.4 (tested)

Optional:

  1. BMP085 Bosch pressure sensor (for sensing atmosphere if using absolute sensors)

Wire up the project on a breadboard or test board.

Arduino Boost AFR LCD Layout
Arduino Boost AFR LCD Layout

Follow the schematic below if needed.   Please do note that the schematic has the LCD header upside down.  Pin one is at the top right.

Arduino boost afr Schematic
Arduino boost afr Schematic

Once the unit is wired up, upload the Project file to your Arduino (or compatiple) board.  This has been tested on the Uno and Mega2560.  Download the code and full details below.

Navigation Push Buttons

There are 4 buttons to navigate the Menu System.  In order to invoke the menu, press, the Enter button for 1 second.  To navigate the menu, push the Previous/Next button for 2seconds.  Press Enter to select the menu, submenus or to commit a change.

  1. Previous (or Peak Boost reset when not in Menu mode)
  2. Next
  3. Exit (Return to monitor screen)
  4. Enter (or commit changes)

The Code

The project was developed in Arduino 1.0.1 on a Mac and has been tested up to version 1.0.4 on both Mac and PC.  The menu system uses menubackend so that library will need to be included to your Arduino libraries.  (How to add libraries:  http://www.arduino.cc/en/Hacking/Libraries)

 

There are 4 tabs when you open the project in Arduino.  There are codes next to the each line to give you a general idea of what it’s doing.  The first tab houses the void setup and void loop statement.  The second tab (Menu_Action) stored the menu commit command.  The third tab (Boostafr) stores the boost and air fuel ratio computation formulas.  The last tab stores the notes.

 

EEPROM usage

EEPROM address 1 is used for Peak boost (Used sparingly as the EEPROM has a life cycle of about 100k writes.

EEPROM address 2 is used for backlight

 

If you improve or add to it, please let me know so we can update the code on the Tutorial page.

Download the code below in the download link.

The download includes:

1. The Libraries used

2. The Arduino Schetch

3. The Fritzing drawing and schematic

4. The PDF HOW TO document

 

WARNING: Build and use at your own risk.  I do will not be liable for any damages occurred from the project build.

Libraries:  Some of the libraries were open source.  The respectful owner deserves the credit for creating the libraries.

Go to paulsvang.com for more tutorials in the future.

DOWNLOAD FILE:

Download Here
If this article was helpful, please consider donating to support the website. Thanks




81 thoughts on “How to build a Boost and Air Fuel Ratio LCD Gauge

  1. Hi!

    I just went through your write up and I have to say so far with the pots its working just as it should!

    Thanks for providing this awesome solution!

  2. Great Jimmy Luntzel. I’m glad it worked for you. I was going to modify it and add more features but I’m tied up with other projects. When time permits I’m going to add more bells and whistles.

  3. Decided to use my Arduino to make afr/boost reader but you beat me to it! Thank You!! Lol

    Can’t wait to get started with your design and will post results.

  4. Robie,

    Do post results. I started with the uno but then needed more memory so I changed to the mega 2560. If you get progmem working, that will reduce the memory usage and possibly be able to use the uno again. Anyhow post what you’ve come up with. I’d like to know as well.

    Paul

  5. Hi
    I was trying to program my arduino leonardo and all im getting are random characters in my first line of 20×2 lcd.
    can i get any help please
    Thanks
    Matthias

  6. Paul,

    Since my car doesn’t have a MAP sensor (1990 Volvo 780 Bertone) I have been looking around for a suitable one to use. Looking on Ebay and found an OEM Densor sensor for a Honda (pt# TN079800-3280)
    and I was thinking about using that one.

    My question is this, all the ones I have seen look similar with a 3 wire harness and vacuum connection. Is that correct? and would you happen to know the pin out for the stock Honda type.

    Rob

  7. Rob,

    Take a look at this. Hopefully it will help you. You can use the standard map sensor from a 92-2000 honda civic. They Are usually mounted on the intake manifold. You can also use the one from an acura integra 94-2000. They are pretty much the same sensor.

    Paul

  8. Its on Analog Pin 1. The R3 is there for simulating. You remove it and use the output of the 02 sensor (a/r ratio meter) and connect it to Pin 1 on the analog input. Then you connect both grounds together.

  9. Hi admin thank you your preject, can I use to maf sensor MPX4250?

  10. It only supports reading a MAP sensor but the sensor you posted seems to be a motorola MAP sensor. It should be able to read just fine but you’ll have to do the voltage / KPA conversion in the arduino code to support it.

  11. Hİ paul,

    I want to ask the question, I would like to connect dijital pin5 relay,for wastegate selanoid valve,example when set the peak boost 14.7 psi, dijital pin5 output active and lower psi pin 5 passive.I want to control boost,can it be?

  12. Yes it sounds like it can be done but the output of the digital pin will not be able to provide the voltage/current for the solenoid. You’ll probably have to use a transistor circuit to control the solenoid.

  13. Yes understand you, thank you very much good works 😉

  14. Hello, i need the sketch code because i use near the display I2C interface, and with your code mine lcd doesn’t work. Because my lcd works with CrystalLiquid_I2C library and that library doesnt work with the LcdBarGraph.h library. Can you help me? I can’t use all Arduino’s pins because i need them for doing other actions, so with my LCD Interface1602 I use only 2 pin for make it works. Thanks.

  15. Angelo,

    I have a i2c LCD but I have not tested it yet. I plan to but no time soon. As soon as I get to it, I’ll update this post.

    Paul

  16. very good project Paul :-)
    i’m try conbert psi to bar on your sketch,,
    can you advice me about ?
    thanks in advance.

  17. Bill,

    It shouldn’t be too hard. You will need to find where boost is printed out on the LCD and add in your own variable calculation and print that instead. Basically intercepting the boost value then convert from psi to bar and then print the bar value.

    For example:
    My code:

    lcd.print(bstoutput1,1);

    Can be changed to something like this:

    
    
    float barValue = bstoutput1 * 0.0689475729; // Convert from psi to bar
    lcd.print(barValue,2);//Print the new Bar value to 2 decimal places
    

    This however would need to be changed at all places where the BAR will be displayed. I hope that makes sense to you.

    Paul

  18. Hi,

    Thanks a lot for sharing your knowledge, i’m so interesting about it. My question is, this module can be apply to motorcyle (exactly CBR 150 FI)? Thanks a lot for your help.

  19. @DWI Setiyadi, it will work but you’ll may have to make adjustments to the code if you’re not going to add in ausing a honda map sensor.

  20. Great tutorial! Ill be using this WITH and AEM Wideband and Boost gauge, ill let you know how close they are.

    I am getting an error with your code however,

    ‘menuUsed’ was not declared in this scope

    and cannot compile. Anyone else have this issue? Im new to Arduino but not to code and think Im missing a .cpp file.

  21. You have to make sure to use the older Arduino version. Version 1.0.4 to be exact. Make sure to load the libraries as well. It should compile.

  22. i had the same problem as andrew i tried every version of arduino ide including 1.0.4 to no Avail i still had the same error what i had to do is strip the code down to just the AFR meter (which is all i wanted) to get it to work there is something wrong with the code or the menubackend library that keeps it from working if you would like i could send you or post my stripped down version for people that only want the AFR meter

  23. I run it with no problem. It may be the libraries causing the issue. I’m not sure who wrote the menu library as it’s been awhile but feel free to strip out what you don’t need.

  24. although it didn’t work perfectly for me i do want o thank you for the starting point/code it saved me allot of time and money from not having to buy an overly priced AFR gauge and it gives my car a more personalized touch having a custom built gauge im thinking about doing a 7 segment display one next

  25. Hey,
    Can I use any wideband sensor (Example Bosch 1 to 5 wire ones?) with this and do I connect the pin from sensor to that analog input?
    To clarify: wideband o2- sensor->Arduino analog pin 1 (?)
    Also I tried to download and made account for download pager, ordered etc. but did not receive anything yet?
    it says pending?

  26. No, you need to use a wideband unit that has the voltage output of 0-5v. Something like a innovate lc1 or lm-1 or an AEM wideband gauge. For downloading, it takes about a day for approval to ensure your email account is not spam. You will be emailed when it’s ready to be downloaded. Also make sure to check your junk email.

  27. I have 16*2 blue screen, how do I connect the pins on that one?
    it has 16 pins in row

  28. I think I figure it out but I think also that I need new code for smaller screen.
    Also I would love to have bars instead of psi, do you have code for this?

  29. Did not figure the screen out… what screen do you use, so I could see the pin layout on it and then figure it on my screen?
    I saw hitachi lcd screen but do you have more specific model for this?

  30. You’ll have to look up on how to connect that unit. They are pretty straight forward. You only have a few options. Parallel or i2c I believe.

  31. No worries, I got all to work and it shows right on 16×2 screen
    Now I only gotta figure out the changes to “bar” and increase the boost limit. Mine stops on 10.7psi what is less that “1 bar”
    My cars has about 20psi of boost.
    Thank you lot for this. Im also thinking of adding outdoor temperature to this program and some other features.

  32. hi guys really interesting stuff! iv just gotten in to programming and electronics
    getting the message ” ‘menuUsed’ was not declared in this scope ” i added the libraries also

    any suggestions ?

    thanks

  33. make sure to use the right arduino version. It will not work on the latest version.

  34. nice to see you sharing all of these.
    please can u give your skype id on email on there to talk with you please?thanks a lot.

  35. Sorry I have not skype. Feel free to email me or post your question here.

  36. it’s was a good project for those who addicted to engine performance…just have one question..i just wanna to know that this project are able to read the value from the original narrowband 02 sensor or only designated to wideband 02 sensor?

  37. hi admin, can u please help me how to convert narrow band 1-0V output to AFR,because of it’s graph i definitely different with the wide band so that the equation used in your program in not compatible.

  38. You’ll have to modify this code. Look at it to see if it makes any sense to you.

    float afrValue = analogRead(A1);                     //Read input from LC1 Wideband voltage 
    
     float afroutput = (afrValue-0)*(22-8)/(1023-0) +8;   // convert Air Fuel voltage from 0-5v to 8-22 AFR  couldn't use this: map(afrValue,0,1023,8,22)  because it does not support decimal values so it's done a little different
    

  39. You will also need to know the linear output of your o2 sensor to get it mapped correctly. It may not work as intended since it’s not an actual wideband.

  40. I was looking to buy a combined lambda and boost gauge when I came across this great project. So I bought my first Arduino and ordered the LCD screen and the other things needed and started reading the code.
    I will convert psi to bar and AFR to lambda, which should be quite easy and later on I will try to add more functions such as fuel pressure, oil pressure and oil temperature with scrolling functionality with the buttons and maybe even a larger screen.

    Do you have any idea as to why this sketch won’t work with Arduino versions > 1.0.4?

    Thank you very much for sharing this great project!

  41. Hi
    Can i connect this to my AUM 1.8T Bosch wideband sensor and to which wire?

  42. Christian, It wont work with some of the later versions of arduino because the libraries are old and have not been updated. Just use the older version so you can compile it to get it working.

  43. Wimpie, As long as the AUM wideband has a 0-5v output that is linear, then you can use it. You’ll need to do the conversion from volts to lamda/air fuel ratio.

  44. Can i connect it direct to the sensor and it wont effect the readings to the ECU?

  45. Wimpie, Only if you know what you are doing. Tapping into the MAP sensor would be fine however there’s more to it with a wideband. The wideband requires a 0-5V output for you to connect to.

  46. thanks for the great work but i cant find the code please if anyone can help i need the arduino code ,,,, thanks in advance

  47. I’ve got everything up and running except for the buttons. I’ve tried it on the breadboard, and they do work, but it would be nice to use the internal pull up resistors instead of external ones. Do you know what and where to change to get that to work?

  48. Christian, it worked fine for me. What is it doing? Is it not working it all? It worked fine for others.

  49. No no, let me rephrase that. The buttons works just fine. What I want to do is use the Arduinos internal pull up resistors instead of having to wire external ones. Some code needs to be changed in order to get that to work since the logic will be inverted. I found this and I will give it a try.
    https://github.com/tehniq3/custom_menu/blob/master/custommenu_ver1m0.ino

    I will upload some pictures of the project ones it’s finished.

    Thank you again for sharing your hard work! It’s much appreciated!

  50. Christian,
    Sorry I thought you meant that you couldnt get it to work so you want to use the internal resistors instead. Anyhow please do share if you get it working. this could cut down on using additional parts.

  51. hi i am new to arduino so this is probabely a stupid question but i keep geting a eror ‘menuUsed’ was not declared in this scope.
    what can i do to resolve this and also wil this schetch work on anny arduino or just the uno was hoping to run it on a nano?

  52. trymsaetren, are you using the correct arduino version? Make sure to use the one I have mentioned. As for the nano, I believe it should work but you’ll have to test it out to make sure. The nano and uno is essentially the same but one is in the smaller package.

  53. hi, thats a great project. i m new to arduino and old on programming… 15 years actually since my last program…. i m having a project car a classic mini (NOT A CLASSIC THOUGH ANY MORE) and my plan is to replace or add all electrical through arduino and raspberry bi so for now i m reading and experiment. i saw in a comment that you upgraded to mega 2560 cause of memory. i planning to use only afr but 4 of them with mega is it gonna be ok? thanks

  54. Constantinos, It may work but I’ve yet to try it. With limited time, I’ve moved on to my other project instead. Everything else will work except for the Menu system as the creator only created this menu for the UNO during the time I was creating this. If you can share your results when you test it, that would be great!

  55. Hi again!

    I’ve made a simple filter for the boost signal since it was quite jumpy.
    It looks like this if anyone is interested in using it.

    int counter = 0; // The counter is used to count the number of readings from the analog input
    int smootherreadings = 5; // Enter the total number of readings from the analog input before printing the value
    int totalsmoothing = 100; // Enter the total time in ms before printing the value
    float bstsmooth = bstoutput1;
    float fpsmooth = fpoutput;

    while(counter < smootherreadings){
    bstsmooth = bstsmooth + bstoutput1;
    counter++;
    delay(totalsmoothing / smootherreadings);

    }

    bstoutput1 = bstsmooth / smootherreadings;

    counter = 0;

  56. Hi all I am new to this project thanx for this wonderful project I would like to ask for some assistance with using the liquid crystal display 16×2 with a back plate if anyone has done this before here is my email address if anyone can send me a email then I will reply with photos to show what I have in mind.
    Thank you

  57. Steven earlier told he only took the AFR part, any beginner help how to take that only from code?

Leave a Reply

Your email address will not be published. Required fields are marked *