Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ENGR 40M Lab 3B – Weather Display with Multiple Animations

Overview

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

Hardware Setup

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.


Arduino Sketch

weather_display/weather_display.ino

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.


Python Control Scripts

Setup (One-Time)

  1. Install required packages:
pip install pyserial requests
  1. Find your Arduino port:

    • Arduino IDE: Tools → Port
    • macOS: /dev/cu.usbserial-XXXXXX or /dev/tty.usbmodem####
    • Windows: COM3, COM4, etc.
  2. Update PORT variable in the Python scripts to match your Arduino port.

Option 1: Local Testing (Recommended)

control_weather_full.py - Uses local JSON file for reliable testing

python control_weather_full.py

Commands:

  • rain - Show rain animation
  • sun - Show sun animation
  • clouds - Show cloud animation
  • pause - Freeze current animation
  • stop - Clear display
  • weather - Read from weather_data.json and display appropriate animation
  • quit - 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"

Option 2: Online Weather

control_led_weather.py - Fetches real weather from wttr.in API

python control_led_weather.py

Same commands as above, but weather fetches real-time weather data for Stanford.

Example Output:

> weather
The weather in Stanford is Clear. [Showing SUN now]

Weather Mapping Logic

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

Quick Start Guide

  1. Wire the 8×8 LED matrix to Arduino according to the pinout above
  2. Upload weather_display/weather_display.ino to Arduino
  3. Close Arduino Serial Monitor (only one program can use the port)
  4. Set the correct PORT in control_weather_full.py
  5. Run python control_weather_full.py
  6. Type weather to test automatic weather display
  7. Edit weather_data.json to simulate different weather conditions

File Structure

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

Troubleshooting

Python can't find serial module:

  • Use python instead of python3 if 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.py instead

Demo Tips

  1. Start with local JSON testing to verify everything works
  2. Edit JSON to demonstrate all three animations
  3. Show automatic weather detection with the weather command
  4. If presenting online weather, have a backup plan (JSON) in case API is slow

About

Arduino Lab 3B

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages