miksrv/arduino-weather-station
About
Arduino Weather Station is an automated weather monitoring project built on Arduino for collecting environmental data, featuring an API (PHP + MySQL + CodeIgniter) and a web interface (Next.js + Redux RTK) for real-time and historical weather data analysis. Please give the project a star :)
Data & AnalyticsWhat you can do
- Live data: continuous sensor monitoring.
- Historical logging: long-term storage in MySQL with detailed analytics.
- Web dashboard: access your station from anywhere — charts, stats, trends.
- REST API: integrate weather data into external apps or services.
Measured star growth
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- 0
- in 1 month
- Collecting history
Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.
README.md
OriginalArduino Weather Station is a complete DIY weather-monitoring project powered by Arduino or ESP32. It collects real environmental data and provides a full backend API (PHP + MySQL + CodeIgniter) and a modern web interface (Next.js + Redux RTK) for real-time and historical weather analysis. You can use this repository to build your own fully-featured weather station - and if you like it, please give the project a star :)
Table of Contents
- About of Project
- Build Guide
- Installation
- Usage
- Screenshots and Demos
- Contributing
- License
- Acknowledgments
- Contact
Documentation
Detailed documentation lives in the /docs directory:
- Architecture — system design, data flow, external services
- Backend — PHP/CodeIgniter API reference and setup
- Frontend — Next.js app structure and development
- Testing Guide — running tests, coverage, CI pipeline
- Anomaly Monitor — meteorological anomaly detection, flood risk scoring, and visualization
- Precipitation Calendar — annual rainfall calendar, daily totals, wet/dry streaks, and monthly breakdown
About of Project
Arduino Weather Station is a modular DIY platform for collecting and analyzing weather data. It supports Arduino or ESP32, works with a wide range of sensors, and sends real-time measurements to a backend server. Data is processed, stored, and exposed through a clean REST API and a modern Next.js dashboard.

