Intro: Weather Getter
Hello there, I am a student at Howest Kortrijk who studies NMCT. And with this instructable i will show you how to make a weather station a.k.a The Weather Getter. This will measure the temperature, humidity and air pressure while also showing you what time it is. All of this will also be visible on a website hosted on the raspberry pi. So without any further ado, lets begin creating our Weather Getter.
Step 1: What Do I Need?
First of all we need our components. Here are all the items that you need to make the Weather getter:
- DHT11: for temperature and humidity
- BMP180: for air pressure
- LCD display 16x2: to show your data
- Raspberry Pi: is the "computer" that makes this possible
- Breadbord: to connect everything
- Male to female jumper cables: to connect your display
- Resistor 10kOhm: is used for your DHT11
- Potentiometer: is used for your brightness of your lcd
- Flat-cabble: connects your raspberry pi to your T-cobbler
- T-cobbler: connects your raspberry pi to the breadbord
- MICRO SD card: to save your programs and files
All these items are available to buy on amazon, aliexpress, ...
For a more detailed list with prices, check the file.
The software that I use to make this:
You can choose what your casing is made of. I used wood for my casing.
Step 2: Connecting the Components
First of all we are going to connect our components. We only use 4bits LCD but thats good enough for this project. The DHT11 must be connected to a 10kOhm resistors to show reliable data. You can use the Programing fritzing to make a circuit. Here you can see a picture of how it should look like. I also added the fritzing file.
Step 3: Set Up Your Raspberry Pi
Raspberry pi is something very complex so set it up correctly.
- Download raspbian
- Extract the file and write it on to your SD Card
- This is easy using disk imagerOn your SD Card -> open "cmdline.txt"Write "169.254.10.1" at the end
You can now use your SD CardYou can now install Putty after connecting the Pi select SSH with Host name "169.254.10.1" using port 22. You can now login with the default credentials ("pi", "raspberry").
Step 4: Creating a Virtual Environment and the Database
Now we will create the virtual environment and the database where we will store the data of our Weather Getter. Make sure that you are connect to the internet with your raspberry pi!.
Follow these steps on your raspberry pi.
Connect your raspberry pi with your computer using a ethernet cable.
Connect to your raspberry pi by logging in with your IP address and Port.
Install the packages using these comands:
me@my-rpi:~ $ sudo apt update
me@my-rpi:~ $ sudo apt install -y python3-venv python3-pip python3-mysqldb mariadb-server uwsgi nginx uwsgi-plugin-python3
Now we will create our virtual environment using these comands:
me@my-rpi:~ $ python3 -m pip install --upgrade pip setuptools wheel virtualenv
me@my-rpi:~ $ mkdir project1 && cd project1 me@my-rpi:~/project1 $ python3 -m venv --system-site-packages env
And now we will install the mysql database
me@my-rpi:~/project1 $ source env/bin/activate (env)me@my-rpi:~/project1 $ python -m pip install mysql-connector-python argon2-cffi Flask Flask-HTTPAuth Flask-MySQL mysql-connector-python passlib
Now we have to create a database with users, we first have to enter the program by using:
me@my-rpi:~ $ sudo mariadb
And now use these commands to create users with rights on the database:
CREATE USER 'project1-admin'@'localhost' IDENTIFIED BY 'adminpassword';
CREATE USER 'project1-web'@'localhost' IDENTIFIED BY 'webpassword'; CREATE USER 'project1-sensor'@'localhost' IDENTIFIED BY 'sensorpassword';
CREATE DATABASE project1;
GRANT ALL PRIVILEGES ON project1.* to 'project1-admin'@'localhost' WITH GRANT OPTION; GRANT SELECT, INSERT, UPDATE, DELETE ON project1.* TO 'project1-web'@'localhost'; GRANT SELECT, INSERT, UPDATE, DELETE ON project1.* TO 'project1-sensor'@'localhost';
Now you can create your database using the commands that are in my github. You can find these with this link.
You only now have to connect your database with pycharm. Here are some pictures on how it should look like.
Step 5: Coding
You can get the code by using my github.
There you have a map conf, thats for your services.
This is so your website and programs runs automaticly when your raspberry pi starts.
A map sensor, that holds the code for your Weather Getter.
Dont forget to import the Adafruit DHT11 library for this. It makes it very simple to read the data of this component.
A map sql with the databases for the Weather Getter.
These will create databases where your data will be stored.
And a map web for your website.
There you can see the data of your Weather Getter.
Step 6: The Housing
I made a housing out of wood. That can easily open and close. In it you have your raspberry pi with your breadbord and your lcd. Make sure you have a hole for your lcd, a hole for your power cable and ethernet cable.
Step 7: Enjoy
Everything should work by now. You would be able to see the temperature, humidity, air pressure and time on your Weather Getter. I hope you enjoy your product.