Thursday, May 16, 2019

Python NEOPIXEL Google Traffic and Weather LED Strip

Started playing around with the Neopixel library and python on the Raspberry Pi. I usually take a run over lunch break so I wanted a way to get a quick view of the current weather conditions. I have a 60 LED WS2812 strip so I divided the strip up into 15 LED sections.

  • Section 1 - Temperature. Depending on the temperature I wanted to color the 15 LEDs a specific color.
    • temp > 44 and < 80 = Green
    • temp > 79 and < 90 = Yellow
    • temp > 90 = Red
    • temp > 34 and < 45 = Yellow
    • temp < 34 = Red
  • Section 2 - Wind. 
    • wind < 5 = green
    • wind = 5 and < 16 = Yellow
    • wind > 15 = Red
  • Section 3 - Humidity
    • Humidity < 61 = Green
    • humidity > 61 and < 80 = Yellow
    • humidity > 80 = Red
  • Section 4 - Condition
    • If it is not raining - Green
    • If it is raining - Red
I am using the Open Weather Map API. You can sign up for a free account here: https://openweathermap.org/. I setup an infinite while loop that will sleep for 10 minutes between each iteration. I also set it up to only turn the LEDs on between 10AM and 2PM. The API will only be called during these times. I typically take a run around lunch time so no need to keep it on after this. 



Next steps is to add a Traffic API call. I will light the led up based upon my commute time home.




0 comments:

Post a Comment