HUM: BME280-Uncategorized

You are a beginner with Dasduino. Or electronics? A specific module caught your eye, but you do not know how to use it? Do not worry, HUM is here for you! How to Use Module (HUM) is a blog tutorials series by soldered where you will find all you need in order to begin working with your favorite module. Tutorials include: technical characteristics, work principle, instructions on how to connect module with Dasduino and the basic code. Everything else is left to your imagination.


This pressure, temperature and humidity sensor is designed and manufactured by the world-famous Bosch company. It is ideal for any type of project that in some way involves working with weather data, such as weather stations, environmental monitoring, controlling heating/cooling, but also other oppurtunities such as smart watches for fitness.

The sensor is embedded in a compact LGA casing of 2.5 x 2.5 x 0.93 mm^3 dimensions. Small dimensions and low power consumption allow the implementation of this sensor into devices such as GPS or smart watches which use batteries. It is characterized by very precise pressure measurements  (+-12 Pa), temperature (+-1 C) and humidity (+- 2%), and altitude can also be calculated from these data since it is closely related to pressure. The integrated sensor is primarily used for temperature compensation of the pressure and humidity sensors, and can also be used for estimating ambient temperature.


The basic work principle is that the sensor performs temperature, pressure and humidity measurements, and after the measurement period, the selected temperature and pressure data go through a low-pass IIR filter that removes the noise of short term pressure fluctuations caused by e.g. wind blowing directly into the sensor, door smashing, car accelerating, etc. For humidity, this type of sensor is not necessary, therefore it is not built-in.

BME280 has 3 operation modes: sleep, forced and normal mode:
Sleep mode has the lowest power consumption, no measurements are performed, and all registers are accessible
Forced mode is suitable for situations which do not require much measuring, e.g. when reading weather conditions. One measurement is performed, data is saved to registers and the sensor returns to sleep mode. That way we can reduce consumption.
Normal mode constantly performs measurements with a certain delay, i.e. inactive time we can adjust.

What is also interesting is that measurement of any of these three types(temperature, pressure and humidity) can be separately included or skipped.


Using this sensor is simple since it uses the I2C communication protocol. The I2C lines already have built-in pull-up resistors at 3.3V, so you can directly connect it to analog pins of the Dasduino. It is important that you supply the sensor with 3.3V, because it can be damaged by higher voltages.
3.3V ———–> 3.3V
GND ———–> GND
SDA ———–> Pin A4
SCL ———–> Pin A5


This code will print out data about temperature, pressure, altitude and humidity every second on the serial monitor. For this example, we need the BME280 library. If you need to remind yourselves on how to install libraries, check it on the link (here). After you have installed the library, you can also access the code straight from Arduino IDE in the “Examples” section.

#include "Wire.h"
#include "BME280.h"
uint8_t address = 0;          // default address on e-r BME280 breakout
uint8_t mode = 3;             // normal mode
uint8_t standby = 0;          // recomeded for normal mode
uint8_t filter = 0;           // filter off
uint8_t temp_overSample = 1;  // oversampling temperat x1
uint8_t humi_overSample = 1;  // oversampling humidity x1
uint8_t pres_overSample = 1;  // oversampling pressure x1
BME280 bme;
void setup()
  //Call settings before begin()
  bme.settings(address, mode, standby, filter, temp_overSample, humi_overSample, pres_overSample);
void loop()
  Serial.print("Temperature: ");
  Serial.print(bme.readTemp(), 2);
  Serial.println(" degrees C");
  Serial.print("Pressure: ");
  Serial.print(bme.readPressure(), 2);
  Serial.println(" Pa");
  Serial.print("Altitude: ");
  Serial.print(bme.readAltitude(), 2);
  Serial.print("%RH: ");
  Serial.print(bme.readHumidity(), 2);
  Serial.println(" %");