The tutorial at https://learn.adafruit.com/pico-w-wifi- ... dafruit-io
fails with a clean install of the latest versions of Circuit Python and libraries.
It fails 100% of the time on the second and subsequent run of the code, strangely the first execution works fine.
Hardware reset by power-off/on does NOT solve the problem. Only a fresh install, and then only for one run...
CP versions tested:
adafruit-circuitpython-raspberry_pi_pico_w-en_GB-8.0.0-beta.6.uf2
adafruit-circuitpython-raspberry_pi_pico_w-en_GB-20230126-a7b12de.uf2
Libraries tested:
adafruit-circuitpython-bundle-8.x-mpy-20221230
adafruit-circuitpython-bundle-8.x-mpy-20230125
An error message in the Mu serial interface implies a failure in adafruit_requests.py
Traceback (most recent call last):
File "code.py", line 33, in <module>
File "adafruit_io/adafruit_io.py", line 707, in get_feed
File "adafruit_io/adafruit_io.py", line 555, in _get
File "adafruit_requests.py", line 714, in get
File "adafruit_requests.py", line 655, in request
File "adafruit_requests.py", line 507, in _get_socket
RuntimeError: Sending request failed
The bug/feature seems similar to this:
https://github.com/adafruit/Adafruit_Ci ... issues/126
In case helpful, I have made CP / Adafruit IO work in the past, possibly with v7 of CP. Perhaps v7 to v8 changes explain this issue. Also the same hardware works just fine with WipperSnapper - again suggesting a CP/libraries codebase issue.
Anyone have a work around for current versions or know of working versions of CP/libraries?
Steve H
Adafruit IO & Raspberry Pi Pico W = Fail
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- bidrohini
- Posts: 202
- Joined: Thu Oct 20, 2022 10:03 am
Re: Adafruit IO & Raspberry Pi Pico W = Fail
Are the Adafruit IO and Raspberry Pi Pico W good? I mean, have you tested them separately?
- hyde00001
- Posts: 13
- Joined: Fri Jan 20, 2023 4:16 am
Re: Adafruit IO & Raspberry Pi Pico W = Fail
I have three Pico Ws. All fail in the same way. One of them is current working fine with Wippersnappper to load some simple temperature sensor data to Adafruit IO. So I’m reasonable confident it’s not a hardware thing. I’ve now flashed one to Micro Python and it can act as a trivial web server. The effect is seen on two different WiFi routers. So overall pretty it’s not a hardware thing.
Not sure how to test Adafruit Io as that’s kind of what’s failing. Got a suggestion on that??
As this has worked under. Earlier versions of CircuitPython and libraries in reasonably confident it’s a software/library thing. I wonder if my choice of “UK/GB English” for CP is a factor as possibly less tested than “American English” (don’t get Brits started on that one…)
Not sure how to test Adafruit Io as that’s kind of what’s failing. Got a suggestion on that??
As this has worked under. Earlier versions of CircuitPython and libraries in reasonably confident it’s a software/library thing. I wonder if my choice of “UK/GB English” for CP is a factor as possibly less tested than “American English” (don’t get Brits started on that one…)
- hyde00001
- Posts: 13
- Joined: Fri Jan 20, 2023 4:16 am
Re: Adafruit IO & Raspberry Pi Pico W = Fail
A little more digging shows the fail is here:
File "adafruit_requests.py", line 527, in _get_socket
OSError: (-29312, 'MBEDTLS_ERR_SSL_CONN_EOF')
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "code.py", line 33, in <module>
File "adafruit_io/adafruit_io.py", line 707, in get_feed
File "adafruit_io/adafruit_io.py", line 555, in _get
File "adafruit_requests.py", line 721, in get
File "adafruit_requests.py", line 661, in request
File "adafruit_requests.py", line 508, in _get_socket
RuntimeError: Sending request failed
I little googling of the primary error reveals this link:
https://forum.micropython.org/viewtopic ... 5&start=10
Where something vaguely similar was reported for MicroPython...
Unfortunately (for me) the code and explanation are beyond my level of understanding.
In the hope that CP or library updates fixed the problem I tried:
adafruit-circuitpython-raspberry_pi_pico_w-en_GB-8.0.0-rc.0.uf2
adafruit-circuitpython-bundle-8.x-mpy-20230129
Which are both new today. No luck problem still exists.
In case anyone can help, this code generates the problem 100% of the time for me...
import os
import time
import ssl
import wifi
import socketpool
import microcontroller
import board
import busio
import adafruit_requests
from adafruit_io.adafruit_io import IO_HTTP, AdafruitIO_RequestError
wifi.radio.connect(os.getenv('CIRCUITPY_WIFI_SSID'), os.getenv('CIRCUITPY_WIFI_PASSWORD'))
aio_username = os.getenv('aio_username')
aio_key = os.getenv('aio_key')
pool = socketpool.SocketPool(wifi.radio)
requests = adafruit_requests.Session(pool, ssl.create_default_context())
io = IO_HTTP(aio_username, aio_key, requests)
print("Connected to io. I get here everytime")
try:
# get feed
picowTemp_feed = io.get_feed("pitemp")
picowHumid_feed = io.get_feed("pihumid")
except AdafruitIO_RequestError:
# if no feed exists, create one
picowTemp_feed = io.create_new_feed("pitemp")
picowHumid_feed = io.create_new_feed("pihumid")
print("It's a miracle as I never get here")
File "adafruit_requests.py", line 527, in _get_socket
OSError: (-29312, 'MBEDTLS_ERR_SSL_CONN_EOF')
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "code.py", line 33, in <module>
File "adafruit_io/adafruit_io.py", line 707, in get_feed
File "adafruit_io/adafruit_io.py", line 555, in _get
File "adafruit_requests.py", line 721, in get
File "adafruit_requests.py", line 661, in request
File "adafruit_requests.py", line 508, in _get_socket
RuntimeError: Sending request failed
I little googling of the primary error reveals this link:
https://forum.micropython.org/viewtopic ... 5&start=10
Where something vaguely similar was reported for MicroPython...
Unfortunately (for me) the code and explanation are beyond my level of understanding.
In the hope that CP or library updates fixed the problem I tried:
adafruit-circuitpython-raspberry_pi_pico_w-en_GB-8.0.0-rc.0.uf2
adafruit-circuitpython-bundle-8.x-mpy-20230129
Which are both new today. No luck problem still exists.
In case anyone can help, this code generates the problem 100% of the time for me...
import os
import time
import ssl
import wifi
import socketpool
import microcontroller
import board
import busio
import adafruit_requests
from adafruit_io.adafruit_io import IO_HTTP, AdafruitIO_RequestError
wifi.radio.connect(os.getenv('CIRCUITPY_WIFI_SSID'), os.getenv('CIRCUITPY_WIFI_PASSWORD'))
aio_username = os.getenv('aio_username')
aio_key = os.getenv('aio_key')
pool = socketpool.SocketPool(wifi.radio)
requests = adafruit_requests.Session(pool, ssl.create_default_context())
io = IO_HTTP(aio_username, aio_key, requests)
print("Connected to io. I get here everytime")
try:
# get feed
picowTemp_feed = io.get_feed("pitemp")
picowHumid_feed = io.get_feed("pihumid")
except AdafruitIO_RequestError:
# if no feed exists, create one
picowTemp_feed = io.create_new_feed("pitemp")
picowHumid_feed = io.create_new_feed("pihumid")
print("It's a miracle as I never get here")
- hyde00001
- Posts: 13
- Joined: Fri Jan 20, 2023 4:16 am
Re: Adafruit IO & Raspberry Pi Pico W = Fail
So... I take one of my Pi Pico W boards that cannot execute the CP/IO Adafruit test code without failing. Then flash it to WipperSnapper. It then connects to the IO Adafruit service just fine and using Adafruit IO feeds/dashboards can turn the onboard off/on from the internet. All of that says my hardware is just fine - the Adafruit example at https://learn.adafruit.com/pico-w-wifi- ... dafruit-io just doesn't work (with CPv8/libraries)...
If anyone could help me make it work, that would be great...
If anyone could help me make it work, that would be great...
- hyde00001
- Posts: 13
- Joined: Fri Jan 20, 2023 4:16 am
Re: Adafruit IO & Raspberry Pi Pico W = Fail
Adding a short time.sleep immediately after any calls to import seems to fix this "feature".
- Mattrobo
- Posts: 4
- Joined: Thu Feb 09, 2023 7:59 am
Re: Adafruit IO & Raspberry Pi Pico W = Fail
Exactly where did you add time.sleep and how much did you "sleep" Thanks Mat
- hyde00001
- Posts: 13
- Joined: Fri Jan 20, 2023 4:16 am
Re: Adafruit IO & Raspberry Pi Pico W = Fail
I’ve added a time.sleep(5) immediately after all the import and from calls. This fixes the issue for me. I’ve not spent anytime optimising the length of the sleep - shorter durations may well be sufficient.
- Mattrobo
- Posts: 4
- Joined: Thu Feb 09, 2023 7:59 am
Re: Adafruit IO & Raspberry Pi Pico W = Fail
Thankyou. I also found this where they discuss it and fix it - https://github.com/adafruit/circuitpython/issues/7333
just needs to be in a release
just needs to be in a release
Please be positive and constructive with your questions and comments.