Free shipping for orders above 60 €

BlueDot BME280 Weather Station

The BlueDot BME280 Weather Station is a great way to measure temperaturehumiditypressure, and altitude. Being developed for mobile applications, the BME280 sensor from Bosch Sensortec combines high precision and low power consumption in a small package. Now let’s get started with the BlueDot BME280 and take our first steps with this sensor.

Description

Here are five features that make the BlueDot BME280 Weather Station very easy to use:

  • Temperature, Humidity, Pressure, and Altitude Measurements. You can measure temperature, relative humidity, and air pressure with high precision. Besides, the pressure measurements allow you to calculate your altitude with a precision of ± 1.0 meters.
  • 3.3V and 5V Power Supply. The onboard voltage regulator accepts anything from 2.6V to 5.5V to supply the BME280 sensor. 
  • SPI and I²C Communication. Depending on your project, you may choose between SPI and I²C protocols to communicate with the sensor. 
  • Data Transfer with 5V and 3.3V devices. While devices like the Arduino Uno interpret a 5V signal as a logic HIGH, the BME280 uses 3.3V as a logic HIGH. The onboard logic level converter translates the 5V signals into 3.3V signals.
  • BlueDot BME280 Library for Arduino. The best for last! With the BlueDot BME280 Library, you can start measuring right away. Just download the library from the Arduino IDE, Github, or our Website.

This quick start guide on the BlueDot BME280 will show you how to take the first steps with this environmental sensor.

Assembly

The first step with the BME280 Weather Station is to solder the 6-pin header that comes along with the board. The easiest way to solder the board is to insert the header into a breadboard (long pins down) and solder the short pins to the board.

Connecting via I²C

Connecting the BME280 to the I²C bus is very easy. The first step is to connect the board to the power supply.

  • VCC Pin. Connect the VCC pin from the board to either 5V or 3.3V output from your Arduino. 
  • GND Pin. Connect the GND pin from the board to the GND from the Arduino.

Great! Now we need to connect the sensor to the I²C bus. The I²C communication uses two wires. The clock signal is generated by the Arduino and transferred to the sensor through the SCL line. The Arduino can send commands to the sensor using the SDA line. Just as well, all data from the sensor goes back to the Arduino through the SDA line. Because of that, the SDA line is bidirectional.

  • SDI Pin. Connect the SDI pin from the board to the SDA line on the Arduino. This corresponds to the pin A4 on the Arduino Uno.
  • SCK Pin. Connect the SCK pin from the board to the SCL line on your Arduino. This corresponds to the pin A5 on the Arduino Uno.
  • SDO Pin. Here we have two options. Leave the SDO pin unconnected to use the default I²C address (0x77). Instead, we can connect the SDO pin to GND to use the alternative I²C address (0x76).
  • CS Pin. Leave it unconnected.

Connecting via Hardware-SPI

We can also communicate with the BME280 sensor using the SPI protocol. Just like before, the first step is to connect the board to a power supply.

  • VCC Pin. Connect the VCC pin from the board to either 5V or 3.3V output from your Arduino. 
  • GND Pin. Connect the GND pin from the board to the GND from the Arduino.

Unlike the I²C protocol, SPI communication uses four different lines. All data from the sensor is transferred back to the Arduino through the SDO line (Serial Data Output), while all commands from the Arduino are transferred through the SDI (Serial Data Input) line. The clock signal is generated from the Arduino and sent through the SCK line (Serial Clock). Finally, the CS or Chip Select line is used to tell the sensor when the communication is starting or ending.

  • SDI Pin. Connect the SDI pin from the board to the MOSI pin on the Arduino. The MOSI pin (Master Out Slave In) is located on the ICSP header.
  • SCK Pin. Connect the SCK pin from the board to the SCK pin on your Arduino. You will also find the SCK pin on the ICSP header.
  • SDO Pin. Connect the SDO pin from the board to the MISO pin on the Arduino. The MISO pin (Master In Slave Out) is also located on the ICSP header.
  • CS Pin. Connect the CS pin from the board to the digital pin 10 on the Arduino. If you like, you can use any other digital pin, just remember to change the program as well.

