Create an open weather map account: https://home.openweathermap.org/users/sign_in
They will email you an API key which you need for the code
example URL: http://api.openweathermap.org/data/2.5/weather?q=94112,us&APPID=0e974dbb38ad3719228ac1854b212827&units=imperial
example key: 0e974dbb38ad3719228ac1854b212827
Use weather_data.py
You'll need to add your API Key as shown in the image (between the quotes).
You can also change the zip code.
Now try this example that will print the "type" of weather
You'll need to add your API Key as shown in the image (between the quotes).
You can also change the zip code.
Now try to control an LED based on a weather condition
You need to add two LEDs to your Pi. Remind yourself how to do that here.
One LED will connect to #18 and GND (use blue)
One LED will connect to #17 and GND (use red)
This code will turn on the Red LED when it's warm out and a BLUE led when it's cold out.
Don't forget to add your api_key!
To really test this, run it once with weather someplace cold, like Utqiagvik, Alaska = 99723
And someplace warm like Key Largo, Florida = 33037
Here’s an example that prints the weather to a screen
(you need an api key from here)
Challenges:
Can you print out more than just the temperature and the weather type for somewhere in Vermont? What about five different data points?
Can you check and print the weather in multiple locations? And print a comparison?
Want to get fancy? This example displays the temperature on the mini- unicorn hat
NOTE: you need to make sure to save this file in the “unicorn hat examples” folder OR copy the font file to your documents folder
and this one will change the color of the unicorn hat based on SF temperaure: