Maker.io main logo

How to Build an Internet-Connected Weather Station

2023-12-05 | By Zach Hipps

License: See Original Project

I tend to check the weather on my phone pretty often, and the weather apps that I use are generally pretty accurate, but they're not measuring the weather conditions right here at my house. In some cases, the weather information that I'm getting could be from a weather station that is dozens of miles away. I'm going to show you how to get the most accurate weather information by building a weather station right in my own yard.

How to Build an Internet-Connected Weather Station

I've started brainstorming some ideas on which kind of measurements I want to include in this design. I don't think it would be much of a weather station if I didn't measure temperature and humidity, so I'll definitely include those. It would also be nice to measure rainfall and wind speed as well as air pressure. I think if I can get those fundamental measurements, that'll be a good start.

How to Build an Internet-Connected Weather Station

 

To measure temperature, humidity, and air pressure, I'm using the Adafruit MS8607 breakout board. This is a one-stop shop breakout board for all of those measurements. So it's going to be super convenient to include in this project. Then to measure rainfall and wind speed, I got the Sparkfun weather meter kit. This kit comes with a little anemometer and a wind vane that tells me which direction the wind is coming from. There is also a rain gauge that will measure rainfall very accurately.

How to Build an Internet-Connected Weather Station

How to Build an Internet-Connected Weather Station

These sensors need to talk to some sort of microcontroller, and I have a few options. I could connect them all up to an Arduino and read all of the measurements just fine. I plan to make this weather station connected to the Internet, so I'm going to use an ESP32 for its WiFi connectivity. To get started I need to connect all of these sensors to an ESP32 to see if I can get some measurements out of them. Before I can do that, I need to solve one little problem. The components in the Sparkfun weather meter kit have RJ11 connectors on the end, so in order to interface those with my microcontroller, I need an RJ11 connector and a breakout board. Once I have those soldered together I can connect the weather meter kit to the microcontroller.

How to Build an Internet-Connected Weather Station

Let me explain how each of the weather meter kit sensors works. The anemometer and rain gauge are pretty straightforward, while the wind vane is a little bit more complicated, as we'll see in a minute. As the anemometer spins, there's a little reed switch inside that opens and closes depending on how fast the wind speed is. As the wind speed increases, those pulses get closer and closer together. So to measure the wind speed, all I need to do is measure the amount of time between pulses. I know from the datasheet that a pulse time of one second is equivalent to a wind speed of 1.5 miles per hour. The rain gauge works very similarly. As the water fills up one side of the bucket, it gets to a point where it's too heavy and it tips over. When that happens, the reed switch inside pulses momentarily. I know that each pulse is the equivalent of 0.011 inches of rainfall.

How to Build an Internet-Connected Weather Station

How to Build an Internet-Connected Weather Station

The wind vane, on the other hand, is a lot more complicated. It has 8 reed switches spaced radially around a 360-degree circle. Each reed switch also has a different value resistor connected in series. If the wind vane is aligned perfectly with one of the reed switches, the magnet inside the vane will close only one reed switch and there will be a single resistor connected between the two output pins. On the other hand, if the vane is centered between two reed switches, the magnet will close both switches at the same time causing two resistors to be connected in parallel. This means there are a total of 16 different positions that can be measured. As the various switches open and close, the resistance between the two output pins changes. If I add an external 10k resistor, I can build a voltage divider circuit which creates a unique voltage for each of the 16 positions. These 16 unique voltage levels can be read with an ADC on a microcontroller.

How to Build an Internet-Connected Weather Station

How to Build an Internet-Connected Weather Station

I've written some basic Arduino code for the ESP32 to read temperature, humidity, and pressure readings from the MS8607, and I've got wind speed, wind direction, and rainfall measurements from the SparkFun weather meter kit. But my plan with this project was to make a WiFi-connected weather station so I set up an Adafruit.io account, and I've added some more code to stream these data to my Adafruit.io dashboard. If you are going to replicate this project, this is the point where you would have a whole bunch of options.My plan is to send this data to the National Weather Service to use in forecasting models. But you could also send it to weather apps like Weather Underground. Or if you're into home automation and you use Home Assistant, you could use this information to trigger other automations. The point is, there are a lot of options of what you can do with this data.

How to Build an Internet-Connected Weather Station

How to Build an Internet-Connected Weather Station

