From 50b8e2ef9050ad52e04dd88805a17e3e78d790e0 Mon Sep 17 00:00:00 2001 From: Hel Gibbons <50950368+helgibbons@users.noreply.github.com> Date: Tue, 13 Dec 2022 12:50:13 +0000 Subject: [PATCH 1/2] Use http instead of https to avoid memory errors --- micropython/examples/plasma_stick/weather.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/micropython/examples/plasma_stick/weather.py b/micropython/examples/plasma_stick/weather.py index bb3667f5..abd291d8 100644 --- a/micropython/examples/plasma_stick/weather.py +++ b/micropython/examples/plasma_stick/weather.py @@ -25,7 +25,7 @@ LAT = 53.38609085276884 LNG = -1.4239983439328177 TIMEZONE = "auto" # determines time zone from lat/long -URL = "https://api.open-meteo.com/v1/forecast?latitude=" + str(LAT) + "&longitude=" + str(LNG) + "¤t_weather=true&timezone=" + TIMEZONE +URL = "http://api.open-meteo.com/v1/forecast?latitude=" + str(LAT) + "&longitude=" + str(LNG) + "¤t_weather=true&timezone=" + TIMEZONE UPDATE_INTERVAL = 900 # refresh interval in secs. Be nice to free APIs! # Weather codes from https://open-meteo.com/en/docs#:~:text=WMO%20Weather%20interpretation%20codes%20(WW) From d5e1a2d8a03d3c683be50279d64e8e27d3b8b28a Mon Sep 17 00:00:00 2001 From: Hel Gibbons Date: Tue, 13 Dec 2022 13:52:51 +0000 Subject: [PATCH 2/2] make sure socket is closed --- micropython/examples/plasma_stick/weather.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/micropython/examples/plasma_stick/weather.py b/micropython/examples/plasma_stick/weather.py index abd291d8..bb0374d1 100644 --- a/micropython/examples/plasma_stick/weather.py +++ b/micropython/examples/plasma_stick/weather.py @@ -88,7 +88,6 @@ def get_data(): # open the json data j = r.json() print("Data obtained!") - r.close() # parse relevant data from JSON current = j["current_weather"] @@ -101,6 +100,8 @@ Conditions = {WEATHERCODES[weathercode]} Last Open-Meteo update: {datetime_arr[0]}, {datetime_arr[1]} """) + r.close() + # flash the onboard LED after getting data pico_led.value(True) time.sleep(0.2)