A modern, interactive web dashboard that displays real-time smart city data including weather conditions, air quality metrics, and environmental insights for major cities worldwide.
- 🌤️ Real-time Weather Data: Current temperature, humidity, wind speed, pressure, and visibility
- 💨 Air Quality Monitoring: AQI (Air Quality Index) with detailed pollutant breakdown (PM2.5, PM10, O₃, NO₂)
- 📊 Interactive Charts:
- 24-hour temperature forecast
- Air quality trends visualization
- 5-day weather forecast
- 💡 Smart Insights: AI-generated insights based on current conditions
- 🔄 Auto-refresh: Automatic data updates every 5 minutes
- 🌍 Multi-city Support: Switch between 6 major cities (London, New York, Tokyo, Paris, Delhi, Beijing)
- 📱 Responsive Design: Works seamlessly on desktop, tablet, and mobile devices
- Frontend: HTML5, CSS3, JavaScript (Vanilla JS - No React)
- Visualization: Chart.js 4.4.0
- APIs:
- OpenWeatherMap API (Weather & Air Quality)
- Mock data fallback for demonstration
- Clone or download this repository
- Open
index.htmldirectly in your web browser - The dashboard will work with mock data for demonstration purposes
-
Get API Keys:
- Sign up for a free account at OpenWeatherMap
- Get your API key from the dashboard
-
Configure API Key:
- Open
script.js - Replace
YOUR_OPENWEATHER_API_KEYon line 2 with your actual API key:
const WEATHER_API_KEY = 'your-actual-api-key-here';
- Open
-
Run the Dashboard:
- Open
index.htmlin your web browser - Or use a local server:
# Using Python python -m http.server 8000 # Using Node.js (http-server) npx http-server # Using PHP php -S localhost:8000
- Navigate to
http://localhost:8000in your browser
- Open
smart-city-dashboard/
│
├── index.html # Main HTML structure
├── styles.css # Styling and responsive design
├── script.js # JavaScript logic and API integration
└── README.md # This file
The dashboard uses two endpoints from OpenWeatherMap:
-
Current Weather:
https://api.openweathermap.org/data/2.5/weather- Provides current weather conditions
-
Air Pollution:
https://api.openweathermap.org/data/2.5/air_pollution- Provides real-time air quality data
-
5-Day Forecast:
https://api.openweathermap.org/data/2.5/forecast- Provides weather forecast data
Note: The free tier of OpenWeatherMap API allows:
- 60 calls/minute
- 1,000,000 calls/month
- Displays current temperature, weather description, and key meteorological data
- Updates in real-time when city is changed or data is refreshed
- Shows AQI on a color-coded scale (Good to Hazardous)
- Displays individual pollutant concentrations
- Visual indicators change color based on air quality level
- Temperature Chart: Line chart showing 24-hour temperature forecast
- Air Quality Chart: Bar chart comparing different pollutant levels
- Forecast Chart: Line chart showing 5-day temperature trends
- Automatically generates contextual insights based on:
- Temperature extremes
- Wind conditions
- Visibility issues
- Air quality warnings
- Health recommendations
-
Add city coordinates to the
cityCoordinatesobject inscript.js:'CityName': { lat: latitude, lon: longitude, name: 'CityName' }
-
Add the city option to the
<select>element inindex.html
Modify the auto-refresh interval at the bottom of script.js:
setInterval(() => {
// Change 5 * 60 * 1000 to your desired interval in milliseconds
}, 5 * 60 * 1000);All styles are in styles.css. The color scheme uses a purple gradient theme that can be easily customized.
- Chrome (recommended)
- Firefox
- Safari
- Edge
- Add more cities
- Include traffic density data
- Add energy consumption metrics
- Implement data export functionality
- Add historical data comparison
- Include more visualization types
- Ensure your API key is correctly set in
script.js - Check your API quota hasn't been exceeded
- Verify internet connection
- The dashboard will fall back to mock data if API calls fail
- Ensure Chart.js CDN is loading (check browser console)
- Verify JavaScript is enabled in your browser
- Clear browser cache
- Ensure
styles.cssis in the same directory asindex.html
This project is open source and available for educational purposes.
- Chart.js: https://www.chartjs.org/
- OpenWeatherMap: https://openweathermap.org/
- Icons: Unicode emoji characters
For issues or questions, please check the code comments or refer to the API documentation.
Note: This dashboard is designed for educational purposes and demonstrates API integration, data visualization, and modern web development practices.