Interfacing BMP280 with ESP32 on I2C with errors and solutions

In this quick tutorial, we are going to learn, how to interface BMP 280 with ESP32 and also learn how to solve errors like  “Could not find a valid bmp 280 sensor, check wiring.” or got any garbage values instead of the sensor values, while interfacing them.

Required components (Bill of Materials):

Product NameQuantityamazon logoamazon logo india
ESP 32 WiFi and Bluetooth development board1https://amzn.to/36gKUluhttps://amzn.to/3Kw2np2
BMP280 Temperature, barometric pressure and approx altitude sensor1https://amzn.to/3I6YiXAhttps://amzn.to/3HUt199
Few Connecting Wireshttps://amzn.to/3H2BV4ehttps://amzn.to/3J0WVu2
5V power supply (Micro USB or External).1https://amzn.to/3s1a8g3https://amzn.to/364yInH
You can buy the required components from the given best buy links. We choose the components according to value for money.

BMP 280 Temperature and pressure sensor Overview:

The BMP280 sensor integrates atmospheric pressure, temperature and relative humidity sensors in a single device, with great precision, low energy consumption and an ultra compact format. Based on BOSCH piezo-resistive technology with great EMC robustness, high precision and linearity, as well as long-term stability. It connects directly to a microcontroller via I2C or SPI.

BME/BMP280 pinout diagram

The temperature and pressure sensing in BMP280 sensor is more accurate and resolution with 0.01°C, it is superior to the BMP180. Regarding the relative humidity sensing, it presents an outstanding performance compared to the DHT22 or DHT21 sensors.

This type of sensor can be used to calculate altitude with great precision (barometer), making it a widely used sensor in Autopilot systems for Drones (UAVs), delivering altitude measurements with an accuracy of up to 1m. Other applications are: Room Climate Monitoring, Healthcare Monitoring systems, Home Automation and Air Conditioning.

Datasheet : link

Tech Specs:

  • Communication interface: I2C or SPI (3.3V)
  • Operating Voltage: 1.8V – 3.3V DC
  • Absolute accuracy: 1 hPa
  • Temperature range: -40 ° C to 85 ° C
  • Temperature accuracy: 1 ° C
  • Temperature resolution: 0.01 ° C
  • RH Accuracy: + -3%
  • Relative Humidity Range: 0-100% RH
  • Ultra-low power consumption

Circuit diagram of interfacing BMP280 and ESP32 on I2C communication

Here we are connecting both the boards by using only 4 connecting wires using I2C connection. For detailed connection check the blow schematic diagram.

interfacing bmp280 and esp32 circuit diagram

In the above image, BMP 280 has 6 pins, 2 pins for 3.3 volts input and Ground respectively. and another 2 pins for SCL, and SDA. As we are connecting them through i2c interface so leave the other two pins CSB, and SDO untouched.

On ESP32, we are connecting the VCC pin to 3.3 volts, and GND pin to GND pin of ESP32. Next, we need to connect, SDA, and SCL pins of BMP 280 to ESP32. but on ESP32, those pin values are not printed. so, lets have a look on, E S P 32 pinout diagram, where SDA, is on Pin D21, and SCL, is on D22.

ESP 32 pinout diagram 1
Click to enlarge

Now lets connect, those pins to the D21 and D22. That’s it for connection. now, to upload the sample code, to display temperature and pressure. we need to connect, the ESP32 with Micro USB cable to your PC, where Arduino IDE is installed.

Now lets have a look onto the PC, where we compile and execute the code. First, open Arduino IDE, and click on file-> examples -> BMP 280 library and click on Bmp 280 test, to load the sample code.

If you don’t find this, you need to download and install, Adafruit Bmp 280 library, Link here

So, below is the code, which mention, i2c connection, and initializing the bmp280, and printing the values on serial monitor.

bme/bmp280 sample code

Before uploading, select the board as ESP32 Wrover module. and select, the COM port of the device. you can get that, from the device manager ports. now press, the upload button.

After compiling and uploading. Open serial monitor, to check the output. Select the correct baud rate of serial monitor, mentioned in the code.

But unfortunately, we got an error, saying, “Could not find a valid bmp 280 sensor, check wiring.”

Could not find a valid bmp 280 sensor esp 32

To solve this, first we need to find the, i2c address of the bmp sensor, with i2c scanner, like our previous tutorials, link for the code here. upload the code, and open serial monitor, to check the i2c address, where it was 0x76. note it down, and get back to our previous sample code, and type the address, in the sensor initialization line, as shown.

Now upload the code again, and check the serial monitor, where the sensor value like temperature, barometric pressure and approximate altitude is printed as shown in the below image.

output for BMP280 interfacing esp32

Video Tutorial:

Interfacing BMP 280 with ESP32 with error solutions - CircuitSchools

Thanks for watching. If you like this tutorial, please like, share, and subscribe to our channel, circuit schools, to help us make, more interesting projects and tutorial videos.

1 comments
  1. Nice tutorial. However, I struggled quite a while to make it work. Solution was to connect SDO to 3.3V.

Leave a Reply

Your email address will not be published. Required fields are marked *