Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OSError: [Errno 116] ETIMEDOUT while using the adafruit_ntp.py library #42

Open
wavesailor opened this issue Oct 17, 2024 · 0 comments
Open

Comments

@wavesailor
Copy link

So I just updated my MagTag to the latest version of everything - Adafruit CircuitPython 9.1.4 on 2024-09-17; Adafruit MagTag with ESP32S2
Now I get the following error:

  File "adafruit_ntp.py", line 93, in _update_time_sync
OSError: [Errno 116] ETIMEDOUT

I created a simple test to replicate the problem using the example code: Adafruit_CircuitPython_NTP/examples/ntp_simpletest.py. The error does not always happen the first time I run it but usually on the 2nd or 3rd attempt, it crashes.

# SPDX-FileCopyrightText: 2022 Scott Shawcroft for Adafruit Industries
# SPDX-License-Identifier: MIT

"""Print out time based on NTP."""

import os
import time

import socketpool
import wifi

import adafruit_ntp

from adafruit_magtag.magtag import MagTag

magtag = MagTag()
URL = "https://swapi.dev/api/"
resp = magtag.network.fetch(URL)
print(resp.json())
print("*****************")

# Get wifi AP credentials from a settings.toml file
wifi_ssid = os.getenv("CIRCUITPY_WIFI_SSID")
wifi_password = os.getenv("CIRCUITPY_WIFI_PASSWORD")
if wifi_ssid is None:
    print("WiFi credentials are kept in settings.toml, please add them there!")
    raise ValueError("SSID not found in environment variables")

try:
    wifi.radio.connect(wifi_ssid, wifi_password)
except ConnectionError:
    print("Failed to connect to WiFi with provided credentials")
    raise

pool = socketpool.SocketPool(wifi.radio)
ntp = adafruit_ntp.NTP(pool, tz_offset=0, cache_seconds=3600)

print(ntp.datetime)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant