16x2 LCD I2C not working with BMP280 sensor

Hi everyone, this is my first time posting in this community forum,

To start off with I'm fairly new to Arduinos even when it comes to electronics, recently I've been trying to make some simple mini projects such as making and using an android app to text and display it on the LCD screen and I've had quite a success with it and it showed that the LCD is working perfectly, so in this topic, as the title says I'm trying to figure out why my LCD is not displaying the Temperature and Pressure even though the sensor is displaying values in the serial monitor from the computer.
I'm using an Arduino Uno, with the following connections :
BMP 280:

VCC with 3.3V
GND with GND
SCL with A5
SDA with A4

As for 16x2 LCD I2C screen :
VCC with 5V
GND with GND
SCL with GPIO 19 ( SCL I2C )
SDA with GPIO 18 ( SCL I2C )

Edit* (code) :

/*
 * Interfacing Arduino with BMP280 temperature and pressure sensor.
 * Temperature and pressure values are displayed on 16x2 LCD.
 * This is a free software with NO WARRANTY.
 * https://simple-circuit.com/
 */

#include <Wire.h>             // include Wire library, required for I2C devices
#include <Adafruit_Sensor.h>  // include Adafruit sensor library
#include <Adafruit_BMP280.h>  // include adafruit library for BMP280 sensor
#include <LiquidCrystal.h>    // include LCD library

// define device I2C address: 0x76 or 0x77 (0x77 is library default address)
#define BMP280_I2C_ADDRESS  0x76

Adafruit_BMP280 bmp280;

// LCD module connections (RS, E, D4, D5, D6, D7)
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);

void setup() {
  Serial.begin(9600);

  // set up the LCD's number of columns and rows
  lcd.begin(16, 2);
  
  Serial.println(F("Arduino + BMP280"));
  
  if (!bmp280.begin(BMP280_I2C_ADDRESS))
  {  
    Serial.println("Could not find a valid BMP280 sensor, check wiring!");
    while (1);
  }

  lcd.setCursor(0, 0);
  lcd.print("Temp:");
  lcd.setCursor(0, 1);
  lcd.print("Pres:");
}

char text[14]; 

// main loop
void loop()
{
  // get temperature, pressure and altitude from library
  float temperature = bmp280.readTemperature();  // get temperature
  float pressure    = bmp280.readPressure();     // get pressure
  float altitude_   = bmp280.readAltitude(1013.25); // get altitude (this should be adjusted to your local forecast)

  // print data on the LCD screen
  // 1: print temperature
  sprintf(text, "%d.%02u%cC  ", (int)temperature, (int)(temperature * 100)%100, 223);
  lcd.setCursor(5, 0);
  lcd.print(text);
  // 2: print pressure
  sprintf(text, "%u.%02u hPa ", (int)(pressure/100), (int)((uint32_t)pressure % 100));
  lcd.setCursor(5, 1);
  lcd.print(text);

  // print data on the serial monitor software
  // 1: print temperature
  Serial.print("Temperature = ");
  Serial.print(temperature);
  Serial.println(" °C");
  // 2: print pressure
  Serial.print("Pressure    = ");
  Serial.print(pressure/100);
  Serial.println(" hPa");
  // 3: print altitude
  Serial.print("Approx Altitude = ");
  Serial.print(altitude_);
  Serial.println(" m");
    
  Serial.println();  // start a new line
  delay(2000);       // wait 2 seconds
  
}
// end of code.

Are I²C addresses different?

Did you try a simple "hello world" on the LCD first?

Also, we can't see your code - don't forget the code tags

My LCD I2C Address is 0x27 and BMP 280 is 0x76, I don't know if it matters but I can't seem to find where I put my LCD I2C address in that specific code.

Because the code you linked doesn't use I2C for the LCD?

Yes, I did try "Hello, world!" and it worked, I'm new to this as soon as I figure out how to tag the code I'll post it.

Good, so everything is working. Then have another look at the example code you're using and convert it to use your I2C display. It won't be very difficult; it's only one or two lines of code that need changing.

1 Like

Thank you, it worked much appreciated!

That was quick! Nice, good job. @anon73444976 actually had the key to your solution.

Is it really a good idea to run a 3.3V device on a 5V I2C bus?

1 Like

It isn't. It may survive and it may even work fine for extended periods of time, but it's certainly a better idea to run it at 3.3V and use a logic level shifter on SCL and SDA.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.