Introduction: Arduino Easy Weather Station With BME280 Sensor

Picture of Arduino Easy Weather Station With BME280 Sensor

Dear friends welcome to another Arduino project tutorial!

In this tutorial we are going to take a first look at the new BME280 sensor, a new very interesting sensor. We are going to build a simple but very accurate weather station project. I have built a similar project 2 years ago, using different sensors. Now that we have a new sensor available which makes things easier, it’s time to update the project. As you can see, on the LCD display we can see the temperature, the humidity and the barometric pressure. The readings are updated every two seconds. This is a very easy project to build so it is ideal for beginners! Let’s build it!

Step 1: Get All the Parts

Picture of Get All the Parts

The parts needed in order to build this project are the following:

The cost of the project is around $18.

Step 2: BME280 Sensor

Picture of BME280 Sensor

The BME280 in a new great sensor from Bosch. So far I was using the BMP180 sensor which can measure temperature and barometric pressure. The BME280 sensor can measure temperature, humidity and barometric pressure! How cool is that! We just need one sensor to build a complete weather station!

In addition to that, the sensor is very small in size and very easy to use. The module we are going to use today, uses the I2C interface so it makes communication with Arduino very easy. We only to connect power and two more wires to make it work.

There are already many libraries developed for this sensor so we can use it in our projects very easily!

The cost of the sensor is about 5$.

You can get it here ▶ http://educ8s.tv/part/BME280

NOTE: We need the BME280 sensor. There is also a BMP280 sensor which does not not offer humidity measurement. Be careful to order to sensor you need.

Step 3: LCD Shield

Picture of LCD Shield

The LCD shield is a very useful shield. It offers a 16x2 LCD display along with some buttons. It also offers a potentiometer which controls the contrast of the display.

Althouth there is not much going on on this shield, it great shield in my opinion. You can easily connect it to an Arduino and display something on it at once. You don't even need to install a library to make it work. The LiquidCrystal library that is required was installed on your machine when you installed the Arduino IDE.

If you are new to Arduino, or if you need an easy to use display to start prototyping with it, this LCD shield is what you need. In addition to that, it costs less than 5$!

You can get it here ▶ http://educ8s.tv/part/KeypadShield

Step 4: Connecting the Parts

Picture of Connecting the Parts

Let’s connect the sensor to Arduino.

We are using the Arduino Mega today but you can use the Arduino Uno as well if you solder some header pins to your LCD shield. The Arduino Mega make things easier for beginners.

At first we connect the LCD shield to the Arduino Mega. It is very easy, you connect just like any other shield.

Then we connect the Vin pin of the sensor to the Arduino Mega 5V output. Next we connect the GND pin of the sensor to the Arduino Mega GND. The next step is to connect the SCL pin of the sensor to the SCL pin of the Arduino Mega, and the SDA pin of the sensor to the SDA pin of the Arduino Mega. Check the attached photos.

That’s it, if we load the code and power up the project we can see that after 2 seconds the readings from the sensor are displayed on the screen. Our project is ready! You can now build your own enclosure for it, and you have a very accurate weather station! Let’s now take a look at the code of the project.

Step 5: The Code of the Project

Picture of The Code of the Project

The code of the project uses 3 libraries. We need to download 2 of them, since the 3rd one is already installed with the Arduino IDE.

We need to download the

  1. Adafruit BME280 library ▶ https://github.com/adafruit/Adafruit_BME280_Library
  2. Adafruit Sensor library ▶ https://github.com/adafruit/Adafruit_Sensor

In order to see how to install the libraries watch the attached video, where I explain how to do it.

Now that we have installed the libraries we need to define the altitude for our location in meters in order to get accurate barometric pressure readings.

<p>#define ALTITUDE 216.0 // Altitude in Sparta, Greece</p>

As you can see, the code is very simple.

<p>void setup(void) {</p><p>  lcd.begin(16, 2);
  lcd.print("Reading sensors");</p><p>   bool status;
    
    // default settings
    status = bme.begin(0x76);  //The I2C address of the sensor I use is 0x76</p><p>    if (!status) {
        Serial.println("Could not find a valid BME280 sensor, check wiring!");
        while (1);
    }
}</p>

At first we initialize the sensor and the display.

Then in the loop function the read the sensor every 2 seconds. After reading the sensor we print the values on the display.

<p>delay(2000);</p><p> getPressure();
 getHumidity();
 getTemperature();
 
 lcd.clear(); 
 //Printing Temperature
 String temperatureString = String(temperature,1);
 lcd.print("T:"); 
 lcd.print(temperatureString);
 lcd.print((char)223);
 lcd.print("C ");</p>

In this version of the code we display the temperature in degrees Celsius but I have also prepared a version of the code with the temperature measured in degrees Fahrenheit. You can find both versions of the code of the project attached to this Instructable.

Step 6: Final Thoughts

Picture of Final Thoughts

That’s today’s project. An Arduino Weather Station project with the new BME280 sensor.

The new BME280 sensor is very easy to use since it uses the I2C interface. I am going to use it a lot in the future projects because it offers temperature, humidity and pressure sensors in one package. This makes our weather station projects easier to build and more compact. I would love to hear your opinion about this sensor. Are you going to use it any of your projects? If yes, what kind of projects are you going to build using this sensor? Please post your ideas below, I would love to read them. Thanks!

Comments

pedervanroest (author)2017-08-08

I designed and 3d-printed an enclosure for it as well. I am very happy with the result, but I have to figure out why my temperature-readings seems to be too high.

Thank you for a great instructable (great project, great description, easy to follow along!).

Pikkemoos made it! (author)2017-07-05

Nice...

norbs (author)2017-06-05

For UNO users, SDA/SCL can be seen here.

aarthi (author)2017-05-23

Thanks. I want to have this placed in a case. What material do I need to use?

norbs (author)2017-05-20

Any way to log the data?

ThirdEarthDesign (author)2017-05-14

Excellent project, thanks for sharing :-)

IgorF2 (author)2017-05-13

Great Instructable.
I've made anexo Arduino Uno Weather Station with other sensors. Maybe it can help you:

https://www.instructables.com/id/Arduino-UNO-Mini-Weather-Station

About This Instructable

4,076views

85favorites

License:

Bio: I am Nick Koumaris from Sparta, Greece. I'm extremely passionate about electronics, making things and design. I love teaching what I know and sharing ... More »
More by educ8s:Arduino Temperature Monitor and Real Time Clock With 3.2" DisplayArduino TEA5767 FM Radio ReceiverArduino Weather Station With a Nextion Display
Add instructable to: