In this article, the wizard will tell us how to make a home weather station.
The device has sensors for CO2, humidity and temperature, built-in web server with settings and real-time graphs, automatic recording of constant readings (every 5 seconds), color indication for low/high readings and an audible alarm for high CO2 levels with the ability to set any melodies.
Tools and materials: -Raspberry Pi Zero W; -MicroSD card 8 GB;
-2.8 inches 240×320 TFT display; -CO2 sensor MH-Z19B;
-Temperature/humidity sensor GY-21 HTU21;
-Sensor temperature/humidity SHT31-D IIC; -Passive piezo buzzer; – 5 V power supply for R PI; -Related cable 10 wires 28AWG 50 cm;
-A tool with a sharp end (compasses, needle, nail);
– Glue gun; -Soldering iron;
-Acrylic primer spray;
-Acrylic spray paint;
-Third hand for soldering;
Step one: making the case
The master makes the case from plywood.
First, he develops a project in a graphics program. Then he prints the templates onto paper.
Glues the template onto a plywood sheet.
Drills and cuts holes according to the template.
Cuts grooves and space for the screen.
Next, you need to try to assemble the case. If necessary, the grooves can be adjusted using a file.
Checks the installation of components.
Files with templates can be downloaded below.
RWS_Design.skpRWS_Draft.pdfStep two: painting
After final fitting and assembly, he primes and then paints the body.
Step three: assembly and assembly
Then the master proceeds to the installation of electronics. Soldered the connector to Rusbury.
Prepares wires and sensors.
Installs everything in the case and connects according to the diagram. The technician used 2 temperature/humidity sensors to improve the measurement accuracy and make it more reliable. For example, if one sensor sends corrupted data for any reason, the RWS will use the data from the second sensor. If both sensors send different data, they average the results to improve accuracy. If both fail, which is unlikely, RWS will use the last known exact data values.
Step four: programming
Next, you need to program Russberi. The code can be downloaded here.
Next, you need to follow these steps.
1. Write the code to an SD card using the Raspberry Pi Imager.
2. Create wpa_supplicant.conf file, add WiFi info, put it in your SD card boot folder (it must have Linux line endings to work correctly):
ctrl_interface = DIR =/var/run/wpa_supplicant GROUP = netdev update_config = 1 country = & lt; Insert 2 letter ISO 3166-1 country code here & gt; network = & # 123; ssid = & # 34; & lt; Name of your wireless LAN & gt; & # 34; psk = & # 34; & lt; Password for your wireless LAN & gt; & # 34; }
3. Place an empty file named “ssh” in your boot directory.
4. Edit config.txt in boot
#Uncomment these lines & # 58; dtparam = i2c_arm = on dtparam = spi = on
#Add these lines to the end of file:
enable_uart = 1
dtoverlay = disable-bt #only if you don 't need bluetooth for any usefull purpose
5. Load pi
6. Connect via SSH (eg PuTTY on Windows)
7. Change the password for pi using the passwd command.
8. Run sudo raspi-config and do the following:
Interface Options – & gt; SPI – & gt; Yes
Interface Options – & gt; I2C – & gt; Yes
Localization Options – & gt; Timezone – & gt; Choose your Timezone
Interface Options – & gt; Serial Port – & gt; No – & gt; Yes – & gt; reboot
9. Install wiringPi using the command:
sudo apt-get install wiringpi
10. Update wiringPi to the latest version:
cd/tmp wget https & # 58; //project-downloads.drogon.net/wiringpi-lat ... sudo dpkg -i wiringpi-latest.deb gpio - v //Should display 2.52
11. Install git and clone program:
sudo apt-get update sudo apt-get -y install git cd git clone https & # 58; //github.com/ScienceDiscoverer/RWS
12. Create a program:
cd RWS make
13. Now you need to make the program automatically start every time the system boots. Create rws.service file:
& # 91; Unit & # 93; Description = Room Weather Station & # 91; Service & # 93; Type = simple WorkingDirectory =/home/pi/RWS ExecStart =/home/pi/RWS/build/rws & # 91; Install & # 93; WantedBy = multi-user.target
14. Copy this file and give it permissions:
sudo cp rws.service /etc/systemd/system/rws.service sudo chmod 644 /etc/systemd/system/rws.service
15. Check if everything is working correctly:
sudo systemctl start rws sudo systemctl status rws //Should be & # 34; active & # 34; sudo systemctl stop rws
16. Enable autostart:
sudo systemctl enable rws
17. Reboot the Pi and check if rws is running correctly:
sudo systemctl status rws
18. Now you need to install the buzzer and close the back panel.
Now you can check how the web server is working. Go to your home network router settings and set a static IP address for the Raspberry Pi. Next, you need to go to the Pi's IP address in any browser. Install the font found here.
The last thing to do is register your own local domain name for the Pi.
Everything is ready, you just need to connect the power supply or install the battery. As mentioned earlier, all data is saved to the card. According to the master, 8GB is enough to store data for 60 years (provided that data is recorded every 5 seconds).