Key Features:
- Live data: continuous sensor monitoring.
- Historical logging: long-term storage in MySQL with detailed analytics.
- Web dashboard: access your station from anywhere — charts, stats, trends.
- REST API: integrate weather data into external apps or services.
- Modular design: easily add new sensors or expand the system.
Measured Parameters:
- Temperature
- Feels like temperature
- Humidity
- Dew point
- UV intensity
- Solar energy
- Solar radiation
- Wind speed and direction
- Atmospheric pressure
- Precipitation levels
- Cloud cover
The system is highly customizable - from a small indoor sensor hub to a full outdoor weather station with complete data logging and visualization.
Built With
The Arduino Weather Station project leverages a wide range of technologies across various layers of the system:
Programming language used for the Arduino firmware.
Server-side scripting language for the backend API.
Database system for storing weather data.
Core languages used in frontend development.
TypeScript extends JavaScript by adding types to the language.
React-based frontend framework for building the user interface.
State management for the frontend, providing predictable and centralized state.
JavaScript runtime used for frontend development and package management.
Styling the user interface.
Continuous integration and deployment pipeline for automating tests and deployment processes.
Code quality and security analysis.
This project also includes custom-designed components for measuring airflow, voltage, and light, making use of 3D printing for hardware integration.
Build Guide
This project is fairly extensive and includes hardware, firmware, backend, and frontend components. You can choose to build the entire weather station from start to finish, or you can use only the parts you need - whether it's the Arduino/ESP32 firmware, the server API, the 3D-printed enclosure, or the web dashboard.
The guide below walks you through each stage step by step: printing the enclosure, assembling the hardware, setting up the server, and configuring the client application.
3D Printing the Enclosure
All 3D-printable parts for the weather station are located in the models directory, which includes a detailed guide on recommended print settings, assembly notes, and an overview of each component.
The enclosure is fully modular and allows you to print only the parts needed for your specific sensor configuration. Most models are optimized for FDM 3D printers and require no supports unless otherwise noted.
Before printing, review the Models README to choose the correct components and verify recommended materials and orientation.
Installation
Follow these steps to install and run the Arduino Weather Station project on your local machine.
Prerequisites
Make sure you have the following installed on your system:
- Node.js (v20 or higher)
- NPM or Yarn (for frontend dependencies)
- PHP (v8.2 or higher)
- Composer (for backend dependencies)
- MySQL (or any compatible database) — or Docker to run the bundled local database (see step 2 below)
- Arduino IDE (for programming the Arduino microcontroller)
1. Clone the repository
git clone https://github.com/miksrv/arduino-weather-station.git
cd arduino-weather-station
2. Backend Setup (PHP + CodeIgniter)
Navigate to the
serverfolder:cd serverInstall PHP dependencies using Composer:
composer installStart the local MySQL database using Docker (skip this if you already have a MySQL-compatible database running):
docker-compose -f ../config/docker-compose.yml up -dCreate a
.envfile and configure your environment variables, such as database connection settings:cp env .envThe default
database.development.*values already match the docker-compose database from step 3, so no changes are needed if you used Docker. Don't forget to set the parameterapp.arduino.token= '' in the .env file. This token will be used for proper authentication of the Arduino weather station when transmitting data to the server. The same token will need to be set in the Arduino sketch, which will be described in step 4.Migrate the database:
php spark migrateStart the backend server (built-in PHP server or any web server of your choice):
php spark serve
3. Frontend Setup (Next.js + Redux)
Navigate to the
clientfolder:cd ../clientCopy file
envto.env.localand set the following environment variables:cp env .env.localNEXT_PUBLIC_API_HOST = 'http://localhost:8080/' NEXT_PUBLIC_SITE_LINK = 'http://localhost:3000/' NEXT_PUBLIC_STORAGE_KEY = 'meteo'Install frontend dependencies:
yarn installRun the frontend in development mode:
yarn run devTo build the project for production:
yarn run buildOptionally, start the production build:
yarn start
4. Arduino Setup
- Open the Arduino Readme — it includes the full wiring diagram (which pin/wire connects to which component).
- Open the Arduino sketch from the
arduino/mainfolder in the Arduino IDE. - Configure the following parameters in the
main.inofile for Arduino:API_SERVER- the server address for sending data from the weather station.API_METHOD- the correct method (if you haven't changed anything in the server settings in this repository, you don't need to change it).API_SECRET- your secret for server authentication, the same secret key set in step 2 during server setup.- Make sure the Arduino sensors are connected to the correct pins, or simply reassign them:
PIN_ANEMOMETR,PIN_DHT22,PIN_UV_OUT,PIN_UV_REF
- Before compiling, make sure to install the required libraries:
- Extract the BMP085_Library.zip and PCF8574_Library.zip archives from the
/arduinodirectory into thelibrariesfolder of your Arduino IDE.
- Extract the BMP085_Library.zip and PCF8574_Library.zip archives from the
- Connect your Arduino microcontroller and upload the sketch.
- Ensure the Arduino is correctly wired with the sensors for proper functionality.
Arduino Components:
- BMP085: Barometric pressure sensor
- BH1750: Light sensor
- DHT22: Temperature and humidity sensor
- PCF8574: I2C expander for wind direction
- GUML8511: UV sensor
- Anemometer: Measures wind speed
- Wind Vane: Measures wind direction

All models for 3D printing can be found in the models directory.

Which filament / print settings should I use? Don't overthink it - any filament with default slicer settings works fine, and none of the parts need supports. My own enclosure has been printed in plain ABS with default settings, and it's been mounted outdoors since 2021, through everything from +44°C summer sun to -37°C winter frost - nothing has cracked, warped, or fallen apart.
5. Accessing the Application
Once the backend and frontend servers are running, access the weather station UI by visiting:
http://localhost:3000
You can now monitor real-time and historical weather data from the Arduino Weather Station!
Usage
After successfully installing and setting up the Arduino Weather Station project, follow these steps to start using the application and monitor weather data.
1. Access the Web Interface
- Open your browser and navigate to the frontend running at
http://localhost:3000(or the production URL if deployed). - You will see a dashboard displaying current weather conditions as well as the option to view historical data.
2. Real-Time Weather Data
- The dashboard updates weather data in real-time, pulling data from the Arduino sensors connected to your weather station.
- Key metrics displayed include:
- Temperature
- Humidity
- Dew Point
- UV Index
- Wind Speed & Direction
- Pressure
- Precipitation
- Solar Radiation
3. Historical Data
- Navigate to the History page from the main menu.
- Choose a date range to view weather trends and archived data, including charts for various metrics like temperature, wind, and humidity.