I'm ready to take this project outside, but right now it's tethered to a USB cable. I need to make this whole project solar-powered and put everything into a weatherproof box. The cool thing about the ESP32 Feather boards from Adafruit is that they can be powered directly using a lipo battery. I could take a simple lipo battery and plug it right in, and the whole setup would run for at least a couple of days. But after that, I'd have to recharge the battery, and since I don't want to have to do that I got a solar panel and a solar charge controller. The solar panel plugs right into the charge controller, as well as the battery and the electronics. I've tried to size the components with enough capacity to power these electronics indefinitely. The solar panel will charge the battery during the day, and there's enough capacity to keep it running overnight and even into the next day. Even if I have several cloudy days in a row and I don't get the full power from the solar panel, there's enough capacity in here to make up the difference. Once I connect all of these components, I want to ensure they're not exposed to the elements. I need a weatherproof container to keep everything dry.

How to Build an Internet-Connected Weather Station

How to Build an Internet-Connected Weather Station

How to Build an Internet-Connected Weather Station

How to Build an Internet-Connected Weather Station

How to Build an Internet-Connected Weather Station

How to Build an Internet-Connected Weather Station

How to Build an Internet-Connected Weather Station

At this point, I'm pretty much done with the weather station enclosure and now I'm ready to install it outside. I want the weather station to be positioned pretty high up in the air. But the 10-foot lengths of EMT conduit that come from the hardware store are a little bit too long. So first I need to cut it down to about 8 feet. Once I do that, I'm going to use an auger bit in a drill to start a hole in the ground and then pound it the rest of the way in. The weather meter kit will sit on top while the weather station enclosure with all the electronics will sit down below.

How to Build an Internet-Connected Weather Station

How to Build an Internet-Connected Weather Station

How to Build an Internet-Connected Weather Station

How to Build an Internet-Connected Weather Station

How to Build an Internet-Connected Weather Station

It’s been about a week since I set up the weather station, and it's been collecting data which I can see on my Adafruit.io dashboard. We had a ton of rain here and I had a little bit of a problem with water leaking into the enclosure, but it's totally my fault. I forgot to put the rubber grommet around the cable gland, which explains why there's water inside! That rubber gasket is kind of important! But I was able to install the grommet and everything works fine now. The other thing I did before closing it back up was use a heat gun to dry out the air and I put a desiccant packet inside to keep the moisture level down. As always, the design files and building materials for this project and all my other projects can be found on GitHub.

How to Build an Internet-Connected Weather Station

How to Build an Internet-Connected Weather Station

How to Build an Internet-Connected Weather Station

How to Build an Internet-Connected Weather Station

制造商零件编号 4716
STEMMA QT MS8607 HUMID TEMP PRES
Adafruit Industries LLC
制造商零件编号 SEN-15901
WEATHER METER KIT
SparkFun Electronics
制造商零件编号 5300
ESP32-S2 TFT FEATHER STEMMA QT
Adafruit Industries LLC
制造商零件编号 2926
TERMINAL BLOCK BREAKOUT FEATHERW
Adafruit Industries LLC
制造商零件编号 4401
STEMMA QWIIC JST SH CABLE 200MM
Adafruit Industries LLC
制造商零件编号 A-2014-1-4-N-T-R
CONN MOD JACK 6P6C VERT UNSHLD
Assmann WSW Components
制造商零件编号 BOB-14021
RJ11 BREAKOUT
SparkFun Electronics
制造商零件编号 4755
BATT CHRGR SOLAR 3.7V 4.2V 1.5A
Adafruit Industries LLC
制造商零件编号 5367
5V 5W SOLAR PANEL - ETFE - VOLTA
Adafruit Industries LLC
制造商零件编号 2788
CBL ASSY 1.1-1.3MM JCK-PLG 0.54'
Adafruit Industries LLC
制造商零件编号 IPG-22211
CABLE GLAND 5.08-9.91MM PG11
Bud Industries
制造商零件编号 PTR-28483-C
BOX PLASTIC CLEAR 8.6"L X 6.3"W
Bud Industries
制造商零件编号 PTX-18483-P
PLASTIC INTERNAL PANEL
Bud Industries
制造商零件编号 3814
JST PH 2 PIN CABLE MALE HEADER 2
Adafruit Industries LLC
Add all DigiKey Parts to Cart
TechForum

Have questions or comments? Continue the conversation on TechForum, DigiKey's online community and technical resource.

Visit TechForum