This Weather Station with Arduino was designed for the Catholic Education STEM Weather Station Challenge. We were lucky enough to be asked to build one of the basic kits provided to schools across South Australia for entry into this challenge! Anyone can build this weather station though, and we will walk you through step by step! We will be building the minimum viable product for this challenge, but there is so much more that you can do with this weather station! Measure wind speed, rainfall, dust particles in the air, UV light, and so much more! This project is meant to be a launching pad to experiment and develop on your own weather station!

Transcript

Hi, Steven here from Core Electronics, in this video I'm going to be showing you how to make an Arduino weather station.

This project was created for the catholic education STEM weather station challenge and we're going to show you how to put it all together to build a basic weather station if you're not a part of the challenge it's still a great project to make, by the time we're done we're going to have a weather station that takes temperature and humidity readings and logs them and saves them to an SD card over time. Then you can take that data later, open it up on the computer and then analyse it or do whatever you like with it.

To get started the parts that we need are an Arduino, a proto shield, an SD card module and an SD card, a real-time clock and a DHT22, now this is the temperature and the humidity sensor and we also need some jumper cables to connect everything together. So, to get started we're just going to put our proto shield on top of the Arduino it will fit right onto the pins. I have the mini breadboard that comes with the proto shield, I've removed the adhesive backing and stuck it into the middle so it's a nice small package and just a quick reminder about breadboards, all the holes that are running this direction are connected to each other so it allows us to connect things a lot more simply.

So, the first thing we're going to connect is going to be the DHT22 sensor, so this is what we take our readings from. If we're looking at the front of it, from left to right the pins go voltage, data ones not used and then ground and there's a picture of that on the tutorial page. So, I'm just going to put that in the breadboard and then we'll connect it with some wires. First of all, we'll do the voltage so the leftmost pin and on the protoboard there's a power and there's a ground rail over here and that's what we use to power and have ground for all of our different parts. So, I'll just put that into the ground rail or the power rail then we'll do the data next because it's the next one in line and the data is going to go to digital pin 2, so it's on the top edge pin 2 and then the ground we're going to skip one pin and do the ground to the ground rail.

Next thing we're going to install is our real-time clock. So, the real-time clock allows us to keep accurate track of time when we make our measurements, the Arduino can keep time a little bit but it has a high rate of error so after a short amount of time you'd be way off, the reported time would be way off with the real time is in the real-time clock is pretty accurate, it'll lose maybe a second or two a day and with the coin cell battery in there it'll last for five years keeping time.

So, to connect the real-time clock just look at the schematic here that have made. First, we’re going to connect power and ground, so ground will be the far-left pin and I'll put that into the ground rail. The 5 volts to 5 volts and then next is the SDA and SCL pins and these are aware that they transmit and receive of the data, this device uses what's called I2C or I2C and those will go to an analog pin 4 and 5 in the corner, so SDA goes to 4 and SCL goes to 5.

Next we'll connect our SD card module the SD card module has two rows of pins but they're both common so it doesn't matter which role you use I'm using the inside row for all the pins and I've just used a ribbon cable of male to female jumpers and put them all together on the board. So, the first thing we're going to connect is the 5 volts which is the blue wire on mine, your wires may be different colours so connect them accordingly. The next pin is CS so that's our clock that's going to go to digital pin 4. Next, we have the MOSI, SCK and MISO. So MOSI will go to pin 11, MISO to pin 12 and SCK to pin 13 and those are the digital pins along the top edge, we have one more one more connection to make and that's the ground wire and that will just go into our ground rail on the proto shield. So, there we have all our parts assembled for the weather station, we can put our SD card and SD card slot now and our device is ready to go.

One last thing about putting together the weather station is the housing it goes in. So, a part of the project, there's a STL file if you want to 3D print something like this housing here to be able to house your weather station in, then this will work nicely. This isn't completely waterproof so don't put it out in the rain but you could put it outside somewhere where it can take temperature readings and it'll keep it safe and protected but if you want to put it out in the rain so you add more elements to your weather station project then definitely use a waterproof case but have vents in it so the temperature sensor can still be open to the outside air. So, to put everything inside, I'm just going to connect the USB cord, which is what everything's powered off, you can also power from the 2.1mm jack. I'll slip this housing over the top and put the lid on, some of the wires stick up a bit so I found that once everything's in there just bend them down into place and set the lid on top. So, there we have it our weather station is on and taking readings.

