pressure sensor pressure equation problem

Pressure sensor (3-wire , Vcc=10VDC, COMM, Output). The output is
0-10VDC for a pressure range 0 – 250 bar (absolute)
arduino uno - Mpx4115

  • Monitor the pressure and display its value (bar) on LCD
  • A yellow warning lamp is lit if the value drops below 25 bar
  • A red warning lamp and a buzzer are on when the value exceeds 200 bar
  • The system is operated by an ON/OFF switch

I want to complete code

#include <LiquidCrystal.h>
int switc =6;
int buzzer =7;
int red_led =10;
int yellow_led =9;
int pressure_analog_pin =0; //pressure sensor connected to analog 0
int pressure_reading; //the analog reading from pressure sensor
float volt;
float pressure;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
pinMode(switc,INPUT);
pinMode(buzzer,OUTPUT);
pinMode(yellow_led,OUTPUT);
pinMode(red_led,OUTPUT);
lcd.begin(16, 2);
}

void loop() {
pressure_reading = analogRead(pressure_analog_pin);
volt=(pressure_reading5)/1023;
pressure= volt
31.3;
lcd.setCursor(0,0);
lcd.print(“pressure is=”);
lcd.setCursor(13,0);
lcd.print(pressure);
}

Is this your assignment for a class?

no its project of mecatronics introduction

Before you/we deal with program, how are you dealing with a sensor that can output +10 vdc and a AVR chip that cannot have greater then +5vdc applied to it's analog input pin without damage?

in proteus design their is no sensors except mpx4115 which get 125 kpa i want to know sensor 0-250 bar w input volatge 0-10vdc

Hi Samar

Pressure sensor (3-wire , Vcc=10VDC, COMM, Output). The output is
0-10VDC for a pressure range 0 – 250 bar (absolute)
arduino uno - Mpx4115

From the MPX4115, its supply voltage is 5V. It gives an output from about 0.25V to about 4.75V for a pressure range of 15 to 115kPa.

i want to know sensor 0-250 bar

So you are asking for recommendations for a sensor that can read up to 250 bar (which is 25,000 kPa)? Is that right?

...w input volatge 0-10vdc

And this sensor needs to run off a supply of 10V maximum? So a sensor with 5V supply would be OK?

Please confirm what help you want.

Regards

Ray

Pressure sensor (3-wire , Vcc=10VDC, COMM, Output). The output is
0-10VDC for a pressure range 0 – 250 bar (absolute)

in protus design there is no sensor read for 250 bar
what I shoul suppose to do

pressure_reading = analogRead(pressure_analog_pin);
volt=(pressure_reading5)/1023;
pressure= volt
31.3

and the equation give wrong calculation

Pressure sensor (3-wire , Vcc=10VDC, COMM, Output). The output is
0-10VDC for a pressure range 0 – 250 bar (absolute)

Which pressure sensor are you using? The MPX4115 does not give the outputs you say above, according to its datasheet.

the project just software not hardware its only design and code isis professional have 2 sensor pressure only 150 kpa - 125 kpa I want to know what I shall use to get 250 bar or tell me another simulation program have pressure 250 bar

To use a sensor that outputs 10V at 250 bar with the Arduino, you could use a voltage divider that divides the sensor output by 2. Then, 250 bar = 5 V.

The code could be:

float pressure_reading = analogRead(pressure_analog_pin);
int pressure_in_bar = 250.0*pressure_reading/1024.0;

i tried to to get the pressure but always give wrong calculation !
plz any one check code 250 bar 10 vdc

#include <LiquidCrystal.h>
int buttonState = 0;
int switc =6;
int buzzer =7;
int red_led =10;
int yellow_led =9;
int pressure_analog_pin =0; //pressure sensor connected to analog 0
int pressure_reading; //the analog reading from pressure sensor
float volt;
float pressure;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
pinMode(switc,INPUT);
pinMode(buzzer,OUTPUT);
pinMode(yellow_led,OUTPUT);
pinMode(red_led,OUTPUT);
lcd.begin(16, 2);
}
void loop() {
buttonState = digitalRead(switc);
if(buttonState == HIGH){
pressure_reading = analogRead(pressure_analog_pin);
volt=(pressure_reading250)/1023;
pressure= volt
31.3;// wrong equation
if(pressure <25){ // if the pressure smaller than 25
digitalWrite(yellow_led, LOW); // turn an yellow LED on
}
else if(pressure > 200){// if the pressure great than 225 bar
digitalWrite(red_led, HIGH);// turn an red LED on and make sound
digitalWrite(buzzer, HIGH);}
lcd.setCursor(0,0);
lcd.print(“pressure is=”);
lcd.setCursor(13,0);
lcd.print(pressure);
}
else {buttonState = LOW;}
}

Does this improve the results you get? The decimal points force the constants to be treated as float, and (float) does the same for the integer analogRead() value.

volt = 10.0 * (float)pressure_reading / 1023.0; // "full scale" analogRead equates to 10V output from sensor
pressure = 250.0 * volt / 10.0 ; // 10V output from sensor equates to 250 bar

If it works, you could simplify to:

pressure = 250.0 * (float)pressure_reading / 1023.0; // "full scale" analogRead equates to 250 bar