Not sure where the ICSP header is located? On the Arduino Uno, it is the header on the far side of the board, close to the microcontroller.

ICSP header on Arduino UNO

Connecting via Software-SPI

We can also use the SPI communication without using the ICSP header, using regular digital pins instead. In this case, the communication is called Software-SPI.

  • VCC Pin. Connect the VCC pin from the board to either 5V or 3.3V output from your Arduino. 
  • GND Pin. Connect the GND pin from the board to the GND from the Arduino.
  • SDI Pin. Connect the SDI pin from the board to the digital pin 13 on the Arduino. 
  • SCK Pin. Connect the SCK pin from the board to the digital pin 12 on the Arduino.
  • SDO Pin. Connect the SDO pin from the board to the digital pin 11 on the Arduino.
  • CS Pin. Connect the CS pin from the board to the digital pin 10 on the Arduino.
Software SPI wiring diagram for the BlueDot BME280 board

Installing Arduino Library

The easiest way to start using your BME280 sensor is to download and install the BlueDot BME280 Library for Arduino. Just open the Arduino IDE and go to Sketch > Include Library > Manage Libraries… and search for the BlueDot BME280 Library on the Library Manager. Alternatively, you can download the latest version of the library from the GitHub repository or from the official Arduino website.

Upload Example-Sketch

After installing the library we can open an example sketch. Just go to File > Examples > BlueDot BME280 Library and open the sketch BME280_Weatherstation.

So how did you connect your BME280 sensor to the Arduino? Are you using I²C, Hardware-SPI, or Software-SPI? The very first step is to put that information into the code. Just change the variable bme280.parameter.communication to 0 (I²C), 1 (Software-SPI), or 2 (Hardware-SPI). 

  //Choose between the SPI and I2C Communication protocols
  //Or leave the I2C Communication as default

  //0:        Set to 0 for I2C (default value)
  //1:        Set to 1 for Software SPI
  //2:        Set to 2 for Hardware SPI

bme280.parameter.communication = 0; //Choose communication protocol

Are you connecting the BME280 using the I²C communication? Then we need to write into the program, which I²C address we need to use. If you left the SDO pin unconnected, then you are using the default I²C address (0x77). If the SDO pin is connected to GND, then you are using the alternative I²C address (0x76). Either way, just change the variable bme280.parameter.I2CAddress to 0x76 or 0x77.

  //Set the I2C address of your breakout board  
  //Or ignore this, if you're using SPI Communication

  //0x76:       Alternative I2C Address (SDO pin connected to GND)
  //0x77:       Default I2C Address (SDO pin unconnected)
  
    bme280.parameter.I2CAddress = 0x77;                  //Choose I2C Address

If you are using the SPI communication instead, then we need to define the Chip Select (CS) pin. Per default, the digital pin 10 is programmed as the CS pin. If you want to use the digital pin 10 for something else, then you can change the variable bme280.parameter.SPI_cs to something else.

Are you using Software-SPI or Hardware-SPI? If the BME280 sensor is connected to the ICSP header, then you are using Hardware-SPI and the Chip Select Pin is the only one that needs to be programmed. Just leave the other lines on the program commented.

  //Set the pins for SPI Communication
  //Or ignore this, if you're using I2C Communication instead

     bme280.parameter.SPI_cs = 10;                         //Then you need to define the Chip Select Pin.
    
   //bme280.parameter.SPI_mosi = 13;                       //For Hardware SPI you can leave this line commented.
   //bme280.parameter.SPI_miso = 11;                       //Just comment this out for Hardware SPI.
   //bme280.parameter.SPI_sck = 12;                        //Same as before. For Hardware SPI, just comment this out.

However, if you are connecting the BME280 sensor to four digital pins, then you are using Software-SPI and we need to program all four pins. In this case, remove the comments on the three remaining lines and choose pins for the MOSI, MISO, and SCK lines.

  //Set the pins for SPI Communication
  //Or ignore this, if you're using I2C Communication instead

    bme280.parameter.SPI_cs = 10;                         //Then you need to define the Chip Select Pin.
    
    bme280.parameter.SPI_mosi = 13;                       //For Hardware SPI you can leave this line commented.
    bme280.parameter.SPI_miso = 11;                       //Just comment this out for Hardware SPI.
    bme280.parameter.SPI_sck = 12;                        //Same as before. For Hardware SPI, just comment this out.

