I am new in Arduino and have a project for my ultralight aircraft:is to maintain, once at a certain altitude, the selected altitude, with the barometric pressure.
How? with input on the electrical trim pitch with 2 relays.
Once the Arduino is on power, that the pressure is mesured and fixed so long the arduino on power.
If the plane is going down, the pressure increases and there is a input on relay up (1 sec) with a delay of 5 sec due to the react time of the plane. If the plane is going up, the pressure decreases and there is a input on relay down (1 sec) with a delay of 5 sec and so one in the loop.
The project is based on a BMP 085 sensor and Arduino UNO with 2 relays
I wrote a sketch but I have some questions:
- The barometric pressure must be fixed at once time in the void setup but I do not know how?
- in the the void loop: if (pressure>threshold); I have the message : "pressure was not declared in this scope".
I think that the "variables" and the void setup are wrong but i can not find an answer.
This is the sketch I wrote:
#include "Wire.h"
#include "Adafruit_BMP085.h"
Adafruit_BMP085 bmp;
int threshold= pressure ,HPa// threshold to hold the bar pressure
int relayup = 2;// relay up on pin 2
int relaydown = 3;// relay down on pin 3
void setup() {
Serial.begin(9600);
bmp.begin();
int thresold = pressure,HPa // pressure read is threshold
}
void loop()
{
if( pressure > threshold);
digitalWrite(relayup,HIGH);
delay(1000);
digitalWrite(relayup,LOW);
delay(5000);
}
if( pressure < threshold );
digitalWrite(relaydown,HIGH);
delay(1000);
digitalWrite(relaydown,LOW);
delay (5000);
Serial.print("Pressure = ");
Serial.print(bmp.readPressure());
Serial.println(" Pa");
Serial.println();
delay(4000);
}
Do somebody have an idea? Thnaks for reply and suggestions.
I wrote a sketch for mesuring pressure,temp and is it OKE.
Only the pressure is always in Pa. How can I change that in HPa ?
This is the sketch:
#include "Wire.h"
#include "Adafruit_BMP085.h"
Adafruit_BMP085 bmp;
void setup() {
Serial.begin(9600);
bmp.begin();
}
void loop() {
Serial.print("Temperature = ");
Serial.print(bmp.readTemperature());
Serial.println(" *C");
Serial.print("Pressure = ");
Serial.print(bmp.readPressure());
Serial.println(" Pa ");
Serial.println();
delay(4000);
}
Thanks - jc