Hi,
While following the course for micropython I was having issues with openweather.
Finally it seems you have to wait for ages before the api-key is activated at their side.
In the meanwhile I converted the exercise to open-meteo.com (you can use their api without registering.)
Personally I think this would be better for the book ๐
with the following code I could remake the exercise without any acount (I only implemented temperature and humidity)
open_weather_map_url = ‘https://api.open-meteo.com/v1/forecast?latitude=51.1939&longitude=4.0965¤t=temperature_2m,relative_humidity_2m,weather_code,surface_pressure,wind_speed_10m,wind_direction_10m&timezone=Europe%2FBerlin’
weather_data = requests.get(open_weather_map_url)
print(weather_data.json())
temperature = weather_data.json().get(‘current’).get(‘temperature_2m’)
temperature_unit = weather_data.json().get(‘current_units’).get(‘temperature_2m’)
print(f”Temperature: {temperature}{temperature_unit}”)
humidity = weather_data.json().get(‘current’).get(‘relative_humidity_2m’)
humidity_unit = weather_data.json().get(‘current_units’).get(‘relative_humidity_2m’)
print(f”humidity: {humidity}{humidity_unit}\n\n”)
On this page you can even construct the query for the API, so you only receive the data you want ๐
https://open-meteo.com/en/docs
That’s great.
Thanks for sharing.
Seems better than the one we’re currently using.
Regards,
Sara