There you go! This is the output from the Serial Monitor.

Serial Monitor Output with BME280

Precise Altitude Measurements

Since it contains an atmospheric pressure sensor and air pressure varies with altitude (I guess you already know that), you can use the BME280 as an altimeter. The BlueDot BME280 Library already includes functions to calculate your altitude in both meters and feet.

    bme280.readAltitudeMeter();
    bme280.readAltitudeFeet();  

If you run the example sketch and take a look at the altitude readings, you may wonder why the altitude values vary daily. Today you read an altitude of 550 meters, while yesterday your measured altitude was 620 meters, even though your sensor didn’t move at all. What is going on?

International Barometric Formula

Well, the BlueDot BME280 library uses the International Barometric Formula to calculate the sensor’s altitude. This equation describes the relationship between the atmospheric pressure and the altitude from sea level.

International Barometric Formula

The formula assumes an average atmospheric pressure at sea level of 1013.23 hPa and an average temperature of 15°C or 288.15 Kelvin. Because of that, you only get rough altitude estimates with these default values. So what can you do?

Just change these two default values in your example sketch. Under the setup() function you will find this section, where you can change the pressure at sea level and your local outside temperature. 

  //For precise altitude measurements please put in the current pressure corrected for the sea level
  //On doubt, just leave the standard pressure as default (1013.25 hPa)
  
    bme280.parameter.pressureSeaLevel = 1002.25;           //default value of 1013.25 hPa

  //Now write here the current average temperature outside (yes, the outside temperature!)
  //You can either use the value in Celsius or in Fahrenheit, but only one of them (comment out the other value)
  //In order to calculate the altitude, this temperature is converted by the library into Kelvin
  //For slightly less precise altitude measurements, just leave the standard temperature as default (15°C)
  //Remember, leave one of the values here commented, and change the other one!
  //If both values are left commented, the default temperature of 15°C will be used
  //But if both values are left uncommented, then the value in Celsius will be used    
  
    bme280.parameter.tempOutsideCelsius = 5;              //default value of 15°C
  //bme280.parameter.tempOutsideFahrenheit = 59;           //default value of 59°F

Mean Pressure at Sea Level

Getting the mean pressure at sea level for your location can be a little tricky. You can consider it as the atmospheric pressure at your location as if you were moved down to sea level. For example, the atmospheric pressure at the time of this writing in Munich (Germany) is about 940 hPa, and this is the value I get from the BME280 sensor. But the mean pressure at sea level for Munich now is 1001 hPa. This would be the atmospheric pressure here in Munich if it were located at sea level, and not 530 meters above it, as is the case.

The website Weather.us is a great way to find the mean pressure at sea level for your location since it contains data for countries all over the world. Click on this link to go to their website and select your city with the dropdown menus at the left side of the screen. 

Reading atmospheric pressure at sea level from website weather.us

The second parameter you need to write into the example sketch is the outside temperature at your location. This is quite easy to do since it only means measuring the air temperature in your region. In other words, how high is the temperature in your city right now?

You can measure the temperature with your BME280 sensor, of course. Just remember to protect the sensor from direct sunlight, since the board would accumulate the extra heat and distort your measurement.

A final note to the Barometric formula: it works well for the troposphere (up to an altitude of 11 km), where the air temperature drops around 0,0065 kelvin for every meter. But above that you reach the tropopause and the stratosphere, where air temperature changes differently with increasing altitude, and this formula no longer applies.

3D Model

A 3D model of the BlueDot BME280 board is available as a STEP file (click here to download). A STEP file is a CAD file format widely used for exchanging CAD files between companies and can be easily read by most (if not all) CAD software applications.

You can also view 3D models online without installing any software on your computer. The images below were taken using Autodesk Viewer, an online, free-to-use tool from Autodesk. It does require registration at Autodesk, but it is worth it!

Schematics

Leave a Reply

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