Weather Station

The weather station measures temperature and humidity both indoors and outdoors. The station is based on an article from majsterkowo.pl by user r.blaszczak Solar weather station using Wemos D1 mini Pro and Raspberry Pi 3 B+. Of course, the project has been modified according to personal ideas.

Project Assumptions:

  • Measurement of temperature and humidity both indoors and outdoors
  • Saving measurements on a local server
  • Displaying the latest measurement and history in the form of a graph on the website
  • Building an application for the Android system
  • Displaying the latest measurement as a widget for Windows 10



The power supply for the station, unlike what is described in the article, is provided by the electrical grid. Wires from a network cable (so-called “twisted pair”) approximately 2 meters long were used to connect the sensors to the ESP8266.

The final view of the website is shown in the image below.

Website link
Stacja Meteo Pomiar Temperatury i Wilgotności Historia pomiarów

The view of the widget in Windows 10.

widget rainmeter stacja meteo ESP8266 DTH11 DTH22
Widget in Rainmeter

The view of the Android application.

Stacja Meteo Aplikacja Android
Android application.

Used Components:

  • Raspberry Pi 4 (using the version with 4 GB of RAM)
  • ESP8266
  • DTH11 temperature and humidity sensor
  • DTH22 temperature and humidity sensor



On the Raspberry Pi, we install the Apache web server with PHP support and a database; for this project, I used MariaDB. Additionally, it is recommended to install an SSL certificate; Let’s Encrypt was used in this project to generate the certificate. Next, we create our database; the following code was used in the project to create the table.

CREATE TABLE S_01 (
id int(20) NOT NULL AUTO_INCREMENT,
timestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
temperatureIN float NOT NULL,
humidityIN float NOT NULL,
temperatureOUT float NOT NULL,
humidityOUT float NOT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

The next step is to create files in the Apache main directory that are responsible for saving data to the database and displaying the current data on the webpage along with the history chart.

espdata.php



A website presenting current data and the history chart.

meteochart.php



Creating charts using CanvasJS.com.

Next, connect the ESP8266 board to the computer and launch the Arduino IDE. You need to add support for the ESP8266 board before you can upload the software.

Once we have added the board to Arduino and uploaded the additional libraries for Wi-Fi and the DTH sensor, we can upload the software to the board.



It is important to ensure that the correct pins to which the sensors are soldered are specified in the code.

Rainmeter

The widget for Windows 10 was implemented using Rainmeter, for which a plugin was developed.

The plugin code.

Spread the love