Pressure regulation project

Hi everyone,

I'm quite new to Arduino and have recently started a project:

I want to monitor & control air pressure by an Arduino.

the Arduino is hooked up to a pressure sensor, witch feeds the arduino with data.
The Arduino processes this data and controls a 5v relay board, that switches the 12v compressor on or of.

I want it to switch on at <= 0.6 MPa (6 Bar) an switch of at > 1.0 MPa (10 Bar)
If compressor switched of because of reaching 1.0MPa then I just want it to start again at 0.6MPa, not somewhere in between.

I can read the data from the sensor, but can't get it to work right with the relay board...
I hope someone can help me!

Roy

this is my code:

[code]
/*macro definition of sensor*/
#define SENSOR A0                                             //the YELLOW pin of the Sensor is connected with A0 of Arduino/OPEN-SMART UNO R3
int relayPin = 8;

void setup()
{
                                                               //Innitiate Serial Communication
 Serial.begin(9600);
 pinMode(relayPin, OUTPUT);
   
    
}                                                              //close setup

void loop()
{
// Sensor output
    int sensorVal=analogRead(A0);

    float voltage = (sensorVal*5.0)/1024.0;
    float pressure_pascal = (3.0*((float)voltage-0.47))*1000000.0;
    float pressure_bar = pressure_pascal/10e5;
    Serial.print("Pressure = ");
    Serial.print(pressure_bar);
    Serial.println(" Bar");

// Compressor off:
      if (pressure_bar >= 0.10);{
      digitalWrite(relayPin,LOW); 
      }
// Compressor on:
      if (pressure_bar <= 0.05);{
      digitalWrite(relayPin,HIGH); 
      }
    delay(200);
      
}

[/code]

What does the code actually do when it runs?
Why not put a couple of print statements in where you try to turn the compressor on and off?
The pressures in bar in the code don't match the pressures in bar in your question, which are right?

Ardy, thanks for your quick reply!

The code does read the sensor value righ, it however does not switch on/of the relay when the right pressure is reached.

the lower pressures in the code i'd use for testing, so that i could blow in the sensor to simulate some pressure.

Roy093:
...

the lower pressures in the code i'd use for testing, so that i could blow in the sensor to simulate some pressure.

I would put print statements within the 'if' statements as suggested.
Also instead of connecting the relay just connect an LED to start.
When you are not blowing into the tube what reading in bar do you actually see?
Presumably when you blow the pressure goes above 0.1 Bar.
If you can get the LED to work then the problem must be with the way the relay is wired.