4. Customize Data Display
- You can customize the data display to show or hide specific sensors on the dashboard.
- For example, toggle between temperature readings, feels-like temperature, and dew point, or switch between solar energy and solar radiation.
5. Arduino Sensor Calibration
- For accurate readings, you may need to calibrate some sensors depending on your specific environment. Refer to the Arduino sketch in the
arduino/folder to adjust the calibration values for sensors such as temperature or pressure.
6. Data Export
- Weather data can be exported from the History page in various formats (e.g., CSV) to analyze trends further.
7. System Maintenance
- The backend server running on PHP + CodeIgniter is responsible for handling incoming data from the Arduino sensors and storing it in a MySQL database. Ensure the backend is running to avoid data loss.
- The frontend is built with Next.js and provides a smooth interface to view, interact with, and analyze weather data.
8. Arduino Weather Station Features
- Real-time Monitoring: Monitor real-time weather conditions using connected sensors.
- Historical Data: Review weather history with customizable date ranges.
- Graphical Visualizations: View weather trends and patterns using interactive charts.
- Sensor Readings: Monitor multiple environmental factors, such as UV Index, wind speed, and solar radiation.
CLI Commands & Cron Jobs
The backend exposes several php spark commands for pulling external weather data, computing aggregates, and maintaining the anomaly log. These are intended to be scheduled via cron on the server running the PHP backend.
Available Commands
| Command | Description |
|---|---|
php spark system:getCurrentWeather |
Fetches current weather observations from all configured external APIs (VisualCrossing, WeatherAPI, OpenWeatherMap, Open-Meteo), saves new records to raw_weather_data, and recalculates hourly and daily averages. |
php spark system:getForecastWeather |
Fetches forecast data from all configured external APIs and bulk-upserts records into forecast_weather_data. |
php spark system:sendNarodmonData |
Retrieves the latest sensor reading from the database and pushes it to the narodmon.ru monitoring service. |
php spark system:detectAnomalies |
Runs all meteorological anomaly checks for the last complete UTC days (yesterday and the two days before it, so a skipped run is caught up; today's partial data is never logged) and updates the anomaly_log table. Idempotent. end_date of an episode is its last active day (inclusive). Must run after daily averages are available. |
php spark system:backfillAnomalyLog |
Iterates all historical daily records and populates anomaly_log from scratch. Intended for initial bootstrapping. Accepts --force, which deletes all existing rows and rebuilds the log (in one transaction). |
Recommended Schedule
| Command | Frequency | Rationale |
|---|---|---|
system:getCurrentWeather |
Every hour | Keeps raw observations and hourly/daily averages up to date. |
system:getForecastWeather |
Every 3–6 hours | Forecast data changes slowly; 4-hour intervals balance freshness against API quota. |
system:sendNarodmonData |
Every 15 minutes | Near-real-time push to the public monitoring network. |
system:detectAnomalies |
Once daily (e.g. 01:30) | Runs after midnight UTC when the previous day's daily averages are fully computed; it evaluates that completed day. |
system:backfillAnomalyLog |
One-time / manual | Run once on a fresh deployment to seed historical anomaly records. |
Example Crontab
Add the entries below to your server's crontab (crontab -e). Adjust /var/www/project/server to match your actual deployment path.
# Fetch current weather from external APIs and recalculate averages — every hour
0 * * * * cd /var/www/project/server && php spark system:getCurrentWeather >> /var/log/weather.log 2>&1
# Fetch forecast data — every 4 hours
0 */4 * * * cd /var/www/project/server && php spark system:getForecastWeather >> /var/log/weather.log 2>&1
# Push latest reading to narodmon.ru — every 15 minutes
*/15 * * * * cd /var/www/project/server && php spark system:sendNarodmonData >> /var/log/weather.log 2>&1
# Run anomaly detection — daily at 01:30 (after daily averages are ready)
30 1 * * * cd /var/www/project/server && php spark system:detectAnomalies >> /var/log/weather.log 2>&1
Note:
system:backfillAnomalyLogis a one-time maintenance command and should not be added to cron. Run it manually once after a fresh deployment:cd /var/www/project/server && php spark system:backfillAnomalyLog
Screenshots and Demos
1. Current Weather Overview
The Current section provides real-time data on the current weather conditions, including temperature, humidity, UV index, and more. Users can quickly view all key environmental metrics at a glance.

2. Sensors Dashboard
The Sensors section displays a list of all connected weather sensors, including temperature, pressure, wind speed, and solar radiation. This section gives users an in-depth view of each sensor's status and real-time readings.

3. Weather History and Trends
The History section allows users to explore weather data over a specified time period. Interactive charts provide insights into trends for various weather metrics like temperature, wind speed, and humidity.

4. Forecast
The Forecast section offers a comprehensive weather outlook for the next five days, accompanied by a detailed breakdown for the current day. Users can access forecasts for temperature, precipitation, wind speed, humidity, and more, presented in an intuitive interface. This section is designed to help users plan their activities with precision by providing accurate, easy-to-read weather data for both short-term and extended periods.

5. Heatmap
The Heatmap section provides a detailed visualization of weather metrics, including temperature, pressure, humidity, precipitation, and cloud coverage, displayed as a heatmap. Users can select any time period to view trends and patterns across multiple environmental factors at once. This powerful tool allows for quick comparison and in-depth analysis of weather conditions over time.

6. Climate Dashboard
The Climate page is a multi-widget climate science dashboard that surfaces long-term environmental trends from the station's full historical record. Five visualizations make warming and precipitation shifts immediately legible:
| Widget | Description |
|---|---|
| Warming Stripes | One color-coded stripe per year — deep blue (cold years) through white (baseline) to deep red (warm years). Inspired by Ed Hawkins' iconic "Show Your Stripes" graphic. |
| Temperature Anomaly | Bar chart of annual deviation from the long-term mean. Red bars = warmer than average, blue = cooler. A linear trend line is overlaid automatically. |
| Monthly Climate Normals | Band chart showing the all-time min/max envelope and historical mean per calendar month, with the current year's actual values overlaid. |
| Annual Precipitation | Yearly total rainfall bars (blue = above average, amber = below average) plus a linear trend line and a plain-language trend label. |
| Extreme Event Days | Grouped bars counting frost days (< 0 °C), hot days (≥ 30 °C), and heavy-rain days (≥ 10 mm) per year. |
All five widgets are powered by the new GET /climate endpoint, which returns pre-aggregated statistics computed server-side from daily_averages. The response is cached indefinitely (TTL = 0) because the underlying data changes at most once per year.
Live Demo
Explore the fully functioning weather station web application at:
🌐 Live Demo
Contributing
Contributions are what make the open-source community an incredible environment for learning, inspiration, and innovation. Your contributions are highly valued and greatly appreciated, whether it’s reporting bugs, suggesting improvements, or creating new features.
To contribute:
- Fork the project by clicking the "Fork" button at the top of this page.
- Clone your fork locally:
git clone https://github.com/miksrv/arduino-weather-station.git - Create a new feature branch:
git checkout -b feature/AmazingFeature - Make your changes, then commit them:
git commit -m "Add AmazingFeature" - Push your changes to your forked repository:
git push origin feature/AmazingFeature - Open a pull request from your feature branch to the main repository.
We encourage contributions of all kinds, whether big or small. Your efforts help improve the project for everyone!
License
Distributed under the MIT License. See LICENSE for more information.
Acknowledgments
This section is dedicated to recognizing the resources and individuals that have been invaluable to this project. I’d like to highlight a few key tools and contributions that made a significant impact on its development. Feel free to explore them as they may be useful for your own projects!
Contact
Misha - miksoft.pro
Explore related projects
Loading…
