Weather Conditions Powered by Arduino

I have been playing with Arduino builds for about 2 months now, off and on. Most recently I setup my first combo tutorial project, where I mixed 2 tutorials into one project. It was a great first step to reading weather conditions powered by Arduino! I have some plans for a much bigger project but, for me, this was more about combining 2 working projects into one.

This build will allow you to get a readout of temperature, air pressure, altitude (sort of) and humidity. At the end of this article is a video of the final output. Feel free to skip on down, check it out, then come back to see how its all done. I don’t have much experience at all with electronics, just what I’ve picked up over the few weeks I’ve been playing with my Arduino UNO. I got a great starter pack, from eBay, a couple of months ago. Also, I followed a lot of the Arduino built in tutorials and got my mind around how everything works, on a basic level. It was time to upgrade my DIY electronics skills and put what I already learned together.

It takes almost no effort to find Arduino parts and tutorials with a quick Google search. Almost everything from this project was bought from eBay and recently I found the seller alice1101983. The thing I like about this seller is that they ship your order in full, as 1 order. Not in separate pieces and that’s helpful here in Croatia, where the post office likes to charge you almost $1 for anything marked “small packet”, which is a lot of things from China. But I digress. I wanted to mention this seller as I’ll be using some of their images in this article.

First things first…

Parts Required:

  1. Arduino UNO (linked to eBay starter kit)

    arduino-starter-kit
    I suggest getting an Arduino as part of a starter kit.
  2. Breadboard
  3. 10K Pentometer
  4. 330 Ohm resistor
  5. Solderless Breadboard Cables
  6. LCD Display (16 x 2)
  7. Breakout Temperature Humidity Barometric Pressure BME280 Digital Sensor Module
BME-BMP280
BME-BMP280 (links to eBay)

All items listed above are part of the starter kit I have linked to, with the exception of the last item. I decided to get this sensor after some research and after playing with my starter kit. Its a great all around sensor, although finding libraries that worked with it in Arduino was a bit of a challenge.

In the end it was a YouTube video that I followed on how to hook up this sensor to the Arduino. It was odd that I can see on eBay that so many of these were sold, yet finding support for them was not easy. Even finding that someone was talking about the same part was difficult. Most things I found on forums, via Google of course, were for slightly different parts that are named the same and do the same functions.

Here’s a link to the library I used in my current project. Its on GitHub so, its an easy download. However, I find the method for getting an altitude value is a little out of wack. One day I’m at 240m the next day only 140m. I was never sure how you could calculate altitude from air pressure in the first place.

The other tutorial that I based this project from was a standard display tutorial for an LCD. You can find them anywhere, an example of more of the norm for parts of Arduino’s and in stark contrast to my sensor. Here’s a link to an example from Arduino’s webpage. You will see variations in my code below, as I progressed in my LCD knowledge.

You will also need the Arduino compiler installed on your PC of course. If you’re a real newbie to Arduino, you connect it to your PC via USB in order to send new code and power to your testing builds.

Weather Conditions Powered by Arduino
In the beginning…

The code was a little tricky at first, but after a short while it was doing exactly what was required, it was displaying the information I asked for. Originally I coded it to just display as much as possible on one screen, as seen in the image above. I’m using a 16 x 2 LCD screen. 16 characters per line on 2 lines. Later I learned how to blank the screen and place new data. I gave it a 2 second delay, which is long enough to read it, but not so long to slow down cycling through every option. Here’s the code, which I’m overly happy with as it works great.

// include LCD libraries
#include <LiquidCrystal.h>

// initialize the LCD library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

// include weather sensor libraries
#include <Seeed_BME280.h>
#include <Wire.h>

BME280 bme280;

void setup()
{
 //LCD Code
 // set up the LCD's number of columns and rows:
 lcd.begin(16, 2);
 // Print a message to the LCD.
 lcd.setCursor(2, 0);
 lcd.print("Miles' House");

 lcd.setCursor(2, 1);
 lcd.print("Weather Now");

 delay(2000);
 lcd.clear();
 
 //Weather Code
 if(!bme280.init()){
 lcd.print("Device error!");
 }
}

void loop()
{
 //Weather Code
 //print Tempurature data
 lcd.setCursor(6, 0);
 lcd.print("Temp");
 
 //print Tempurature to 2nd Row of LCD
 lcd.setCursor(5, 1);
 lcd.print(bme280.getTemperature(),1);
 lcd.print(" C");

 delay(2000);
 lcd.clear();

 //Print the Air Pressure data

 lcd.setCursor(2, 0);
 lcd.print("Air Pressure");
 lcd.setCursor(4, 1);
 lcd.print(bme280.getPressure());
 lcd.print(" Pa");

 delay(2000);
 lcd.clear();
 
 //Print the Altitude data

 lcd.setCursor(4, 0);
 lcd.print("Altitude");
 float pressure;
 pressure = bme280.getPressure();
 lcd.setCursor(4, 1);
 lcd.print(bme280.calcAltitude(pressure),2);
 lcd.print(" M");

 delay(2000);
 lcd.clear();
 
 //get and print humidity data
 lcd.setCursor(4, 0);
 lcd.print("Humidity");
 lcd.setCursor(6, 1);
 lcd.print(bme280.getHumidity());
 lcd.print("%");

 delay(2000);
 lcd.clear();
}

I’ll get to a short video of the weather conditions powered by Arduino output in a moment, but first, here’s how I set it all up in the real world. Remember, to use the code above, unedited, you will need to make the exact same connections as I have in the following diagram.

Weather Conditions Powered by Arduino
My wiring diagram. Something does’t feel right about how its grounded, but it works!

As you can see the diagram for the sensor that’s reading all the conditions is not the same as the image I showed above. It just goes along with the problems I mentioned earlier, also I’m quite new to a lot of this, including the software I used to build the layout diagram, so bare with me as I slide through this learning curve. However, the connections are labeled the same, but are in a slightly different order and this is why the wires appeared crossed. Its a straight setup on the real thing.

And finally for the output. Here’s the 12┬áseconds we’ve all been waiting for…

error: Content is protected !!