Hey there,
I'm trying to connect two BMP085 air pressure sensors to my arduino to measure the pressure difference between a room with negative pressure and the outside of that room, so i can calculate the pressure difference and monitor how big it is.
Both sensors seem to work fine if i connect only one of them. However if i start switching them on and off via XCLR they start to produce completely false output. All the readings are off. One sensor will always show too high values and one will always show too low values.
How i set it up:
2x Sensor GND to arduino GND
2x Sensor Vcc to arduino 3.3v
2 x SDA and SCL to arduino SDA and SCL
XCLR of one sensor to digital output 53, the other to digital out 51.
I'm using an arduino mega board.
Here's the code im using, i just modified the BMP085test example that adafruit included in their library. Sorry for the messy code, i'm kinda new to this still.
Adafruit_BMP085 bmp;
int internalpin = 53;
int externalpin = 51;
float rawpressint;
float rawtempint;
float avgpressint;
float avgtempint;
void setup() {
Serial.begin(9600);
if (!bmp.begin()) {
Serial.println("Could not find a valid BMP085 sensor, check wiring!");
while (1) {}
}
}
void loop() {
//readsensorinternal
pinMode(internalpin, OUTPUT);
pinMode(externalpin, OUTPUT);
int i = 0;
rawpressint = 0;
rawtempint = 0;
digitalWrite(internalpin, HIGH);
digitalWrite(externalpin, LOW); //Ext sensor abschalten
delay(100);
while(i<=15)
{
i++;
rawpressint = rawpressint + bmp.readPressure();
delay(20);
rawtempint = rawtempint + bmp.readTemperature();
}
avgpressint = rawpressint / 16;
Serial.println("Avg Press Int Sens");
Serial.println(avgpressint);
avgtempint = rawtempint / 16;
Serial.println("Avg Temp Int Sens");
Serial.println(avgtempint);
i = 0;
float rawpressext = 0;
float rawtempext = 0;
digitalWrite(internalpin, LOW);
digitalWrite(externalpin, HIGH); //Ext sensor anschalten
delay(100);
while(i<=15)
{
i++;
rawpressext = rawpressext + bmp.readPressure();
delay(20);
rawtempext = rawtempext + bmp.readTemperature();
}
float avgpressext = rawpressext / 16;
Serial.println("Avg Press ext Sens");
Serial.println(avgpressext);
float avgtempext = rawtempext / 16;
Serial.println("Avg Temp ext Sens");
Serial.println(avgtempext);
Serial.println("rawval");
Serial.println(bmp.readTemperature());
Serial.println(bmp.readPressure());
Edit: To prevent misunderstandings, the sensors are not yet installed in or outside the room, i just put them on my desk for testing right now.
Do i maybe need some sort of resistor between XCLR and arduino digital out?