Introduction
This tutorial will show you how to connect a BME280 pressure sensor to your Arduino.
This unit combines high-accuracy temperature, barometric pressure, and humidity sensors and supports both I2C and SPI. I have included wiring diagrams and example codes to help you get started.
The BME280 sensor is beneficial for monitoring temperature, humidity, and pressure.
You can use BME280 sensors in applications such as Heating Ventilation and Air Cooling (HVAC), fluid level, flow sensing and much more.
This article has two sections. You will understand the BME280 sensor pinouts, the operating range, and the sensor’s accuracy in the first part of the article.
The second section will show you how to connect it to the Arduino and the example codes to read the sensor values.
Components Needed To Connect BME680 To Arduino
Hardware Components
- Arduino Uno Rev3 x 1
- BME280 sensor x 1
- Dupont wire x 4
- Arduino USB cable (for powering and programming) x 1
Software
You will be able to read the BME280 sensor values using the parts listed above. Let us begin!
What Is The BME280 Temperature, Humidity & Pressure Sensor?
BME280 is a combined humidity and pressure sensor. You can use the sensor to detect room change, measure height, volume, airflow, dryness in the room and more.
It helps you create weather sensing projects that can find applications in:
- indoor and outdoor weather monitoring
- heating and cooling applications and
- vertical velocity monitoring, etc.
You don’t need any complex circuitry for powering the BME280 sensor. Also, calibration is not necessary.
You use I2C to communicate with the sensor. The I2C speed of BME280 can be up to 3.4 MHz.
You can communicate with the BME280 sensor via both SPI and I2C communication. It operates in three modes.
- Sleep Mode – No operations, lowest power consumption
- Normal Mode – Periodically wake up and do measurements
- Forced Mode – On-demand measurements
BMP280/BME280 has similar pinouts and can easily be interfaced with an Arduino.
BME280 is an 8 Pin IC in a very tiny package. Here you will find the pinouts of the BME280 sensor.
The BME280 expansion boards are available. I am using the one linked in the hardware components section above.
I can easily solder a Bergstick connector to the BME sensor board and mount it on a breadboard.
In the below image, you can see all the major sections of the BME280 sensors.
The necessary pullups for the SCL and SDA lines are already present on the Arduino Board.
BME280 sensor provides two I2C addresses. They are 0x76 and 0x77. The last bit of the address is the SDO pin. Connect the SDO pin to either the GND Pin or the VIN Pin.
You can choose one I2C address by shorting the first two or the last two pads, as shown in the image below. You can either use a solder blob or a zero ohm resistor to do this.
I want to share the accuracy and the BME280 sensor’s operating range with you:
The operation range of the BME280 is as follows:
- Temperature range: -40 °C to 85 °C. Hence this can be used in a variety of applications with extreme temperatures.
- Pressure range: 300 to 1100 hPa. This range can help you build applications for indoor such as navigation, as well as in gaming.
- Relative humidity: 0 to 100 %RH. You can use the BME280 sensor to warn about the dew points, predict rain, as well as help protect buildings by monitoring the humidity present inside.
The BME280 sensor board has 4 Pins. I will brief you about the 4 Pins in the table below:
VIN | Input supply voltage. The valid range is 1.71 V to 3.6 V. Connect this to the 3V3 pin of the Arduino |
GND | Ground pin. Connect this to Arduino GND pin |
SCL | I2C Clock line (Serial CLock) |
SDA | I2C Data line (Serial DAta) |
Did you know that humidity sensor and pressure sensor can be individually enabled or disabled?
For example, if you only need to measure the temperature and humidity, then you can disable the pressure sensor.
Disabling the unwanted sensor reduces the current consumption as well as you can complete the measurements faster and take the entire product to sleep mode quickly.
Hence, this feature helps you to increase the battery life of the product.
-> Read our guide about What You Can Build with Adruino.
Step-By-Step Instructions To Connect BME280 To Arduino
I will highlight the pin details and the connections first.
The following steps will take you through a step-by-step connection guide to complete this project.
BME280 Pinout information
Arduino UNO | BME280 Board |
3.3 V | VIN |
GND | GND |
PIN A4 | SDA |
PIN A5 | SCL |
Step 1: Wiring Arduino and the BME680 Board
1) Connect GND of both Arduino UNO and BME280 sensors
Take a jumper (Dupont cable) and connect one end to the GND pin of the Arduino.
Connect the other end of the jumper to the GND pin of the BME280 sensor board.
It is always a good practice to connect GND pins first.
2) Connect another cable between the Arduino A4 pin and the SDA pin of the BME280.
3) Make the third connection between Arduino Pin A5 and SCL pin of the BME280 board.
4) Make the last connection between the Arduino 3V3 pin and the VIN pin on the BME280 module.
You will find three GND pins on the Arduino UNO. You can connect to the GND pin, which is more easily accessible.
You have completed the connections between Arduino UNO and the BME280 sensor.
Wiring the BME280 sensor with Arduino Mega is similar to earlier steps. Here are the required connection details.
The I2C lines for the Arduino Boards are present on different pins. The below table will help you find the I2C pins for the boards you have.
Arduino UNO, Ethernet | A4 (SDA), A5 (SCL) |
Arduino Mega2560 | 20 (SDA), 21 (SCL) |
Arduino Leonardo | 2 (SDA), 3 (SCL) |
Arduino Due | 20 (SDA), 21 (SCL), SDA1, SCL1 |
Step 2: How To Install Arduino Libraries Needed For BME280 Sensor
1) Open Arduino sketch and go to Tools – Click on Manage Libraries
You can use this option to install the third-party libraries which are not already there in the IDE available.
2) Search for the Adafruit BME680 library and hit Enter. You will find the Adafruit BME280 library in the results. Click on Install.
3) Also install the needed Adafruit unified sensor in the same way
4) You also need the Adafruit Bus IO library. Install it as well
5) You can find the BME280 working examples in the path given below
Step 3: I2C Arduino Code for BME280 sensor
1) Copy the following code in an empty sketch to read the sensor values in a loop
/* Adafruit library examples for BME280 sensor */ #include#include #include /* If you know the sea level pressure, the accuracy improves a lot #define SEALEVELPRESSURE_HPA (1013.25) */ Adafruit_BME280 bme; void setup() { Serial.begin(9600); /* assuming I2C address set is 0x76. If you are using 0x77, update 0x77 as the I2C address */ if (!bme.begin(0x76)) { Serial.println("No BME280 device found!"); while (1); } } void loop() { /* read all the parameters from the BME280 sensors via bme object created*/ Serial.println("Temperature in deg C = "); Serial.print(bme.readTemperature()); Serial.println("Pressure in hPa = "); Serial.print(bme.readPressure() / 100.0F); Serial.println("Altitude in m = "); Serial.print(bme.readAltitude(SEALEVELPRESSURE_HPA)); Serial.println("Humidity in %RH = "); Serial.print(bme.readHumidity()); Serial.println(); delay(5000); }
2) Description of major parts in the BME280 code
Adafruit_BME280 bme; – Creates the bme object of type Adafruit_BME280.
Serial.begin(9600); – Enable Serial communication so that the parameters can be displayed on the serial terminal.
readTemperature(); – Read the temperature in degree celsius. If you want in Fahrenheit, you can use the equation below °F = °C * 1.8000 + 32.00.
readPressure(); – Returns the Pressure measured in hPa.
readAltitude(SEALEVELPRESSURE_HPA); – Returns the height computed based on the pressure and the parameter sent.
readHumidity(); – Returns humidity in percentage. This is relative humidity and not absolute humidity.
FAQ’s About The BME280 Sensor And Arduino
In this section, you will find brief answers to the most frequent questions asked by other people while working with the BME280 sensor.
1) How accurate is the BME280 sensor?
The accuracy of the temperature sensors is ±0.5 °C. The pressure sensor has a noise range of 1.3 Pa.
The accuracy of the humidity sensor in the BME280 is ±3 %RH.
2) What is the I2C address of the BME280 sensor?
BME280 sensor can have two I2C addresses: 0x76 and 0x77.
You can set the desired I2C address for BME280 by shorting the SDO pin to either GND or VIN.
3) What is the difference between BME280 and BMP280 sensor?
BMP280 is a pressure sensor only. BME280 sensor has temperature, humidity as well as a pressure sensor
4) How do you calibrate a BME280 sensor?
BME280 sensor has factory programmed trimming values stored in its non-volatile internal memory.
You can read them but can not alter them.
The trimming values can be used to improve the sensor’s accuracy using the formulae given in the BME280 datasheet.
Projects Using BME280 Sensor With Arduino
.BME280 is an easy to use sensor. Here are the three examples of Arduino projects based on BME280:
1. Portable Altimeter and Weather Station
This is a portable ATMEGA328 based project which uses a BME280 sensor and an OLED from OSRAM to display the measured weather parameters.
By using a battery, the project is a proper mobile weather station.
2. ESP32 based mini Weather Station
In this project, ESP32 is connected to the BME280 sensor to monitor weather parameters.
ESP32 provides wireless capabilities to display the readings on a mobile app
3. A simple Weather Station built using BME280
This project demonstrates how to read the BME280 sensor data on a 20 x 4 Liquid Crystal Display.
–> Check out our guide to the Top 12 Best Arduino Online Courses
Conclusion
In this article, I covered the basics of the BME280 sensor and the various sections of the BME280 sensor board.
I also showed how to connect the BME sensor board and the Arduino to read the sensors.
I have worked with several temperature and humidity sensors, including the BME280 sensor.
I learned a lot of sensor parameters such as response time, settling time and other critical aspects of the BME280 sensors.
I will be excited to see what new applications you will find for your next project, which uses a BME280 sensor. Please share the BME280 project you built in the comments.
I would love to hear from you. Did you find this article helpful? Have you got some suggestions?
Please reply in the comments, and I will be glad to adapt them in my future articles.
Share the article with your friends too!
I am Puneeth. I love tinkering with open-source projects, Arduino, ESP32, Pi and more. I have worked with many different Arduino boards and currently I am exploring, Arduino powered LoRa, Power line communication and IoT.