adafruit / Adafruit_CircuitPython_MPL3115A2

CircuitPython module for the MPL3115A2 barometric pressure & temperature sensor.
MIT License
5 stars 8 forks source link

OSError: [Errno 116] ETIMEDOUT on RPi PicoW #29

Open bobkster opened 1 year ago

bobkster commented 1 year ago

I have a Raspberry Pi Pico W Connected to a PiCowBell Proto - no other connections or modifications. I am running CircutiPython latest stable for RPi Pico W: adafruit-circuitpython-raspberry_pi_pico_w-en_US-8.1.0.uf2 (downloaded 5/28/2023). I have one lib installed: adafruit_ntp.mpy (from adafruit-circuitpython-bundle-8.x-mpy-20230610)

Summary:

  1. I get an "OSError [Errno 116] ETIMEDOUT" when running immediately following a reset.
  2. Running again, the code runs correctly.
  3. Following are: a) code.py, b) and c) output of two runs

Please let me know if there is any other data you need, and as I am new to CircuitPython and PicoW, please provide instructions. if this is an existing issue, please direct me to it and I'll follow that. Note: this does not appear [to me] to be: https://github.com/adafruit/Adafruit_CircuitPython_MPL3115A2/issues/19, though it has similarities.

Thank you.


a) code.py: import os import wifi import socketpool import time import adafruit_ntp import rtc

print("*** Initial time:", time.localtime())

ssid = os.getenv('CIRCUITPY_WIFI_SSID') passwd = os.getenv('CIRCUITPY_WIFI_PASSWORD')

wifi.radio.connect(ssid, passwd) pool = socketpool.SocketPool(wifi.radio) ip = wifi.radio.ipv4_address

print("*** Connected to WiFi:", ip)

ntp = adafruit_ntp.NTP(pool, tz_offset=-6) # Denver rtc.RTC().datetime = ntp.datetime

print("*** Current time:", time.localtime())


b) REPL output immediately following a RESET via PyCowBell (viewed using Mu editor): Auto-reload is on. Simply save files over USB to run them or enter REPL to disable. code.py output: Initial time: struct_time(tm_year=2020, tm_mon=1, tm_mday=1, tm_hour=0, tm_min=0, tm_sec=11, tm_wday=2, tm_yday=1, tm_isdst=-1) Connected to WiFi: 192.168.1.131 Traceback (most recent call last): File "code.py", line 30, in File "adafruit_ntp.py", line 80, in datetime OSError: [Errno 116] ETIMEDOUT

Code done running.


c) Running a second time via Ctrl-D, REPL output:

soft reboot

Auto-reload is on. Simply save files over USB to run them or enter REPL to disable. code.py output: Initial time: struct_time(tm_year=2020, tm_mon=1, tm_mday=1, tm_hour=0, tm_min=7, tm_sec=19, tm_wday=2, tm_yday=1, tm_isdst=-1) Connected to WiFi: 192.168.1.131 *** Current time: struct_time(tm_year=2023, tm_mon=6, tm_mday=10, tm_hour=19, tm_min=53, tm_sec=6, tm_wday=5, tm_yday=161, tm_isdst=-1)

Code done running.

bobkster commented 1 year ago

I have been able to workaround this issue using try/expect and adding 2s sleep during the expect:
try: wifi.radio.connect(ssid, passwd) # connect to your SSID except ConnectionError as ce: print("ConnectionError:", ce, ", trying again!") time.sleep(2) wifi.radio.connect(ssid, passwd) Thus far, this has been successful after numerous resets.