This project displays weather-based animations on an 8×8 LED matrix controlled by Arduino:
- Rain - Falling droplets animation
- Sun - Pulsing sun pattern
- Clouds - Moving clouds animation
- Control via Python over USB serial or automatically from online weather API
8×8 LED Matrix Wiring:
- Anode pins (rows A–H) → Arduino pins:
13, 12, 11, 10, 9, 8, 7, 6 - Cathode pins (columns 1–8) → Arduino pins:
2, 3, 4, 5, A0, A1, A2, A3
If your wiring is different, update the ANODE_PINS and CATHODE_PINS arrays in the sketch.
Upload this sketch to your Arduino. It supports multiple weather animations controlled by serial commands:
Serial Commands:
'r'= Rain (falling droplets)'u'= Sun (pulsing sun)'c'= Clouds (moving clouds)'p'= Pause (freeze animation)'s'= Stop (clear display)
Serial Monitor Settings: 115200 baud, No line ending
Quick Test: After uploading, open Serial Monitor and type r, u, or c to test each animation.
- Install required packages:
pip install pyserial requests-
Find your Arduino port:
- Arduino IDE: Tools → Port
- macOS:
/dev/cu.usbserial-XXXXXXor/dev/tty.usbmodem#### - Windows:
COM3,COM4, etc.
-
Update
PORTvariable in the Python scripts to match your Arduino port.
control_weather_full.py - Uses local JSON file for reliable testing
python control_weather_full.pyCommands:
rain- Show rain animationsun- Show sun animationclouds- Show cloud animationpause- Freeze current animationstop- Clear displayweather- Read fromweather_data.jsonand display appropriate animationquit- Exit program
To test different weather conditions, edit weather_data.json:
{
"current_condition": [
{
"weatherDesc": [
{
"value": "Rain"
}
]
}
]
}Try values like: "Rain", "Clear", "Sunny", "Cloudy", "Overcast", "Mist"
control_led_weather.py - Fetches real weather from wttr.in API
python control_led_weather.pySame commands as above, but weather fetches real-time weather data for Stanford.
Example Output:
> weather
The weather in Stanford is Clear. [Showing SUN now]
The scripts automatically map weather conditions to animations:
- Rain/Shower/Drizzle → Rain animation
- Sunny/Clear → Sun animation
- Cloudy/Overcast/Mist → Cloud animation
- Other conditions → Clear display
- Wire the 8×8 LED matrix to Arduino according to the pinout above
- Upload
weather_display/weather_display.inoto Arduino - Close Arduino Serial Monitor (only one program can use the port)
- Set the correct
PORTincontrol_weather_full.py - Run
python control_weather_full.py - Type
weatherto test automatic weather display - Edit
weather_data.jsonto simulate different weather conditions
arduino-lab/
├── weather_display/
│ └── weather_display.ino # Main Arduino sketch
├── control_weather_full.py # Python control (local JSON)
├── control_led_weather.py # Python control (online API)
├── weather_data.json # Test weather data
└── README.md # This file
Python can't find serial module:
- Use
pythoninstead ofpython3if you're in a conda environment - Try:
pip uninstall pyserial && pip install pyserial
Port access error:
- Close Arduino Serial Monitor before running Python scripts
- Check port permissions (macOS/Linux: user must be in dialout/uucp group)
wttr.in timeout:
- API can be slow; wait 15+ seconds or use
control_weather_full.pyinstead
- Start with local JSON testing to verify everything works
- Edit JSON to demonstrate all three animations
- Show automatic weather detection with the
weathercommand - If presenting online weather, have a backup plan (JSON) in case API is slow