In this tutorial, we learn how to make a Simple Weather station using Arduino & BME280 Barometric Pressure Sensor that can give real-time information of Atmospheric Pressure, Temperature & Humidity. Using BME280 we can even measure the altitude above sea level.
Overview
BME280 is fairly simple to use, pre-calibrated and don’t require extra components. You can simply start measuring relative humidity, temperature, barometric pressure & approx. altitude in no time. So here we will simply interface BME280 Barometric Pressure Sensor with Arduino and display all the measured parameters like temperature, pressure, humidity and altitude in 20×4 LCD Display. You can also add Anemometer to the project to measure the wind speed.
A weather station is a device that collects data related to the weather & environment using different sensors. There are two types of weather station, one which is having own sensors and the second type of weather station is where we pull data from the weather station servers using IoT Processor. In this tutorial, we will go for the first one, i.e. we will design our own weather station just by using only one sensor BME280.
You can check some more projects related to BME280:
1. ESP8266 & BME280 Based Mini Weather Station
2. ESP32 & BME280 Based Mini Weather Station
Bill of Materials
Following are the components required for making BME280 weather Station. All the components can be purchased from Amazon via the links given below.
| S.N. | Components | Quantity | Purchase Links |
|---|---|---|---|
| 1 | Arduino Nano Board | 1 | Amazon | AliExpress |
| 2 | BME280 Sensor | 1 | Amazon | AliExpress |
| 3 | 20x4 LCD Display | 1 | Amazon | AliExpress |
| 4 | Potentiometer 10K | 1 | Amazon | AliExpress |
| 5 | Connecting Wires | 10 | Amazon | AliExpress |
| 6 | Breadboard | 1 | Amazon | AliExpress |
BME280 Pressure, Temperature & Humidity Sensor
Bosch BME280 Humidity, Temperature & Pressure Sensor is an integrated environmental sensor which is very small-sized with low power consumption.This BME280 Atmospheric Sensor Breakout is the easy way to measure barometric pressure, humidity, and temperature readings all without taking up too much space. Basically, anything you need to know about atmospheric conditions you can find out from this tiny breakout.
This module uses an environmental sensor manufactured by Bosch with temperature, barometric pressure sensor that is the next generation upgrade to the popular BMP085/BMP180/BMP183 Sensor. This sensor is great for all sorts of weather sensing and can even be used in both I2C and SPI! This precision sensor from Bosch is the best low-cost, precision sensing solution for measuring barometric pressure with ±1 hPa absolute accuraccy, and temperature with ±1.0°C accuracy. Because pressure changes with altitude, and the pressure measurements are so good, you can also use it as an altimeter with ±1 meter accuracy. To learn more about this sensor, check BME280 Datasheet.
Features of BME280
- Interface: I2C & SPI
- Supply Voltage: 1.71V to 3.6V
- Temperature Range: -40 to +85°C
- Humidity Range: 0% to 100% rel. humidity
- Pressure Range: 300hPa to 1100hPa
- Humidity sensor and pressure sensor can be independently enabled/disabled
Applications
- Context awareness, e.g. skin detection, room change detection
- Health monitoring/well-being
- Home automation control
- Control heating, ventilation, air conditioning (HVAC)
- Internet of things
- GPS enhancement & Indoor/Outdoor navigation
- Weather forecast
- Vertical velocity indication (rise/sink speed)
BME280 Pinout
The BME280 I2C interface uses the following pins:
1. VCC: 1.71V to 3.6V
2. GND: Connect to GND
3. SCL: serial clock (SCK)
4. SDA: Serial data (SDI)
5. CSB: Must be connected to VDDIO to select I2C interface.
6. SDO: The I2C address decides the pin. If SDO connects to GND(0), the address is 0x76, if it connects to VDDIO(1), the address is 0x77. In this module, we have connected it to VDDIO, so the address should be 0x77.
I2C Interface
The module features a simple two-wire I2C interface which can be easily interfaced with any microcontroller I2C Pins. The default I2C address of the BME280 module is 0x76 and can be changed to 0x77 easily.
There are two different BME280 available in the market whose I2C address can be changed. For the module below if you remove a connection from SDO to GND, the address will change to 0x77.
There is another module available in the market which has only 4 pins. To change its I2C address Locate the solder jumper besides chip.
By default, the middle copper pad is connected to the left pad. So you need to scratch the connection between the middle and the left copper pad to disconnect them. Then you can add a solder blob between the middle and the right copper pad to join them. It allows you to set the I2C address 0x77.
Interfacing BME280 with Arduino & 20×4 LCD Display
The BME280 Barometric Pressure Sensor is interfaced with Arduino to make a simple Weather Station. Connect the SDA SCL pins of BME280 to Arduino I2C Pins, i.e. A5 & A4 Pins.
Connect the pins 1, 5, 16 of LCD to GND & Pin 2, 15 as 5V VCC. Connect the LCD pin 4, 6, 11, 12, 13, 14 to Arduino 12, 11, 5, 4, 3, 2 Pins. Use 10K Potentiometer at Pin 3 of LCD to adjust the contrast.
Source Code/Program
The Source Code/Program for Interfacing BME280 with Arduino & LCD Display is given below. You can copy this code and upload it to your Arduino Board.
But before that you need to install two libraries, i.e BME280 Library & Adafruit Unified Sensor Library. For this you can simply go to the library manager nd install these two libraries:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
#include <Wire.h> #include <Adafruit_Sensor.h> #include <Adafruit_BME280.h> #include <LiquidCrystal.h> LiquidCrystal lcd(12, 11, 5, 4, 3, 2); #define SEALEVELPRESSURE_HPA (1013.25) byte degree[8] = { 0b00011, 0b00011, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000 }; Adafruit_BME280 bme; void setup() { Serial.begin(9600); lcd.begin(20, 4); lcd.createChar(1, degree); if (!bme.begin(0x76)) { Serial.println("Could not find a valid BME280 sensor, check wiring!"); while (1); } } void loop() { Serial.print("Temperature = "); Serial.print(bme.readTemperature()); Serial.println("*C"); Serial.print("Humidity = "); Serial.print(bme.readHumidity()); Serial.println("%"); Serial.print("Pressure = "); Serial.print(bme.readPressure() / 100.0F); Serial.println("hPa"); Serial.print("Approx. Altitude = "); Serial.print(bme.readAltitude(SEALEVELPRESSURE_HPA)); Serial.println("m"); lcd.setCursor(0, 0); lcd.print("Temperature: "); lcd.print(bme.readTemperature()); lcd.write(1); lcd.print("C"); lcd.setCursor(0, 1); lcd.print("Humidity: "); lcd.print(bme.readHumidity()); lcd.print("%"); lcd.setCursor(0, 2); lcd.print("Pressure: "); lcd.print(bme.readPressure() / 100.0F); lcd.print("hPa"); lcd.setCursor(0, 3); lcd.print("Altitude: "); lcd.print(bme.readAltitude(SEALEVELPRESSURE_HPA)); lcd.print("m"); Serial.println(); delay(1000); lcd.clear(); } |
Code Explanation
|
1 2 3 4 5 |
#include <Wire.h> #include <Adafruit_Sensor.h> #include <Adafruit_BME280.h> #include <LiquidCrystal.h> LiquidCrystal lcd(12, 11, 5, 4, 3, 2); |
The sketch starts with including 4 libraries, i.e Wire.h, Adafruit_Sensor.h, Adafruit_BME280.h & LiquidCrystal.h.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 |
#define SEALEVELPRESSURE_HPA (1013.25) byte degree[8] = { 0b00011, 0b00011, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000 }; Adafruit_BME280 bme; |
Next, we define SEALEVELPRESSURE_HPA variable to calculate the altitude and create an object of Adafruit_BME280 library. The byte degree[8] is used to print the degree Symbol in 20×4 LCD.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
Serial.print("Temperature = "); Serial.print(bme.readTemperature()); Serial.println("*C"); Serial.print("Humidity = "); Serial.print(bme.readHumidity()); Serial.println("%"); Serial.print("Pressure = "); Serial.print(bme.readPressure() / 100.0F); Serial.println("hPa"); Serial.print("Approx. Altitude = "); Serial.print(bme.readAltitude(SEALEVELPRESSURE_HPA)); Serial.println("m"); lcd.setCursor(0, 0); lcd.print("Temperature: "); lcd.print(bme.readTemperature()); lcd.write(1); lcd.print("C"); lcd.setCursor(0, 1); lcd.print("Humidity: "); lcd.print(bme.readHumidity()); lcd.print("%"); lcd.setCursor(0, 2); lcd.print("Pressure: "); lcd.print(bme.readPressure() / 100.0F); lcd.print("hPa"); lcd.setCursor(0, 3); lcd.print("Altitude: "); lcd.print(bme.readAltitude(SEALEVELPRESSURE_HPA)); lcd.print("m"); |
In looping section of the code, we use following functions to read temperature, relative humidity & barometric pressure from the BME280 module.
readTemperature() function returns the temperature from the sensor.
readPressure() function returns the barometric pressure from the sensor.
readAltitude(SEALEVELPRESSURE_HPA) function calculates the altitude.
readHumidity() function returns the relative humidity from the sensor.
Video Tutorial
There is an upgraded version of BME280 Sensor called BME680 Sensor, that can also measure Index of Air Quality (IAQ) & can be used to measure Air Quality as well.
And if you are looking for the BME280 alternative then you can use MS5611 Sensor which can also measure temperature, pressure and altitude.
















1 Comment
I encourage you to read website http://www.simplyclime.pl. Enables connection of the weather station with the mobile application.