Introduction: Personal Meteorologist

Have you ever wondered if or when your meteorologist is telling the truth? Do you want a discreet, cheap, and quick way to be your own meteorologist...and maybe a little project? Look no further! This simplistic device will track the weather conditions from any location you desire and give you the ability to monitor that weather at the touch of a button.

This project will give you some practice with Flask, Raspberry Pis, GPIO sensors, and the HTML! Not only is it fun to build but it has a lot of utility. Your meteorologist may just be out of a job…


If you're planning on being your own reliable meteorologist for multiple locations, multiply each of the supplies by how many devices you'll need. However, the code to support multiple devices will differ. If you're in the process of building/testing this device, it's not necessary to have the following...however, it'd definitely be very helpful.

  • A computer monitor
  • A USB keyboard
  • Micro USB charging kit

Step 1: Wiring

Utilizing the Raspberry Pi, we need to integrate the main sensor to the Raspberry Pi’s power source so it can make the measurements we need. The main sensor used in this project, pictured above, records the temperature and humidity of the surrounding physical environment. You can use a breadboard or some other mounting device to place this sensor on and run our wires through or simply connected it via female-to-female wires directly to the pins on the Raspberry Pi device.

Following the wiring schematic shown above to properly connect the sensor to the Raspberry Pi. Note that a power source is needed, a battery pack or close proximity to a wall outlet.

Step 2: Set Up

Congratulations, your hardware has been assembled!

We're now going to start working directly with the Raspberry Pi and the software of the project. All of the following can be done on the Raspberry Pi with a keyboard and monitor or via SSH. The following libraries are necessary to ensure all software can be run on your Raspberry Pi. Using the “pip install” command to allow your software to later use the following libraries:

  • requests
  • RPi.GPIO
  • flask
  • flask_restful
  • flask_wtf
  • wtforms

Note the weather may change a few times while these libraries are installed… be patient, you are so close to unlocking your meteorologic capabilities!

Now that you have installed all of your libraries, let’s get acquainted with Flask, a lightweight framework that allows for simple communication between nodes in our project’s environment. In this project, the Raspberry Pi becomes a server. You can get comfortable with Flask with the simple application example here.

Step 3: Code and Running

Now that you have assembled the hardware and software libraries, you're ready to start constructing the project files.

Server: In this project the Raspberry Pi that is connected to the sensor acts as the server. The server waits for the user to complete a post request of the temperature, humidity, and or the graph. We created HTML templates that are configured to properly interact with the application’s request for temperature, humidity, graph, or any combination of the three (refer to template folder). Meaning that if the user only wants temperature he will not see anything regarding humidity other than the form option to get a humidity reading. Once a Post is made then the server gathers the information from the post and performs the action the user requested. The DHT sensor gets the readings which are then stored and passed in as a dictionary argument with the new html form we are rendering. The server also stores those readings to create a graph of previous readings when requested by the user.

Application: The application is sending HTTP requests to the Flask server to retrieve and render the the temperature, humidity, and a visual representation of the temperature and humidity of the last twenty-four requests set from the form at the user’s request. The Application uses a Flask Form that has three boolean input fields for each. The user can check a box for any combination of the three fields they want to see. They can not control anything other than yes/no they want to see that information. We have made a unique html file that we use to render depending on the request of the user. This is done so that only the readings that show are the ones requested by the user. We do not want the user to request temperature and have them look at an empty template for the humidity or an empty graph.

Step 4: Testing

The device is running through the file: Which brings in the file of that contains our Flask Form class that is used by the application. The server initially renders ‘sense.html’ and then waits for the user to make a request. then waits to get readings from the sensor at a moment’s notice when a GET request from the application asks for the temperature or humidity and store the previous 24 readings from the users. There is also a graph option that the user could choose which graphs the previous readings, at most 24, made by the user. You can also see that the html is only including the form options that the user can use to make another request and the readings that were requested by the user.

You should then be able to navigate to the correct URI/IP and set the proper line of communication between your application and server. You should try sending some test GET requests and ensure the sensor is responding correctly with the proper readings from your sensor. Then if your program is properly tracking the weather on the hour, we're officially ready to delete cable -- that is if you were hanging on for the weather channel!

Step 5: Mounting

Mounting the device is pretty self-explanatory. Basically, you just have to ensure that the device is connected to the battery pack or a power outlet and use command strips to secure the device in your desired location to monitor the weather.

Note: the device must be positioned with the sensor safe from the fierce weather conditions of your location. Once this is completed, you should be able to SSH into the device and begin running the server. Open the website and know you are getting the most up to date weather measurements from the location your Raspberry Pi server has been placed.

Raspberry Pi Contest 2020

Participated in the
Raspberry Pi Contest 2020