BMP085 And LCD

Hi I'm building a portable weather station and I'm using a BMP085, DHT22 and an LCD. The LCD came with a backpack and uses the sda scl i2c bus on the arduino and so does the BMP. The dht works fine with the lcd but when the BMP is displaying results on the lcd, I get a lot of random results. However, the temperature reading seems to be correct. I have already done an independent bmp test with the serial monitor and that seems to work. The results that are incorrect are the pressure at sea level, the air pressure and altitude. I already had doubts about the bmp working with the lcd because they both use the i2c. The lcd is connected to the sda and scl pins on the arduino, not the a4 and a5. I am using an uno. The bmp is connected to the a4 and a5 sda and scl. Sorry if this is a very stupid question. I am very new to arduino. I have built two other projects so far (a simple robotic arm and an obstacle avoiding robot (not the kit one)) but I otherwise have very little experience.

Any help would be highly appreciated.

Thanks! :slight_smile:

Quick update: When I get it to work, I intend on using the DHT’s temperature reading, not the bmp’s. I only did a temperature reading with the bmp to see if it wasn’t working as well.

I have just realised that I should probably post the code as well. Here it is:

#include “DHT.h”
#include <Adafruit_BMP085.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

#define DHTPIN 3
#define DHTTYPE DHT22

DHT dht(DHTPIN, DHTTYPE);

Adafruit_BMP085 bmp;

int bmppress;
int bmpalt;
int bmppsl;

LiquidCrystal_I2C lcd(0x27,16,2);

void setup() {
pinMode(DHTPIN,INPUT);
dht.begin();
bmp.begin();
lcd.init();
lcd.backlight();
}

void loop() {

//DHT Reading:

float h = dht.readHumidity();
float t = dht.readTemperature();
float f = dht.readTemperature(true);
float hif = dht.computeHeatIndex(f, h);
float hic = dht.computeHeatIndex(t, h, false);

//BMP Reading:

bmppress = bmp.readPressure();
bmpalt = bmp.readAltitude();
bmppsl = bmp.readSealevelPressure();

//LCD Print:

lcd.clear();

lcd.setCursor(0,0);
lcd.print("Temp: ");
lcd.print(t);
lcd.print(“C”);

lcd.setCursor(0,1);
lcd.print(“Humidity: “);
lcd.print(h);
lcd.print(”%”);

delay(1600);

//----------------------------------

//DHT Reading:

h = dht.readHumidity();
t = dht.readTemperature();
f = dht.readTemperature(true);
hif = dht.computeHeatIndex(f, h);
hic = dht.computeHeatIndex(t, h, false);

//BMP Reading:

bmppress = bmp.readPressure();
bmpalt = bmp.readAltitude();
bmppsl = bmp.readSealevelPressure();

//LCD Print:

lcd.clear();

lcd.setCursor(0,0);
lcd.print(“Humidity: “);
lcd.print(h);
lcd.print(”%”);

lcd.setCursor(0,1);
lcd.print("AirPr: ");
lcd.print(bmppress);
lcd.print(“Pa”);

delay(1600);

//----------------------------------

//DHT Reading:

h = dht.readHumidity();
t = dht.readTemperature();
f = dht.readTemperature(true);
hif = dht.computeHeatIndex(f, h);
hic = dht.computeHeatIndex(t, h, false);

//BMP Reading:

bmppress = bmp.readPressure();
bmpalt = bmp.readAltitude(1);
bmppsl = bmp.readSealevelPressure();

//LCD Print:

lcd.clear();

lcd.setCursor(0,0);
lcd.print("AirPr: ");
lcd.print(bmppress);
lcd.print(“Pa”);

lcd.setCursor(0,1);
lcd.print("Altitude: ");
lcd.print(bmpalt);
lcd.print(“m”);

delay(1600);

//----------------------------------

//DHT Reading:

h = dht.readHumidity();
t = dht.readTemperature();
f = dht.readTemperature(true);
hif = dht.computeHeatIndex(f, h);
hic = dht.computeHeatIndex(t, h, false);

//BMP Reading:

bmppress = bmp.readPressure();
bmpalt = bmp.readAltitude();
bmppsl = bmp.readSealevelPressure();

//LCD Print:

lcd.clear();

lcd.setCursor(0,0);
lcd.print(“Altitude: “);
lcd.print(bmpalt);
lcd.print(””);

lcd.setCursor(0,1);
lcd.print("PASL: ");
lcd.print(bmppsl);
lcd.print(“Pa”);

delay(1600);

//----------------------------------

//DHT Reading:

h = dht.readHumidity();
t = dht.readTemperature();
f = dht.readTemperature(true);
hif = dht.computeHeatIndex(f, h);
hic = dht.computeHeatIndex(t, h, false);

//BMP Reading:

bmppress = bmp.readPressure();
bmpalt = bmp.readAltitude();
bmppsl = bmp.readSealevelPressure();

//LCD Print:

lcd.clear();

lcd.setCursor(0,0);
lcd.print("PASL: ");
lcd.print(bmppsl);
lcd.print(“Pa”);

lcd.setCursor(0,1);
lcd.print("Temp: ");
lcd.print(t);
lcd.print(“C”);

delay(1600);
}