๐ค๏ธ DIY IoT Weather Station
Build a Professional Weather Monitoring System with ESP8266 & BME280
Complete Guide with Cloud Dashboard | Total Cost: ~$10-15
๐ What Youโll Build
In this comprehensive tutorial, youโll create a complete IoT weather station that:
- โ Measures temperature, humidity, pressure, and altitude
- โ Sends data to your cloud server every 3 minutes
- โ Displays real-time data on a beautiful animated dashboard
- โ Stores all readings in a MySQL database
- โ Supports WiFi configuration via mobile (no code re-upload needed!)
- โ Shows historical charts and trends

โจ Key Features
๐ฑ WiFi Portal
Configure WiFi from your phone without re-uploading code. Change networks anytime!
โ๏ธ Cloud Storage
All data automatically saved to MySQL database on your web server.
๐ Live Dashboard
Beautiful animated interface with real-time charts and timeline view.
๐ Trend Analysis
Automatic detection of rising/falling values with visual indicators.
๐ ๏ธ Components Required
Hardware Components
| Component | Quantity | Approx. Cost |
|---|---|---|
| ESP8266 NodeMCU (ESP-12E) | 1 | $3-5 |
| BME280 Sensor Module | 1 | $3-5 |
| Micro USB Cable | 1 | $2 |
| Jumper Wires (Female-Female) | 4 | $1 |
| Push Button (Optional) | 1 | $0.50 |
| Total Cost | ~$10-15 | |
Software & Services
- Arduino IDE โ Free download from arduino.cc
- Web Hosting โ Any hosting with PHP & MySQL (cPanel recommended)
- Domain Name โ Optional, can use IP address
๐ธ
๐ Circuit Wiring
โ ๏ธ Important Warning
The BME280 sensor operates at 3.3V ONLY. Do NOT connect to 5V or you will damage the sensor!
BME280 to ESP8266 Connections
| BME280 Pin | โ | ESP8266 Pin |
|---|---|---|
| VCC | โ | 3.3V (NOT 5V!) |
| GND | โ | GND |
| SCL | โ | D1 (GPIO5) |
| SDA | โ | D2 (GPIO4) |
Optional: Reset Button
Add a push button to easily reset WiFi configuration:
| Button Pin 1 | โ | D3 (GPIO0) |
| Button Pin 2 | โ | GND |
Hold button for 5 seconds to reset WiFi settings.
๐ป Installation Steps
1 Setup Arduino IDE
1.1 Install Arduino IDE
Download and install from arduino.cc/en/software
1.2 Add ESP8266 Board Support
- Open Arduino IDE
- Go to File โ Preferences
- In โAdditional Board Manager URLsโ, add:
http://arduino.esp8266.com/stable/package_esp8266com_index.json - Click OK
- Go to Tools โ Board โ Boards Manager
- Search for โESP8266โ
- Install โesp8266 by ESP8266 Communityโ
1.3 Install Required Libraries
Go to Sketch โ Include Library โ Manage Libraries, then search and install:
- โ Adafruit BME280
- โ Adafruit Unified Sensor
- โ WiFiManager by tzapu
2 Upload Arduino Code
2.1 Get the Code
Download the complete Arduino sketch from GitHub:
File: weather_station.ino
2.2 Configure Settings
Open the sketch and modify these lines at the top:
// Change this to your server URL
char serverUrl[150] = "https://yourdomain.com/esp12e/receive_data.php";
// WiFi portal name (optional)
const char* apName = "Haneef_Weather_Setup";
const char* apPassword = "haneef123";
2.3 Upload to ESP8266
- Connect ESP8266 to computer via USB
- Select Tools โ Board โ NodeMCU 1.0 (ESP-12E Module)
- Select Tools โ Port โ [Your COM Port]
- Click Upload button (โ)
- Wait for โDone uploadingโ message
- Open Serial Monitor (Ctrl+Shift+M)
- Set baud rate to 115200
๐ก Tip: If upload fails, hold the โFLASHโ button on ESP8266 while uploading.
3 Setup Server (PHP & MySQL)
3.1 Create Database
- Login to your cPanel
- Go to MySQL Databases
- Create a new database (e.g.,
weather_db) - Create a database user with password
- Add user to database with ALL PRIVILEGES
- Note down: database name, username, password
3.2 Upload PHP Files
Download all server files from GitHub:
Files: config.php, receive_data.php, get_data.php, setup_database.php
Using File Manager or FTP:
- Create folder:
/public_html/esp12e/ - Upload all 4 PHP files to this folder
- Edit
config.phpwith your database credentials
3.3 Edit config.php
Update these values with your database information:
define('DB_HOST', 'localhost');
define('DB_NAME', 'your_database_name'); // Change this
define('DB_USER', 'your_database_username'); // Change this
define('DB_PASS', 'your_database_password'); // Change this
3.4 Create Database Table
- Visit:
https://yourdomain.com/esp12e/setup_database.php - You should see: โโ Table created successfully!โ
- IMPORTANT: Delete
setup_database.phpafter setup (security!)
โ ๏ธ Security: Always delete setup_database.php after running it once!
4 Upload Dashboard
Download the beautiful animated dashboard:
File: index.html
- Upload
index.htmlto/public_html/esp12e/ - Visit:
https://yourdomain.com/esp12e/ - You should see the dashboard (may show โLoadingโฆโ until data arrives)
Dashboard Features:
- ๐จ Animated background particles
- ๐ Real-time charts (Chart.js)
- โฑ๏ธ Timeline of recent readings
- ๐ Trend indicators (โโ)
- ๐ฑ Mobile responsive design
- ๐ Auto-refresh every 3 minutes
๐ธ
5 Configure WiFi (First Time)
After uploading code, the ESP8266 will create a WiFi hotspot:
๐ฑ On Your Phone/Laptop:
- Open WiFi Settings
- Look for network:
Haneef_Weather_Setup - Connect using password:
haneef123 - Configuration portal opens automatically
(If not, open browser and go to192.168.4.1) - Click โConfigure WiFiโ
- Select your home WiFi network from the list
- Enter your WiFi password
- (Optional) Enter your Server URL
- Click โSaveโ
- Device will restart and connect to your WiFi! ๐
๐ก Pro Tip: You can reconfigure WiFi anytime by holding the reset button for 5 seconds, or by temporarily adding wifiManager.resetSettings(); in the code.
๐ How to Use
Normal Operation
- โ Device automatically sends data every 3 minutes
- โ Dashboard auto-refreshes every 3 minutes
- โ All data is stored in database permanently
- โ View real-time readings and historical charts
- โ Access from anywhere via your domain
Monitoring Serial Output
Open Serial Monitor (115200 baud) to see:
========================================
SENSOR READINGS
========================================
Temperature: 28.45 ยฐC
Humidity: 65.20 %
Pressure: 1013.25 hPa
Altitude: 15.30 m
========================================
Sending data to server...
โ Server Response Code: 200
โ Data sent successfully!
Next update in 3 minutes...
Changing WiFi Network
Method 1: Press and hold reset button for 5 seconds
Method 2: Power off, add this line to code temporarily, upload, then remove:
wifiManager.resetSettings(); // Add in setup(), upload, then remove
๐ง Troubleshooting
โ BME280 Sensor Not Found
Symptoms: Serial Monitor shows โCould not find BME280 sensorโ
Solutions:
- Check all wire connections (especially VCC to 3.3V)
- Verify sensor is not damaged
- Try I2C address
0x77instead of0x76in code - Test with I2C scanner sketch
โ ๏ธ WiFi Hotspot Not Visible
Symptoms: Canโt see โHaneef_Weather_Setupโ network
Solutions:
- Wait 30-60 seconds after powering on
- Press reset button on ESP8266
- Check ESP8266 has power (LED should be on)
- Ensure your phone supports 2.4GHz WiFi
- Try from different device
๐ Data Not Reaching Server
Symptoms: Serial shows error codes like 400, 404, 500
Solutions:
- Error 400: Check server URL is correct (https://)
- Error 404: PHP file doesnโt exist or wrong path
- Error 500: Check PHP syntax and database credentials
- Error -1: WiFi connection issue or DNS problem
- Test URL in browser first
๐ฑ Configuration Portal Wonโt Open
Symptoms: Connected to hotspot but no portal appears
Solutions:
- Manually open browser and go to
192.168.4.1 - Disable mobile data on phone
- Try different browser (Chrome, Firefox, Safari)
- Forget the WiFi network and reconnect
- Some phones need โStay connectedโ prompt โ click Yes
๐ Dashboard Shows โLoadingโฆโ
Symptoms: Dashboard loads but shows no data
Solutions:
- Wait 3 minutes for first data to arrive
- Check browser console for errors (F12)
- Verify
get_data.phpworks: visit it directly in browser - Check database has data (use phpMyAdmin)
- Ensure all PHP files are in same folder
โก Advanced Features & Customization
Change Data Update Interval
Modify this line in Arduino code (value in milliseconds):
const long interval = 180000; // 3 minutes
// Examples:
// 60000 = 1 minute
// 300000 = 5 minutes
// 600000 = 10 minutes
// 1800000 = 30 minutes
Add Email Alerts
Add this to receive_data.php after data is saved:
// Send email if temperature exceeds threshold
if ($temperature > 35) {
$subject = "High Temperature Alert!";
$message = "Temperature: {$temperature}ยฐC at " . date('Y-m-d H:i:s');
mail('your@email.com', $subject, $message);
}
Clean Old Data Automatically
Add a cron job in cPanel to run this SQL monthly:
DELETE FROM sensor_data
WHERE timestamp < DATE_SUB(NOW(), INTERVAL 30 DAY);
Export Data to CSV
Create export.php to download data:
<?php
require_once 'config.php';
header('Content-Type: text/csv');
header('Content-Disposition: attachment; filename="weather_data.csv"');
$conn = getDBConnection();
$stmt = $conn->query("SELECT * FROM sensor_data ORDER BY timestamp DESC");
echo "Timestamp,Temperature,Humidity,Pressure,Altitude\n";
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
echo "{$row['timestamp']},{$row['temperature']},{$row['humidity']},{$row['pressure']},{$row['altitude']}\n";
}
?>
๐ฆ Complete Source Code
Get All Files from GitHub
Complete project with Arduino code, PHP files, and dashboard
โญ View on GitHubDonโt forget to star the repository if you find it helpful! โญ
๐ Project Structure
weather-station/
โโโ arduino/
โ โโโ weather_station.ino (ESP8266 code)
โโโ server/
โ โโโ config.php (Database config)
โ โโโ receive_data.php (Receive sensor data)
โ โโโ get_data.php (Retrieve data for dashboard)
โ โโโ setup_database.php (Create table - delete after use)
โโโ dashboard/
โ โโโ index.html (Beautiful web dashboard)
โโโ wiring/
โ โโโ circuit_diagram.png (Wiring diagram)
โโโ README.md (Documentation)
๐ฎ Future Enhancements
๐ฑ Mobile App
Create native Android/iOS app using React Native or Flutter for better mobile experience.
๐ค AI Predictions
Use machine learning to predict weather patterns based on historical data.
๐ Multiple Sensors
Deploy multiple ESP8266 nodes in different locations and aggregate data.
๐ Smart Home
Integrate with Home Assistant, Alexa, or Google Home for voice control.
โ๏ธ Solar Power
Add solar panel and battery for completely wireless outdoor operation.
๐ง Notifications
Send push notifications or SMS alerts for extreme weather conditions.
๐ Congratulations!
Youโve successfully built a professional IoT weather station!
This project demonstrates cloud connectivity, real-time data visualization, and modern web development. You can now expand it with additional sensors, features, and integrations!
โญ If you found this helpful, please star the GitHub repository!
๐ข Share this project with fellow makers and IoT enthusiasts!
Last Updated: May 28, 2026
Made with โค๏ธ by Haneef Puttur
