Does anyone have working Pi Pico W - Adafruit IO code?

Moderators: adafruit_support_bill, adafruit

Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
Locked
User avatar
hyde00001
 
Posts: 13
Joined: Fri Jan 20, 2023 4:16 am

Does anyone have working Pi Pico W - Adafruit IO code?

Post by hyde00001 »

I've been trying to get the code at https://learn.adafruit.com/pico-w-wifi- ... dafruit-io to work consistently without luck.

After a fresh install it works fine until either (i) power is removed and then re-applied or (ii) an error is introduced into the code during rounds of code editing. After either of things happen the code always fails at the line

Code: Select all

picowTemp_feed = io.get_feed("pitemp") 
It exits with an moderately cryptic error code:
File "adafruit_requests.py", line 527, in _get_socket
OSError: (-29312, 'MBEDTLS_ERR_SSL_CONN_EOF')

What is really strange is that before a power cycle or debugging error the code works fine - uploading temp/humidity data as expected. Once the error has occurred, the board can only be reset by reloading the CircuitPython.uf2 file which is a sort of work around (but this approach doesn't allow the board to operate autonomously away from a computer which is annoying..).

So assuming I must be doing something really stupid, does anyone have CP code for a Pi Pico W that in their hands appropriately uploads data to Adafruit IO? If so, can you kindly share??

Many thanks, but I'm not really interested in suggestions to use WipperSnapper - that indeed works just fine in my hands, but as I'm looking to do more than just upload simple sensor data once I get going, that isn't really a solution...

User avatar
jastec
 
Posts: 1
Joined: Sat Feb 04, 2023 9:02 am

Re: Does anyone have working Pi Pico W - Adafruit IO code?

Post by jastec »

I'm getting the same problem as well. Like yours it worked first time and started logging results up to IO, then when I moved it to another location on power only, nothing seemed to happen. Connecting it back up to the PC resulted in the same error as you're getting.

User avatar
hyde00001
 
Posts: 13
Joined: Fri Jan 20, 2023 4:16 am

Re: Does anyone have working Pi Pico W - Adafruit IO code?

Post by hyde00001 »

While that must be frustrating for you, I'm kind of glad it's not just me! I have generated some chat on the Adafruit Circuit python discord channel about this topic, but this is still at the level of "have you tried a different version of CP" (answer yes all of the beta and candidate v8 builds...) etc. I'm going I keep hoping the Circuit Python / Adafruit IO people will fix this, but in the meantime, I might focus on getting my sensors working and the wiring I need to sort (I'm trying to monitor the performance of a small solar panel as a prelude to installing a full house system if the data looks promising...). If anyone has simple, reliable sensor update code and or library for Pi Pico W with any IoT platform in Circuit/Micro/Full-fat Python, I'd be delighted to receive it...

User avatar
danhalbert
 
Posts: 4652
Joined: Tue Aug 08, 2017 12:37 pm

Re: Does anyone have working Pi Pico W - Adafruit IO code?

Post by danhalbert »

We are seeing the same error here: https://github.com/adafruit/circuitpyth ... 1416879013. It looks like if you introduce a short delay (5 seconds, probably less) at the beginning of the program, it will avoid this problem. We will try to fix this without needing the delay, but try that as a workaround for now.

User avatar
hyde00001
 
Posts: 13
Joined: Fri Jan 20, 2023 4:16 am

Re: Does anyone have working Pi Pico W - Adafruit IO code?

Post by hyde00001 »

That work around seems to be working for me - brilliant! Thank you

User avatar
Mattrobo
 
Posts: 4
Joined: Thu Feb 09, 2023 7:59 am

Re: Does anyone have working Pi Pico W - Adafruit IO code?

Post by Mattrobo »

I have the same error on this project - https://learn.adafruit.com/pico-w-wifi- ... dafruit-io

mine worked perfectly the first go and then a few days later, but as soon as I unplugged it to run headless I got this error - and then when it was plugged back into the computer and also the next day as well (plugged in)

Traceback (most recent call last):
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 "<stdin>", line 62, 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

And when I put print to screen messages everywhere it is getting stuck and crashing at the get feed. If I ignore the get feed and jump to make feed it crashes there as well.

Code: Select all

try:
# get feed
    print("sleep for Adafruit website to catchup")
    time.sleep(10)
    print("get feed")
    picowTemp_feed = io.get_feed("pitemp")
    picowHumid_feed = io.get_feed("pihumid")
except AdafruitIO_RequestError:
# if no feed exists, create one
    print("make feed")
    picowTemp_feed = io.create_new_feed("pitemp10")
    picowHumid_feed = io.create_new_feed("pihumid10")
I put the delay in there but it didnt help

User avatar
hyde00001
 
Posts: 13
Joined: Fri Jan 20, 2023 4:16 am

Re: Does anyone have working Pi Pico W - Adafruit IO code?

Post by hyde00001 »

FWIW, at the top of my circuit python code I have (as is traditional) a series of import and from statements to add the libraries needed for my code. If add time.sleep(5) immediately after all the import and from statements then my WiFi connection will work fine (a shorter delay may well work - haven't spent anytime trying). Similar time.sleep(5) calls later in the code don't fix the issue for me, can't explain why but it is as if the Pi Pico W needs a little extra time to properly startup before executing Circuit Python code. Hope that helps.

User avatar
Mattrobo
 
Posts: 4
Joined: Thu Feb 09, 2023 7:59 am

Re: Does anyone have working Pi Pico W - Adafruit IO code?

Post by Mattrobo »

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

Locked
Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.

Return to “Internet of Things: Adafruit IO and Wippersnapper”