Let's look at the code. If we look at the code in Arduino IDE, this is the basic code needed to get to your weather station running as it is right now. I strongly encourage you to add some more elements to your weather station maybe sense some wind, sense some UV, detect some rainfall and you can easily add it into this code but this is what you need to get started. So, a brief explanation of what everything's doing here, we have our libraries that we've included, you'll need to download three different libraries do your IDE to get this to work. To add a library, at the top we go to sketch, include library and then manage libraries and in the written tutorial we lay out the three different libraries that you'd need and how to find them but the first one is for the RTC. It's RTC lib, the second is the DHT library and then finally Adafruit unified sensor library and once those are added through the library manager you can include them here and your code will run properly with those resources.

Here we define our DHT sensor, define the type of DHT we're using and where it's connected, we identified the real time clock that we're using and then we move on to our setup. So, they set up a portion of the code, we open our serial connection this is allows the Arduino to communicate with the computer in real time so we can visually see the data coming through and we initialize our SD card and then this part of code checks to see if there's a file on the SD card that has data saved to it already. So, this has “DATA.txt” so if this has been running and it loses power and it comes back, it's not going to overwrite your old data it'll check to see if there's already a file there, if there's not it'll create a new one with the header with the labels of the data that you're collecting and if there's one there already it'll just add to that file and this bit of code checks to see if your real time clock is running. So, if it's the first time you've ever connected your real time clock then it may know what you're running yet and this will set the date and time to your real time clock to when you compiled this code, so it's important to rather than hitting verify and then waiting and compiling later, we’d just hit upload, it'll take the time from the computer and update the real time clock to have it, if you find that your clock is reporting the wrong times then we'll touch on that in a minute.

So, next we have our loop. We start by reading the time each time that the program runs through, we check the time and we save the temperature and humidity we then open our text file and save that information to the text file just separated by commas and then we print that data to the serial port, if your serial ports open so you could read it all on the computer and then we wait 10 seconds between each reading because the temperature doesn't change very fast you don't need to take many readings and fill up your SD card, you can spread it out and then it makes your data more meaningful and easier to work with so let's open up the serial monitor and see the data coming through from the device. Here we can see our readings being detected by the weather station, they're being transmitted to the computer over the comm port and they're coming in so we have our date, we have the time, we have the temperature that's being read and the humidity and all this data is being saved to the SD card at the same time.

To take a look at the files that are on the SD card I'm just going to unplug the weather station, take the SD card out of the SD card module and plug it into an SD card reader in the computer. So here I have the drive opened up and I see that there's a “DATA.txt” file on it if we open that we can see all our readings saved since we powered it up, to this text file in a format that's pretty easy to read but something that we can do now, since when we created the file we just made these comma separated titles and then save the numbers with no labels so we can really easily use this data by just changing the name of the file from “DATA.txt” to “DATA.csv” we'll hit yes to save that file and now when we open it, it's recognized as an excel file and it's automatically separated into its different fields so we can we can easily take this data now separate it into cells to plot it in a graph or use any of the tools to analyse the data that Excel gives us access to.

So that sums up how to make an Arduino weather station, good luck to everybody that's building them for the weather station challenge! Looks like a lot of fun and for those of you at home enjoy building a weather station to be able to monitor all the conditions in your area. Thanks for watching!

Feedback

Please continue if you would like to leave feedback for any of these topics:

  • Website features/issues
  • Content errors/improvements
  • Missing products/categories
  • Product assignments to categories
  • Search results relevance

For all other inquiries (orders status, stock levels, etc), please contact our support team for quick assistance.

Note: click continue and a draft email will be opened to edit. If you don't have an email client on your device, then send a message via the chat icon on the bottom left of our website.

Makers love reviews as much as you do, please follow this link to review the products you have purchased.