ESP32 Weathercloud Weather Station

by Jakub_Nagy in Circuits > Sensors

57802 Views, 447 Favorites, 0 Comments

ESP32 Weathercloud Weather Station

1.jpg

Last year, I published my biggest Instructable to date called Arduino Weathercloud Weather Station. It was very popular I would say. It was featured on the Instructables homepage, Arduino blog, Wiznet museum, Instructables Instagram, Arduino Instagram and also on Weathercloud Twitter. It even was one of the top 100 Instructables of 2018! And that was a very big deal for a small maker like me. I was pleased to see so many positive reactions and I carefully read through every single comment and tip. For about 8 months I've been working on this new, refined station. I fixed and improved various things. I tried to make it smaller, simpler, smarter, cooler and leave the acceptable cost of 150€ (165$). The station is mounted at a robotic farm near Senec, Slovakia. Here is the current data.

I will try to explain my whole thought process here so if you just want to get right on the build just skip right to step 3.

Features:

  • measurement of 12 meteorological values
  • usage of 8 distinct sensors
  • IoT - data is public on cloud
  • 5V 500mA operation
  • communication via Wi-Fi
  • completely weatherproof
  • looks cool
  • it's DIY

Thanks very much to Lab Cafe makerspace for providing space and support while building this station. Go check them out!

Photo credit: ME (of course) + Viktor Demčák

UPDATE 7/18/2020: Hello everyone! It's been a long time. Many of you were writing to me about multiple problems with the hardware and software. The new hardware will be ready in just a couple of weeks but until then I'm releasing new firmware. This software will help eliminate some of the problems. Go to step 12 to learn more. And most importantly, enjoy!

Design

IMG_9872.jpg

Designing a weather station is a long and thoughtful process.
You have so many options to choose from. These are the main things you should think about when designing a weather station (or at least I did so):

1) BUDGET. This is pretty self-explanatory.

2) LOCATION. This is very important since it affects the installation as well as the communication technology and the required power source. Remote weather stations need long range transmitters and a self-sustainable power source such as a solar panel.

3) MEASURED VARIABLES. Do you just want to measure temperature or humidity? Then you can put the probe nearly anywhere. But if you want to measure rainfall, wind, solar radiation, UV index or other stuff related to sun or precipitation then the sensors cannot be in a shadow and cannot be blocked neither from upside or from the sides.

4) ACCURACY. Do you want your measurements to be precisely calibrated and comparable to the national weather institute or are rather amateur values enough for you?

So by now you should have a pretty good image of what you want. So let's get to the drawing board! Here are some basic rules I did think about:

1) PROTECT THE TEMPERATURE SENSOR. You absolutely need to do this. Heat can travel in so many ways it can radiate and conduct through the structure of the station itself. So try to coat all of the metal parts, and put the temperature sensor in a radiation shield. I know, my radiation station isn't perfect but it helps.

2) PUT THE WIND SENSOR HIGH UP. Wind sensors are supposed to be placed 10m high by the international standards. I don't even have the money to buy a 10m pillar so a 2m pipe above a rooftop is enough for me.

3) CLEAR AREA AROUND AND ABOVE THE STATION. If you want to measure sunlight you cannot have the sensor in a shadow. If you want to measure rainfall you cannot have something blocking the droplets. So make sure that the area around and above the station is cleared.

Let's continue. So, for my station I decided I want to measure these variables: Air temperature, ground temperature, relative humidity, atmospheric pressure, heat index, dew point, wind chill, rainfall, solar radiation, UV index, wind speed and wind direction. This is 8 sensors in total from which there are 3 small, PCB-mountable modules and 5 external probes. I will need 2 separate microcontrollers, one for handling just rainfall measurements and the second one for everything else.

I decided to put everything I can on a single PCB. I put the PCB inside a IP65 box with transparent cover, so that sunlight can pass through to the solar radiation and UV index sensors. All of the other sensors will be connected to the main control box with a cable. So that's it for my design.

Weathercloud

Snímka.PNG

"ESP32 Weathercloud Weather Station" What is Weatherclud? Weathercloud is a large network of weather stations reporting data in real time from all over the world. It's free and there are more than 10 000 weather stations connected to it. Firstly, I had my own HTML website where all the data were sent but making your own website and graphics is hard and it's much easier to just send all the data to a big cloud platform which has nice graphics and stable servers. I searched how to send data to weathercloud and I found that you can accomplish that easily by a simple GET call. The only problem with Weathercloud is that with a free account it lets you send data only every ten minutes but that shouldn't be a problem for most uses. You'll need to make an Weathercloud account in order to make it work. Then you'll need to create a station profile on their website. When you create your weather station profile on Weathercloud, you are given the a Weathercloud ID and a Weathercloud KEY. Keep these because the Arduino will need them to know where to send data.

