More than likely intermittent, because it happens at different times, not at a set time period or length.
Configuration:
Adafruit CircuitPython 7.0.0 on 2021-09-20; Adafruit Matrix Portal M4 with samd51j19Board ID:matrixportal_m4adafruit-circuitpython-bundle-7.x-mpy-20210928
Script:
# Matrix Weather display
# For Metro M4 Airlift with RGB Matrix shield, 64 x 32 RGB LED Matrix display
"""
This example queries the Open Weather Maps site API to find out the current
weather for your location... and display it on a screen!
if you can find something that spits out JSON data, we can display it
"""
import time
import board
import microcontroller
from digitalio import DigitalInOut, Direction, Pull
from adafruit_matrixportal.network import Network
from adafruit_matrixportal.matrix import Matrix
import openweather_graphics # pylint: disable=wrong-import-position
# Get wifi details and more from a secrets.py file
try:
from secrets import secrets
except ImportError:
print("WiFi secrets are kept in secrets.py, please add them there!")
raise
if hasattr(board, "D12"):
jumper = DigitalInOut(board.D12)
jumper.direction = Direction.INPUT
jumper.pull = Pull.UP
is_metric = jumper.value
elif hasattr(board, "BUTTON_DOWN") and hasattr(board, "BUTTON_UP"):
button_down = DigitalInOut(board.BUTTON_DOWN)
button_down.switch_to_input(pull=Pull.UP)
button_up = DigitalInOut(board.BUTTON_UP)
button_up.switch_to_input(pull=Pull.UP)
if not button_down.value:
print("Down Button Pressed")
microcontroller.nvm[0] = 1
elif not button_up.value:
print("Up Button Pressed")
microcontroller.nvm[0] = 0
print(microcontroller.nvm[0])
is_metric = microcontroller.nvm[0]
else:
is_metric = true
if is_metric:
UNITS = "metric" # can pick 'imperial' or 'metric' as part of URL query
print("Jumper set to metric")
else:
UNITS = "imperial"
print("Jumper set to imperial")
# Use cityname, country code where countrycode is ISO3166 format.
# E.g. "New York, US" or "London, GB"
LOCATION = "Cranbrook, CA"
print("Getting weather for {}".format(LOCATION))
# Set up from where we'll be fetching data
DATA_SOURCE = (
"http://api.openweathermap.org/data/2.5/weather?q=" + LOCATION + "&units=" + UNITS
)
DATA_SOURCE += "&appid=" + secrets["openweather_token"]
# You'll need to get a token from openweather.org, looks like 'b6907d289e10d714a6e88b30761fae22'
# it goes in your secrets.py file on a line such as:
# 'openweather_token' : 'your_big_humongous_gigantor_token',
DATA_LOCATION = []
SCROLL_HOLD_TIME = 0 # set this to hold each line before finishing scroll
# --- Display setup ---
matrix = Matrix()
network = Network(status_neopixel=board.NEOPIXEL, debug=True)
if UNITS in ("imperial", "metric"):
gfx = openweather_graphics.OpenWeather_Graphics(
matrix.display, am_pm=False, units=UNITS
)
print("gfx loaded")
localtime_refresh = None
weather_refresh = None
while True:
# only query the online time once per hour (and on first run)
if (not localtime_refresh) or (time.monotonic() - localtime_refresh) > 3600:
try:
print("Getting time from internet!")
network.get_local_time()
localtime_refresh = time.monotonic()
except RuntimeError as e:
print("Some error occured, retrying! -", e)
continue
# only query the weather every 10 minutes (and on first run)
if (not weather_refresh) or (time.monotonic() - weather_refresh) > **900**:
try:
value = network.fetch_data(DATA_SOURCE, json_path=(DATA_LOCATION,))
print("Response is", value)
gfx.display_weather(value)
weather_refresh = time.monotonic()
except RuntimeError as e:
print("Some error occured, retrying! -", e)
continue
gfx.scroll_next_label()
# Pause between labels
time.sleep(SCROLL_HOLD_TIME)
Error:
Getting time from internet!
Getting time for timezone America/Edmonton
Traceback (most recent call last):
File "code.py", line 88, in <module>
File "code.py", line 84, in <module>
File "adafruit_portalbase/network.py", line 231, in get_local_time
File "adafruit_portalbase/network.py", line 214, in get_strftime
File "adafruit_portalbase/network.py", line 200, in get_strftime
File "adafruit_requests.py", line 684, in get
File "adafruit_requests.py", line 586, in request
OutOfRetries: Repeated socket failures
Code done running.
I've had this error or variations of this using CP 6.3.0 and all the way thru the progression of CP 7.0.0. I also see happen with the PyPortal and it doesn't seem to matter what the script is. If this is something that is a problem with my network, I wish I could find it.
More than likely intermittent, because it happens at different times, not at a set time period or length. Configuration:
Adafruit CircuitPython 7.0.0 on 2021-09-20; Adafruit Matrix Portal M4 with samd51j19
Board ID:matrixportal_m4
adafruit-circuitpython-bundle-7.x-mpy-20210928
Script:
Error:
I've had this error or variations of this using CP 6.3.0 and all the way thru the progression of CP 7.0.0. I also see happen with the PyPortal and it doesn't seem to matter what the script is. If this is something that is a problem with my network, I wish I could find it.
Scott