Interfacing BMP280 with ESP8266 on I2C with errors and solutions

Interfacing BMP280 with ESP8266 on I2C with errors and solutions Interfacing BMP280 with ESP8266 on I2C with errors and solutions

In this quick tutorial, we are going to learn, how to interface BMP 280 with ESP8266 [NodeMCU] 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:

  • 1X ESP 8266 NodeMCU WiFi development board
  • 1X BMP280 Temperature, barometric pressure and approx altitude sensor
  • Few connecting wires
  • Micro USB cable

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 pressure sensing stage is similar to the BMP280 sensor, and therefore superior to the BMP180. Regarding the relative humidity sensor, 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: Climate Monitoring, Health / Fitness Monitor, Home Automation or Domotics 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 ESP8266 on I2C communication

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

bmp280 with esp8266 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 ESP8266 Node MCU, we are connecting the VCC pin of BMP280 to 3.3 volts, and GND pin to GND pin of ESP8266. Next, we need to connect, SDA, and SCL pins of BMP 280 to ESP8266. but on ESP8266, those pin values are not printed. so, lets have a look on, ESP8266 pinout diagram, where SCL is on Pin D1, and SDA is on pin D2.

our nodemcu pinout circuitschools

Now lets connect, those pins to the D1 and D2. That’s it for connection. now, to upload the sample code, to display temperature and barometric pressure. We need to connect, the ESP8266 NodeMCU 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 ESP8266 NodeMCU 1.0. 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 sometimes, we may get 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 BMP280 with Node MCU ESP8266 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.