Toggle Navigation
Hatchery
Eggs
Simple weather JSON info by D3xtar
__init__.py
Users
Badges
Login
Register
MCH2022 badge?
go to mch2022.badge.team
__init__.py
raw
Content
import urequests import rgb import system import wifi import time import machine apikey = machine.nvs_getstr('system', 'weerliveapikey') if apikey is None: apikey = 'demo' location = machine.nvs_getstr('system', 'weerliveloc') if location is None: location = 'Amsterdam' from default_icons import animation_connecting_wifi, icon_no_wifi rgb.getbrightness() if not wifi.status(): data, size, frames = animation_connecting_wifi rgb.clear() rgb.framerate(3) rgb.gif(data, (12, 0), size, frames) wifi.connect() if wifi.wait(): rgb.clear() rgb.framerate(20) else: print('No wifi') rgb.clear() rgb.framerate(20) data, frames = icon_no_wifi rgb.image(data, (12, 0), (8,8)) time.sleep(3) rgb.clear() if not wifi.status(): print("Error connecting to wifi") system.reboot() result = urequests.get('https://weerlive.nl/api/json-data-10min.php?key=' + (apikey) + '&locatie=' + (location)) print(result.text) parsed_object = result.json()['liveweer'][0] plaatsnaam = parsed_object['plaats'] currenttemp = parsed_object['temp'] print("Plaats: " + (plaatsnaam)) print("Temperatuur: " + (currenttemp)) rgb.clear() rgb.scrolltext((plaatsnaam) + " " + (currenttemp) + "C", (0,0,255))