Parts List

parts.png

OK so for this project you'll need all the stuff that's neatly listed in my Google Docs BOM right here.

.

ESTIMATED PROJECT COST: 150€/165$

Tools

_DSC0064.JPG

These tools could come in handy (though most of them are absolutely necessary):

Laser cutter

Welder

Steel saw

Wire stripper

Power drill

Battery drill

Soldering iron

Pliers

Screwdrivers

Glue gun

Multimeter

Tree drill bit

Control Board Design

ESP32 Weather Station schematic.png
ESP32 Weather Station board without ground plate.png
ESP32 Weather Station board.png

I went with a very centralized architecture. This means that everything that can be is not only in one box but on one circuit board. I recently learned how to design PCBs which is a very valuable and useful skill. All of the projects are much neater and more precise and even elegant in a way. It's also very convenient: you just send your files to China and they do all of the wiring work and ship the complete board to you. Then you just solder the components in place and you're done.

The PCB holds both of the microcontrollers in this station: ESP32 (the main control unit) and Arduino NANO (the rainfall processor). It also holds some of the sensors which include: BME280, BHT1750 and the ML8511. Then there's the DS3231 RTC module. Last but not least, there are some resistors and screw connectors.

I designed my board in Autodesk Eagle. Just download the included Gerber file called "ESP32 weather station.zip" and upload it to JLC PCB. Or if you want to edit it, you can download the "ESP32 weather station schematic.sch" and "ESP32 weather station board.brd" files and edit them in Eagle. I strongly advise enrolling the Circuit Board Design Class from Instructables first.

Soldering

_DSC0020.JPG
_DSC0023.JPG
front.jpg
_DSC0048.JPG

Okay everyone, you've all probably done this before. This beautiful board that I designed has nice silkscreen footprints printed on it. When you have that, soldering should be a piece of cake because you see exactly where goes what. There are only THT components with the standard 0.1" spacing. So, just go on and solder the board because you are clever and you can do it by yourself! It shouldn't take you more than half an hour.

UPDATE 7/18/2020: The RTC module is not required anymore. There is no need to mount it on the board. You can learn more in step 12.

Making the Radiation Shield

FEZ3WYJJ2UPFCOZ.jpeg

When I was building this, I said to myself "Alright, you've already done this two times there is not a chance you will mess it up now." And I didn't.

A solar radiation shield is a very common thing used in weather stations to block direct solar radiation and therefore reduce errors in the measured temperature. It also acts as a holder for the temperature sensor. Radiation shields are very useful but are usually made from steel and they are expensive so I decided to build a shield of my own. I made an Instructable that shows how to make a radiation shield like this.

Control Box

_DSC0012.JPG
_DSC0006.JPG
_DSC0016.JPG

The main part of this station is obviously the control box. It holds the primary and secondary microcontrollers, some of the sensors, the RTC and some passive components. All of that in a convenient IP65 package. The box has a translucent cover so sunlight can pass through to the UV and solar radiation sensors.

Before we can mount the PCB, we need to prepare the box for the cables. There are five power and data cables going in to the box. In order to sustain the waterproof properties of the station, we're going to be needing waterproof cable glands. Specifically, one PG7 for the power cable, second PG7 for the wind and rainfall sensors and the third PG11 for both of the temperature sensors. I put the bigger (PG11) gland in the center of one wall of the box and the two smaller (PG7) glands in the opposite wall. So the box altering process is as follows:

1) Mark the center for each hole with a marker.

2) Drill a small hole with a thin drill bit.

3) Slowly increase the size of the hole with a tree drill bit.

4) Clear the holes.

5) Insert and secure a cable gland in each of the holes.

PCB Mount

_DSC0031.JPG
_DSC0018.JPG
_DSC0027.JPG
_DSC0035.JPG

Since I have only the student trial version of Autodesk Eagle, I can't design PCBs bigger than 8cm. Everything fits to this board so that's fine. Only problem is with the control box. The board mounting holes included in the box are 14cm apart. This means that we are going to need a holder for the PCB. This can be a board (wooden/plastic/metal) on which we will mount the PCB. Then we will attach the holder board to the control box. This way the PCB will be secured to the control box.

