Adafruit Industries, Essential service and business: NYC – Executive Order 202.6 - Read more.
0

Sample code not working
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Sample code not working

by alsy on Sun Mar 01, 2020 5:05 pm

trying to run esp32spi_simpletest.py on my Metro M4 Airlift lite and get an error on line 6
ImportError: no module named 'adafruit_requests'

the code.py on the metro after setting up CircuitPython uses

import adafruit_esp32spi.adafruit_esp32spi_requests as requests

That little sample works...but doesn't use requests for anything, the simpletest.py uses requests to "requests.set_socket(socket, esp)" which fails if I try substituting the above import line substitution telling me
module has no attribute set_socket

so, it would seem I don't have the right library imported

Any help would be appreciated

alsy
 
Posts: 12
Joined: Fri Apr 13, 2012 1:58 pm

Re: Sample code not working

by dastels on Sun Mar 01, 2020 5:18 pm

What's in CIRCUITPY/lib?

dastels
 
Posts: 1906
Joined: Tue Oct 20, 2015 3:22 pm

Re: Sample code not working

by alsy on Sun Mar 01, 2020 7:49 pm

folder adafruit_esp32spi containing
adafruit_esp32spi.mpy
adafruit_esp32spi_requests.mpy
adafruit_esp32spi_socket.mpy
adafruit_esp32spi_wifimanager.mpy

I reloaded the uf2 earlier today and still had the same results as per my original post

alsy
 
Posts: 12
Joined: Fri Apr 13, 2012 1:58 pm

Re: Sample code not working

by dastels on Sun Mar 01, 2020 9:03 pm

What version of CircuitPython?

Do you have the most recent library bundle from https://circuitpython.org/libraries?

Dave

dastels
 
Posts: 1906
Joined: Tue Oct 20, 2015 3:22 pm

Re: Sample code not working

by alsy on Sun Mar 01, 2020 10:14 pm

Hi Dave,

I have not replaced the libraries that were in the UF2 from here
https://circuitpython.org/board/metro_m4_airlift_lite/

Should I?

alsy
 
Posts: 12
Joined: Fri Apr 13, 2012 1:58 pm

Re: Sample code not working

by dastels on Sun Mar 01, 2020 10:28 pm

The UF2 is CircuitPython, the libraries are separate.

With the newer boards (Which the Metro M4 AirLift qualifies as, IMO, you should use the latest. So that means the 5.0.0.rc1 UF2 from https://circuitpython.org/board/metro_m4_airlift_lite/ and the 5.x library bundle from https://circuitpython.org/libraries.

Dave

dastels
 
Posts: 1906
Joined: Tue Oct 20, 2015 3:22 pm

Re: Sample code not working

by alsy on Mon Mar 02, 2020 11:12 am

I copied the libraries over from the bundle and same results

alsy
 
Posts: 12
Joined: Fri Apr 13, 2012 1:58 pm

Re: Sample code not working

by dastels on Mon Mar 02, 2020 11:28 am

Something just clicked for me.

Some of your code is out of date.

Get a fresh version of simpletest.py from github (or use the Internet Connect! example in the Metro M4 Express Airlift Lite guide) The structure of the esp32spi library has changed and requests is a top level adafruit_requests.mpy library.

Dave

dastels
 
Posts: 1906
Joined: Tue Oct 20, 2015 3:22 pm

Re: Sample code not working

by alsy on Mon Mar 02, 2020 7:50 pm

Getting all the libraries and samples from github did the trick

That will now be my first step if I have failed sample code (as opposed to my own code which always has a first step of checking fatfinger problems)

alsy
 
Posts: 12
Joined: Fri Apr 13, 2012 1:58 pm

Re: Sample code not working

by dastels on Mon Mar 02, 2020 11:32 pm

Good stuff!

Dave

dastels
 
Posts: 1906
Joined: Tue Oct 20, 2015 3:22 pm

Please be positive and constructive with your questions and comments.