The BlueDot BME280 Weather Station is the best way to measure temperature, humidity, pressure and altitude with an Arduino. Being developed for mobile applications, the BME280 sensor from BOSCH combines high precision and low power consumption in a very small package.
Here are 5 features that make the BlueDot BME280 Weather Station very easy to use:
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 the BME280 on the I2C bus is very easy. The first step is to connect the board to the power supply.
Great! Now we need to connect the sensor to the I2C bus. The I2C communication uses basically 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.
Do you need to read two BME280 sensors on the I2C bus at the same time? You don't need to figure this out for yourself, because we already did that! Just take a look at this tutorial we prepared for you.
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.
Unlike the I2C protocol, the SPI communication uses 4 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.
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.
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.
You know what is the best part of using SPI communication? You can read multiple sensors at the same time, way more than just two, if you want! Take a look at this tutorial to see how that works!
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 just click on this link to get it directly from our Website!
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 I2C, 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 (I2C), 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 using connecting the BME280 using the I2C communication? Then we need to write into the program, which I2C address we need to use. If you left the SDO pin unconnected, then you are using the default I2C address (0x77). If the SDO pin is connected to GND, then you are using the alternative I2C 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.
Here is an overview of the functions available for the BME280 sensor:
bme280.readTempC(); bme280.readTempF(); bme280.readHumidity(); bme280.readPressure(); bme280.readAltitudeMeter(); bme280.readAltitudeFeet();