You can make the holder anyway you want. You can make it manually from a plate of wood or steel, you can laser cut it (as me) or you can even 3D print it. I'm including the dimensions of the board so the choice is yours. If you have access to a laser cutter, then laser cutting it is the simplest option. You can find the laser cutter files here both in .pdf and .svg format.

As you can see I went through multiple variations of the holder. Finally, I went with the acrylic one, because it doesn't get affected by moisture (as wood) and it doesn't attract heat (as steel).

Asembly + Wiring

wiring diagram.png
_DSC0040.JPG
_DSC0043.JPG
_DSC0055.JPG
_DSC0058.JPG
_DSC0071.JPG
_DSC0078.JPG

This is going to be a pretty easy one to do, but a pretty tough one to explain because there are many small steps. Let's get right onto it then:

1) Insert all of the cables to their designated hole. Do not secure the cable glands yet.

2) Connect all of the wires from the wind sensors, rainfall sensor and from the power cable according to the included wiring diagram. Do not connect cables from the temperature sensors yet.

3) If mounted, remove the PCB mount. Then flip the PCB so that the cables are going along its bottom side. Secure the PCB mount so that the cables are secured in a sandwich between the PCB and the mount.

4) Insert and screw in the PCB mount with the PCB.

5) Secure the two smaller (PG7) cable glands. Do not secure the bigger one yet.

6) Insert and connect the cables from the temperature sensors according to the included wiring diagram.

7) Put on the top cover and screw it in place.

Be Happy

top down.png

This step is kind of a checkpoint. At this point, you should have made yourself something that looks like what you see on the picture. If that is correct, be happy. Go on, get yourself a snack and rest because this is not just one small step for a man, but a giant leap for mankind. If not, look through the previous steps and locate the problem. If that doesn't help, comment or message me.

So when you're healthy and fit again, you can move forward to the coding and debugging part.

Coding and Debugging

IMG_9456.jpg

Yaaaaay, everyone loves coding! And even if you don't, it doesn't matter because you can just download and use my code.

Firstly, you need to add ESP32 dev module to your boards manager. In order to do this, you'll need to download a JSON package and install it through the boards manager. See this tutorial by Random Nerd Tutorials.

Now you need to download all of the essential libraries. I created the ZIP archive "Libraries.zip" for you to make it simpler. Do not import the archive into Arduino IDE like a classic library. Instead, extract the archive and move all of the files to Documents/Arduino/libraries. Now you can download all four of my programs: "Wi-Fi_Weathercloud_API_test.ino", "System_test.ino", "ESP32_Weathercloud_Weather_Station.ino".

Open up "Wi-Fi_Weathercloud_API_test.ino". You will need to change a couple of things. Firstly, you will need to replace "SSID" and "KEY" with your Wi-Fi network SSID (name) and password. Secondly you will need to replace "WID" and "KEY" with your Weathercloud ID and KEY you should have from Step 2. You will also need to do the same with "ESP32_Weathercloud_Weather_Station.ino". Go on and upload the code to the ESP32. You should see the predefined data coming up on the Weathercloud website. If that is correct, continue.

Upload the "System_test.ino" to the ESP32 and the "I2C_rainfall_sender" to the Arduino NANO. Open the Serial Console of ESP32 at 115200 baud. You should now see sensor data coming in every 15 seconds on your screen. Play with the sensors. Shine a light in the solar radiation sensor, blow into the wind speed sensor, heat the temperature probe... This way you can test if everything works. If you conclude that everything is as it should be, continue.

Upload the "ESP32_Weathercloud_Weather_Station.ino" to the ESP32. If you've done everything correctly, you should see the real data from the station coming in on the Weathercloud page every 10 minutes. If this works it means that your station is now fully operational and the only thing left to do is to install it somewhere nice.

UPDATE 7/18/2020: All of the secondary/testing programs remain the same. But the main program of the weather station was upgraded. The structure of the code is much clearer than before. You can set all of the required parameters in the beginning of the code. The ESP32 is now getting time from a NTP server so the RTC module is not required anymore. Last but not least, the ESP32 is now running a deep sleep procedure when it's not measuring and sending data. This will reduce the power consumption and it will also help lengthen life of the weather station. To use the new code, just download the upgraded "ESP32_Weathercloud_Weather_Station.ino" code and the updated ZIP file with libraries (Instructables doesn't accept it so here is a Google Drive link). Enjoy!

