new MP user with an esp32.
MicroPython v1.12-388-g388d419ba
I am trying to get info from api.openweathermap.org API and parse it to get some individual values. Here is my code:
Code: Select all
import urequests, ujson
def url():
r = urequests.get("https://api.openweathermap.org/data/2.5/onecall?<snipped>")
ud = r.text
raw = ujson.loads(ud)
t = raw.get('current').get('temp')
w = raw.get('current').get('weather')
print(t)
print(w)
url()
Code: Select all
{"timezone":"Australia/Melbourne","current":{"dt":1587788262,"sunrise":1587761706,"sunset":1587800335,"temp":20.58,"feels_like":18.94,"pressure":1015,"humidity":61,"dew_point":12.8,"uvi":3.5,"clouds":87,"wind_speed":3.58,"wind_deg":57,"wind_gust":7.15,"weather":[{"id":804,"main":"Clouds","description":"overcast clouds","icon":"04d"}]},"hourly": <snipped>
Code: Select all
20.34
[{'id': 804, 'icon': '04d', 'main': 'Clouds', 'description': 'overcast clouds'}]
thanks in advance,
Matt