Need help with sketch?

Hi all

I have built a Arduino UNO powered Weather Station. I am trying to introduce sensors with both 3.3 & 5 volt supplies, i have introduced a Logic Level Shifter to get round the different power problem, but i still cannot get the BMP180 to display the Air Pressure on the LCD. Everything else, the Clock, the DHT22 & the LCD are OK. I have tried several things but i still cannot get the sketch to work. I have uploaded the sketch i am using and a Jpeg of my schematic, can anyone help please, i am so close to finishing this project.

//weather station master sketch

#include <Adafruit_BMP085.h>
#include <Wire.h> 
#include <RTClib.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,20,4);  // set the LCD address to 0x27 for a 16 chars and 2 line display
#include <DHT.h>
#include <DHT_U.h>
#include <Adafruit_Sensor.h>

RTC_DS1307 RTC;
Adafruit_BMP085 bmp; 

#define DHTPIN  4          // Pin which is connected to the DHT sensor.
#define DHTTYPE  DHT22     // DHT 22 (AM2302)
DHT dht(DHTPIN, DHTTYPE);  // Initialize DHT sensor for normal 16mhz Arduino

#define DS1307_ADDRESS 0x68
#if defined(ARDUINO) && ARDUINO >= 100
#define printByte(args)  write(args);
#else
#define printByte(args)  print(args,BYTE);
#endif
byte zero = 0x00; 
 
float hum;  //Stores humidity value
float temp; //Stores temperature value
uint8_t clock[8] = {0x0,0xe,0x15,0x17,0x11,0xe,0x0};

void setup()
{
  
lcd.init();
lcd.begin(20,4);
lcd.backlight();

}

void loop()
{
  
hum = dht.readHumidity();
temp= dht.readTemperature();

// Read Date and Time From RTC

DateTime now = RTC.now();

lcd.setCursor(1,0);
lcd.print(now.hour(), DEC);
lcd.print(':');
   
lcd.print(now.minute(), DEC);
lcd.print(':');

lcd.print(now.second(), DEC);
lcd.print("     ");  // six spaces
lcd.setCursor(11, 0);
   
lcd.print(now.day(), DEC);
lcd.print('/');
   
lcd.print(now.month(), DEC);
lcd.print('/');
   
lcd.print(now.year(), DEC);
lcd.print(' ');

// Read Temperature from DHT22.
  
lcd.setCursor(3,1);
lcd.print("Temp. : ");
lcd.print(temp);
lcd.print("");
lcd.print((char)223);
lcd.print("C");
    
// Read Humidity from DHT22.  

lcd.setCursor(4,2);
lcd.print("Hum. : ");
lcd.print(hum);
lcd.print(" %");

//read pressure from BMP180
 
lcd.setCursor(2,3);
lcd.print("Press. : ");
lcd.print(bmp.readPressure()/200);
lcd.print(" hPa");


}

gresleyman:
but i still cannot get the BMP180 to display the Air Pressure on the LCD.

Does that mean you can't read the pressure from the sensor or can't display the value read on the LCD? Those are two different things and you need to separate them to find the problem. Try storing the pressure read into a variable and print it both to the Serial port and the LCD.

Where are those components connected to Arduino GND?

I think you have wired the I2C level shifter incorrectly.

You are routing both lines via the same FET, but both lines should have their own FET.

I2CBi-directionalLevelShifter

i2c-level-shifter.png
i2c-level-shift-mosfet.png

i2c-level-shifter.png

i2c-level-shift-mosfet.png

Hi all.

I can read the BMP180 on the serial monitor, but not on the LCD.

Sorry i missed out the Gnd to Arduino wire, i have uploaded a newer drawing

gresleyman:
I can read the BMP180 on the serial monitor, but not on the LCD.

You don't "read" the BMP180 on either the serial monitor or the LCD. You read it using the processor and then display it on those devices. Post the code that behaves as you describe. Post the output from the Serial monitor. Leave everything else that's unrelated to the problem out of the code you post.

Does this line:

lcd.print("Press. : ");

produce output on the LCD?

Hi all.

  1. My sketch is uploaded on my original post.

  2. lcd.print("Press. : "); does not produce an output on the LCD

lcd.print("Press. : "); does not produce an output on the LCD

lcd.setCursor(2,3);
lcd.print("Press. : ");

Have you ever confirmed output on line 3 of the lcd with a simple library test sketch?