Station Mount

IMG_9877.jpg
IMG_9900.jpg
IMG_9906.jpg
IMG_9893.jpg
front.png
IMG_9854.jpg

So after you have confirmed that your station is working you need to design and make a mount for it. It will have to be strong, durable, compact and last but not least it will have to be nice. Take this step more of a recommendation or inspiration than precise instructions. I don't know how it looks where you're going to mount it. You have to get a little more creative. But if you have a flat roof with a 5cm diameter metal pipe sticking out, go on and do as I did. This station has two boxes. So I decided to put both of them next to each other on a metal panel. It has to be mounted on a metal pipe with the diameter of 5cm. So I put a pipe with 5cm inner diameter on the bottom of the panel. Both of the wind sensors have to be far apart from the rest of the station. So put two 40cm long pipes on each side of the station and two 10cm long pipes on end of each one. The radiation shield should be mounted below the panel to provide extra shadow. For this, I put a 7 by 15 cm L bracket on the thick metal pipe.

Here are all of the needed metal parts one by one [dimensions in mm]:

1x pipe, inner diameter 50, length 300

1x panel, 250 by 300, thickness 3

1x L bracket, 75 and 150 arms

2x pipe, outer diameter 12, length 400

2x pipe, inner diameter 17, length 100

.

When you have all of these metal parts, you can weld them in place according to the 3D model I provided. Then you will need to drill all of the holes for the boxes and for the radiation shield. Then just paint it with paint for metal. I recommend going with white, because it absorbs the least heat from all of the colors. That's it you've got yourselves a station mount that you can mount your station on!

Downloads

Installation

IMG_0007.jpg
IMG_0027.jpg
IMG_0119.jpg
IMG_0069.jpg
IMG_0053.jpg

Grab your weather station, your mount and all of your tools because you'll need all of them. Get into a car (or a bus I don't care) and get to the future location of your station. Finally, you can mount the station.

Making your weather station work in your workshop is one thing, but making it work in the real-world harsh conditions is another. The installation procedure depends very much on the building you're mounting your station on. But if you have the holder from the previous step and powerful drill, it should be fine. You just need to stick the thick pipe from the mount onto the slightly thinner pipe on the roof. Then just drill through both of the pipes and secure them with a long screw. Mount all of the boxes and sensors. That's it. Your station is now successfully installed.

We did this on a rainy day. It was very difficult but we had no other option because of the contest deadline.

Power, Uplink Setup and Debugging

IMG_0038.jpg
IMG_9922.jpg
IMG_9974.jpg
IMG_9995.jpg

Your station is physically installed, but it's not online just yet. Let's do that now. You have to power the station somehow. You have to be a little creative here. You can put an adapter inside of the house and pull a cable through the window. You can bury the cable underground. You can power it via a solar panel. All that matters is that there is 5V 500mA on the pins of the power cable coming from the control box. Remember, it all has to be weatherproof! When you have your station powered, you can move on to the uplink setup and debugging.

Uplink Setup is basically getting the ESP32 to connect to your Wi-Fi network. If it's on your house, it should be fine. If it's on a garage or farther apart, you may need a Wi-Fi extender or even a custom Wi-Fi network. Then the debugging phase follows. You can just upload the final code and hope for the best but I really recommend testing each of the sensors one by one just to be sure that everything is functioning properly. Basically the same thing as in step 12. If everything works as it should, you can hit the UPLOAD button unplug the USB cable and close of the control box.

Live Happily Ever After

IMG_0197.jpg

Jeez, this was sooo last minute guys. I noticed the Sensors contest just 10 days before it ended. That same evening, I needed to make like 10 telephone calls to arrange everything required to finalize the station. It was not finished quite yet. The day we were supposed to install the station came a giant storm disrupting our plans. I needed to finalize all of the text before the station was completed. The station was finally installed just today, on the same day I published this Instructable.

There are certainly many things that could have been done better here but there are many useful things you can learn here and use them when building your own station. If you did all steps correctly, you now have a fully operational ESP32 cloud weather station. And that's something! All of the hard work paid off (I hope it did). You can see the data from my station here. If you have some questions or suggestions, I would be happy to hear them in the comment section below.

Yeah and also if you liked this project I would appreciate really much if you voted for me in the Sensors contest. Thanks so much and enjoy!!!