looking for some help with my project

Hi new poster i dont know if this is the right place to post this.

I am trying to finish up this project. I got the code from a guy a while back but i dont fully understand it and i am looking to change a few things on it.
If anyone can help please do.

This is what is going on.

  1. i want to re scale this for my 2.4 bar sensor vs his 2.5 bar sensor.
  2. i would like for it to display only whole numbers. No decimal
  3. if anyone has a full break down of the code please let me know. I understand most but i am getting lost here and there.

rawval = analogRead(0); // Read MAP sensor raw value on analog port 0

I believe this code is for reading the raw voltage of the sensor.

next is

barboost = (((rawval * 0.19) - 69.45) + 10); // Calculate boost value for the graph
This is the bar graph code. all i know is changing the +10 will change where the graph starts at 0 other then that i dont know what the "* 0.19) - 69.45)" part is. All i can say is math.

display.println(((boostmbar * 0.001) - 0.865)*14); // calibrated for a 2.5 bar sensor in Denver (+/- 1psi)

This code seems to be the one i am looking for.
It would seem to take the input voltage and do some math and output the display numbers.
The creator (which i can no longer get in touch with) says that changing the 0.865 was an offset to calibrate for sea level.

This is different from overall scaling of the sensor. So i am not sure which numbers need to be changed.

Any help anyone can give would be great. please and thank you.
original code attached.

boosttest.ino (3.5 KB)

Please read the leading topics, like "How to use this Forum", "How to attach code" etc.
I can't download Your code into my equipment, so no help this faar.

Try this:

display.println(((boostmbar * 0.001) - 0.865)*25.0/24.0/14);    // calibrated for a 2.5 bar sensor in Denver (+/- 1psi)

It looks like the author of your code is in Denver and has removed atmospheric pressure from the measurement to get the amount of boost. You'll need to replace this with your ambient pressure based on your altitude.

I would have thought that it might be better to start the arduino before the engine and then you can just measure what the atmospheric pressure is that day.

Either way, get that number into a const or variable - having the same literal number scattered around the code is asking for trouble - when you change it, one inevitably gets overlooked.

 //Arduino pro micro, .93" I2C OLED use pin 2 for SDA and 3 for SCL ***Look up i2c pins for your controller

#include 
#include 
#include 
#define sensorPin A0

int OLED_RESET = 4;
Adafruit_SSD1306 display(OLED_RESET); //driver for the screen

// bar graph

float rawval = 0; // Setup raw sensor value
float barboost = 0; // Setup value for boost bar

// peak

int boostPeakReset = 4000; // time in milis to reset peak value
float boostPeak = 0.00;
float boostMax = 0.00;
unsigned long boostPeakTimer = 0;



// log

byte count;
byte sensorArray[128];
byte drawHeight;
boolean filled = 0; //decide either filled, or dot-display. 0==dot display.


void setup()
{
  Serial.begin(9600); // start monitoring raw voltage for calibration
  display.begin(SSD1306_SWITCHCAPVCC); // 3.3V power supply
  display.clearDisplay(); // Clear the display and ram
  display.display();
  delay(2000); // display Adafruit logo for 2 seconds
  for (count = 0; count <= 128; count++) //zero all elements
  {
    sensorArray[count] = 0;
  }
}


void loop() // Start loop
{


  
  int boostmbar = map(analogRead(sensorPin), 21, 961, 100, 2600);
  rawval = analogRead(0); // Read MAP sensor raw value on analog port 0
  barboost = (((rawval * 0.19) - 69.45) + 10); // Calculate boost value for the graph



  if (boostPeak < boostmbar && boostmbar > 0.50) {
    boostPeak = boostmbar;
    boostPeakTimer = millis();
    if (boostMax < boostPeak) {
      boostMax = boostPeak;
    }
  }
  else if (boostPeak > boostmbar && (millis() - boostPeakTimer) > boostPeakReset) {
    boostPeak = 0.00;
  }


  // log 

  drawHeight = map(analogRead(A0), 0, 1023, 0, 25 );  

  sensorArray[0] = drawHeight;

  for (count = 55; count <= 128; count++ )
  {
    if (filled == false)
    {
      display.drawPixel(count, 71 - sensorArray[count - 55], WHITE);
    }
    else
      display.drawLine(count, 1, count, 71 - sensorArray[count - 55], WHITE); 
  }

  for (count = 80; count >= 2; count--) // count down from 160 to 2
  {
    sensorArray[count - 1] = sensorArray[count - 2];
  }

  //display.drawLine(55, 43, 55, 64, WHITE);
  //display.setTextColor(WHITE);
  //display.setTextSize(3);
 // display.setCursor(0, 10);
 // display.println(((boostmbar * 0.001) - 0.865)*14);    // calibrated for a 2.5 bar sensor in Denver (+/- 1psi)


  display.fillRect(0, 0, barboost, 4, WHITE); // Draws the bar depending on the sensor value

  //display.setTextColor(WHITE);
 // display.setTextSize(1);
  //display.setCursor(97, 20);
  //display.println("BOOST");

  display.setTextSize(1); //Display peak boost
  display.setCursor(97, 10);
  display.println(((boostPeak * 0.001) - 0.865)*14); // 0.97 = 970mbar atmospheric pressure correction


  if ((((boostmbar  * 0.001) - 0.865)*14) < 0) {
    display.setTextSize(1);
    display.setCursor(97, 20);
    display.println("INHG");
    display.setCursor(0, 10);
    display.setTextSize(3);
    display.println(((boostmbar * 0.001) - 0.865)*63.2);
  }
  else if ((((boostmbar * 0.001) - 0.865)*14) > 0) {
    display.setTextSize(1);
    display.setCursor(97, 20);
    display.println("BOOST");
    display.setTextColor(WHITE);
    display.setTextSize(3);
    display.setCursor(0, 10);
    display.println(((boostmbar * 0.001) - 0.865)*14);    // calibrated for a 2.5 bar sensor in Denver (+/- 1psi)


}

  delay(1);
  display.display();
  display.clearDisplay();

  Serial.print("Input from A0 is ");
  Serial.println(rawval);    // print the raw value from the sensor (0-100%)

  delay(10); // delay half second between numbers
}

Sorry about that.
I have added the code into the code area.

And @
wildbill
Basically i should start with getting the raw voltage of the sensor powered on correct?
This would be my base for 0inhg.

Ive rescaled map sensor in tuning software for cars.
But the whole input voltage to output number is new to me.

Yes, I would start by checking the voltage as various levels of boost. You need to be sure that your Arduino can handle it. Also it will be useful to figure out how to map voltage to psi.