This project saw me build a custom boost gauge for a diesel Nissan Terrano. Since I bought the car second hand and the 3.0L turbo engine is known for an agressive tune, I wanted to monitor the intake pressure. The car comes with a Variable Geometry Turbo so monitoring the vane actuation is important.
Since boost gauges are either inacurate or expensive, I've decided to build my own. Luckily the car comes equipped a good quality Manifold Absolute Pressure (MAP) sensor from factory. Owing to this I was able to get the signal directly from the sensor and feed it to the Arduino microcontroller. Last piece of the puzzle was displaying and refreshing the information on the display according to the translation from volts to PSI.
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
const int OLED_RESET = 4; // Reset pin # (or -1 if sharing Arduino reset pin)
const int SCREEN_WIDTH = 128;
const int SCREEN_HEIGHT = 64;
Adafruit_SSD1306 display(OLED_RESET);
//baro sensor calibration (in psi) from manufacturer's data sheet
//assumes linear volt / pressure correlation
const float maxV = 4.5; //max output voltage
const float maxPSI = 36.73; //max pressure
const float minV = 0.5; //min output voltage
const float minPSI = 1.93; //min pressure
const float GRAD = (maxV - minV) / (maxPSI - minPSI);
//prototypes
const float ATMOSPHERE = 14.69;
float peak;
void boostDisplay ();
void setup() {
Serial.begin(9600); //serial com
Wire.begin(); //wire library
display.begin(SSD1306_SWITCHCAPVCC);
display.clearDisplay();
display.display();
peak = 0; //resets peak boost value to 0 psi
}
void loop() {
boostDisplay (); //calculates current and peak boost
}
//Boost calculations and display
void boostDisplay (){
// Convert raw input value to voltage
int sensorValue = analogRead(0);
float voltage = sensorValue / 1024.00 * 5.00;
//Calculated in PSI
float pressure = (voltage - maxV + GRAD * maxPSI) / GRAD - ATMOSPHERE;
if (pressure > peak){
peak = pressure;
}
// print out the value you read:
//
//Display values
display.clearDisplay();
display.setTextColor(WHITE);
display.setTextSize(1);
display.setCursor(0,0);
display.print(" Wiescoast Customs ");
display.print("Peak ");
display.print(peak);
display.println(" PSI");
display.setTextSize(2);
display.setCursor(65,17);
display.print(pressure);
display.display();
Serial.println(voltage);
}