Toggle Navigation
Hatchery
Eggs
CZ_Test
__init__.py
Users
Badges
Login
Register
MCH2022 badge?
go to mch2022.badge.team
__init__.py
raw
Content
import urequests import ujson import rgb import wifi import virtualtimers import uinterface api_city = "40229,de" api_key = "efa371b15e9807095c1605754e02f008" api_url = "http://api.openweathermap.org/data/2.5/weather?" api_para = "&units=metric&lang=en" api_call = api_url + "appid=" + api_key + "&zip=" + api_city + api_para def get_weather(): print("Hole neue Daten") wifi.connect() if not wifi.wait(): print("Unable to connect to the WiFi network.") else: print("You are now connected to WiFi!") res = urequests.get(api_call) data = ujson.loads(res.text) uinterface.skippabletext(data['weather'][0]['description'] + " / Temp: " + str(data['main']['temp']) + "°C / Wind: " + str(data['wind']['speed']) + "m/s ") wifi.disconnect() return 10000 # Initialise the virtualtimers task, and register our function virtualtimers.begin(100) virtualtimers.new(0, get_weather)