BlueDot BME280+TSL2591 Advanced Weather Station
The one thing that the BME280 sensor cannot do, is measure light! Well, we can fix that. The BlueDot BME280+TSL2591 Advanced Weather Station combines two awesome sensors in one board! While the BME280 measures temperature, humidity, pressure, and altitude, the TSL2591 measures illuminance with great sensitivity. Now let’s get started with the BlueDot BME280+TSL2591 and take our first steps with the two sensors.
The sensors TSL2591 and BNO055 do not work together. They share the same I²C addresses (0x28 and 0x29). Despite using only the address 0x29 for the I²C communication, the sensor TSL2591 also reserves the address 0x28 all the time. If you wish to use the BME280+TSL2591 board with the BNO055 board, please consider using an I²C multiplexer.
The first step with the BME280+TSL2591 Advanced 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.
Here are five features that make the BlueDot BME280+TSL2591 Advanced Weather Station so awesome:
- Light, Temperature, Humidity, Pressure, and Altitude Measurements. You can measure illuminance, 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 and the TSL2591 sensors.
I²C Communication. Using the I²C communication you need no more than two wires to transfer data from and to your board.
- Data Transfer with both 5V and 3.3V devices. While devices like the Arduino Uno interpret a 5V signal as a logic HIGH, the BME280 and the TSL2591 use 3.3V as a logic HIGH. The onboard logic level converter translates the 5V signals into 3.3V signals and vice-versa.
- BlueDot BME280 TSL2591 Library for Arduino. Yes! You don’t need to struggle with any datasheet! With the BlueDot BME280 TSL2591 Library, you can start measuring right away. Download the library from the Arduino IDE, Github, or our Website.
This quick start guide on the BlueDot BME280+TSL2591 will show you how to take the first steps with this environmental sensor board.
Connecting via I²C
Connecting the BME280 and the TSL2591 on 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 both sensors 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 both sensors using the SDA line. Just as well, all data from the sensors go back to the Arduino through the SDA line. Because of that, the SDA line is bidirectional.
- SDI Pin. Connect the SDA 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 SCL pin from the board to the SCL line on your Arduino. This corresponds to the pin A5 on the Arduino Uno.
- INT Pin. This is the Interrupt pin from the TSL2591 sensor. You can expand on the BlueDot library to program this pin. Otherwise, just leave it unconnected.
- 3V3 Pin. This is the output from the voltage regulator. You can pull up to 100 mA from this output. Otherwise, just leave it unconnected.
Installing Arduino Library
The easiest way to start using your Advanced Weather Station is to download and install the BlueDot BME280 TSL2591 Library for Arduino. Just open the Arduino IDE and go to Sketch > Include Library > Manage Libraries… and search for the BlueDot BME280 TSL2591 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.
The board only supports the I²C communication protocol, so there is no need to choose between the SPI and I²C modes. The I²C addresses are also fixed and should not be changed.
bme280.parameter.I2CAddress = 0x77; //The BME280 is hardwired to use the I2C Address 0x77 tsl2591.parameter.I2CAddress = 0x29;
The TSL2591 light sensor allows you to change how strongly it reacts to light by changing the gain of its internal amplifier. Use lower gains when the sensor is exposed to bright light and higher gain values when the sensor is in a darker environment.
//0b00: Low gain mode //0b01: Medium gain mode //0b10: High gain mode //0b11: Maximum gain mode tsl2591.parameter.gain = 0b01;
You can also adjust the sensor’s sensitivity by changing the integration time. Setting longer integration values means that the sensor will collect light for a longer period. Just remember that a higher integration value will lead to longer measurements.
//0b000: 100ms (max count = 37888) //0b001: 200ms (max count = 65535) //0b010: 300ms (max count = 65535) //0b011: 400ms (max count = 65535) //0b100: 500ms (max count = 65535) //0b101: 600ms (max count = 65535) tsl2591.parameter.integration = 0b000;
Also remember that the light sensor is subject to saturation, which means, it can be exposed to too much light. By setting the integration time to 100 ms it will saturate at 37888 lux and for higher integration times it will saturate at 65535 lux. If the sensor becomes saturated, you may either change to a lower gain mode, reduce the integration time, or a combination of both.
This is the output from the sensor.
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 TSL2591 Library already includes functions to calculate your altitude in both meters and feet.
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 TSL2591 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.
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.
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.
A 3D model of the BlueDot BME280+TSL2591 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!