Metro M4 Express AirLift (WIFI) ImportError

Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
DBlanding
 
Posts: 21
Joined: Sun Mar 14, 2021 7:45 am

Metro M4 Express AirLift (WIFI) ImportError

Post by DBlanding »

I have the Metro M4 Express AirLift (WIFI) - Lite
I am unable to get ntp_simpletest.py example working.
I get
ImportError: no module named 'wifi'
and
ImportError: no module named 'socketpool'
Where do I find these libraries? I cannot find them in the 7.x bundle. And they are not listed as built-in libraries.
I have tried installing them with pip3, but that doesn't help either.

User avatar
dastels
 
Posts: 15653
Joined: Tue Oct 20, 2015 3:22 pm

Re: Metro M4 Express AirLift (WIFI) ImportError

Post by dastels »

Post the entire backtrace from the REPL rather than just the single lines. Context is often more useful than the actual error.

Dave

User avatar
DBlanding
 
Posts: 21
Joined: Sun Mar 14, 2021 7:45 am

Re: Metro M4 Express AirLift (WIFI) ImportError

Post by DBlanding »

Here is the code:

Code: Select all

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

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

import time
import socketpool
import wifi

import adafruit_ntp

# Get wifi details and more from a secrets.py file
try:
    from secrets import secrets
except ImportError:
    print("WiFi secrets are kept in secrets.py, please add them there!")
    raise

wifi.radio.connect(secrets["ssid"], secrets["password"])

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

while True:
    print(ntp.datetime)
    time.sleep(1)
and here is the backtrace:

Code: Select all

code.py output:
Traceback (most recent call last):
  File "code.py", line 7, in <module>
ImportError: no module named 'socketpool'

User avatar
dastels
 
Posts: 15653
Joined: Tue Oct 20, 2015 3:22 pm

Re: Metro M4 Express AirLift (WIFI) ImportError

Post by dastels »

OK. The socketpool and wifi modules ARE builtin modules, but not in the Metro Airlift build. They seem to be in the builds for ESP32 family based boards. E.g. the Metro ESP32-S2 https://www.adafruit.com/product/4775.

Dave

User avatar
DBlanding
 
Posts: 21
Joined: Sun Mar 14, 2021 7:45 am

Re: Metro M4 Express AirLift (WIFI) ImportError

Post by DBlanding »

So, where does that leave me? I bought the M4 Express AirLift (WiFi) because I wanted to use CircuitPython and have access to ntp. Is there a workaround that uses different libraries that will allow the M4 Express Airlift board to access the ntp server?
I looked at the Adafruit Metro ESP32-S2 but it doesn't mention whether it works with CircuitPython. Do you know if it does?
Last edited by DBlanding on Fri Jan 27, 2023 11:57 am, edited 1 time in total.

User avatar
dastels
 
Posts: 15653
Joined: Tue Oct 20, 2015 3:22 pm

Re: Metro M4 Express AirLift (WIFI) ImportError

Post by dastels »

You'll just need to use a different approach to connect to the network, See https://learn.adafruit.com/adafruit-met ... -connect-2.

Dave

User avatar
DBlanding
 
Posts: 21
Joined: Sun Mar 14, 2021 7:45 am

Re: Metro M4 Express AirLift (WIFI) ImportError

Post by DBlanding »

I tried that, but it didn't work very well. It struggles to connect. By the time it completes the connection, the moment of interest has long past. Here is the output from the terminal:

Code: Select all

code.py output:
ESP32 SPI webclient test
ESP32 found and in idle mode
Firmware vers. bytearray(b'1.2.2\x00')
MAC addr: ['0x20', '0xbf', '0x1e', '0x51', '0x91', '0x40']
	NETGEAR90		RSSI: -54
	Jim Wifi		RSSI: -88
	WRCHPD		RSSI: -88
	Gators		RSSI: -90
	Kiwi		RSSI: -92
	CaptionCall2_298115		RSSI: -94
Connecting to AP...
could not connect to AP, retrying:  ('No such ssid', b'NETGEAR90')
could not connect to AP, retrying:  ('Failed to connect to ssid', b'NETGEAR90')
could not connect to AP, retrying:  ('Failed to connect to ssid', b'NETGEAR90')
could not connect to AP, retrying:  ('Failed to connect to ssid', b'NETGEAR90')
could not connect to AP, retrying:  ('Failed to connect to ssid', b'NETGEAR90')
could not connect to AP, retrying:  ('No such ssid', b'NETGEAR90')
could not connect to AP, retrying:  ('Failed to connect to ssid', b'NETGEAR90')
could not connect to AP, retrying:  ('Failed to connect to ssid', b'NETGEAR90')
could not connect to AP, retrying:  ('Failed to connect to ssid', b'NETGEAR90')
could not connect to AP, retrying:  ('Failed to connect to ssid', b'NETGEAR90')
could not connect to AP, retrying:  ('Failed to connect to ssid', b'NETGEAR90')
could not connect to AP, retrying:  ('Failed to connect to ssid', b'NETGEAR90')
could not connect to AP, retrying:  ('Failed to connect to ssid', b'NETGEAR90')
could not connect to AP, retrying:  ('Failed to connect to ssid', b'NETGEAR90')
could not connect to AP, retrying:  ('Failed to connect to ssid', b'NETGEAR90')
could not connect to AP, retrying:  ('Failed to connect to ssid', b'NETGEAR90')
could not connect to AP, retrying:  ('Failed to connect to ssid', b'NETGEAR90')
could not connect to AP, retrying:  ('Failed to connect to ssid', b'NETGEAR90')
could not connect to AP, retrying:  ('Failed to connect to ssid', b'NETGEAR90')
could not connect to AP, retrying:  ('Failed to connect to ssid', b'NETGEAR90')
could not connect to AP, retrying:  ('No such ssid', b'NETGEAR90')
could not connect to AP, retrying:  ('Failed to connect to ssid', b'NETGEAR90')
could not connect to AP, retrying:  ('Failed to connect to ssid', b'NETGEAR90')
could not connect to AP, retrying:  ('Failed to connect to ssid', b'NETGEAR90')
could not connect to AP, retrying:  ('Failed to connect to ssid', b'NETGEAR90')
could not connect to AP, retrying:  ('No such ssid', b'NETGEAR90')
could not connect to AP, retrying:  ('Failed to connect to ssid', b'NETGEAR90')
could not connect to AP, retrying:  ('Failed to connect to ssid', b'NETGEAR90')
could not connect to AP, retrying:  ('Failed to connect to ssid', b'NETGEAR90')
could not connect to AP, retrying:  ('Failed to connect to ssid', b'NETGEAR90')
could not connect to AP, retrying:  ('Failed to connect to ssid', b'NETGEAR90')
could not connect to AP, retrying:  ('Failed to connect to ssid', b'NETGEAR90')
could not connect to AP, retrying:  ('No such ssid', b'NETGEAR90')
could not connect to AP, retrying:  ('Failed to connect to ssid', b'NETGEAR90')
could not connect to AP, retrying:  ('Failed to connect to ssid', b'NETGEAR90')
could not connect to AP, retrying:  ('No such ssid', b'NETGEAR90')
could not connect to AP, retrying:  ('Failed to connect to ssid', b'NETGEAR90')
could not connect to AP, retrying:  ('No such ssid', b'NETGEAR90')
could not connect to AP, retrying:  ('Failed to connect to ssid', b'NETGEAR90')
Connected to NETGEAR90 	RSSI: -52
My IP address is 192.168.1.22
IP lookup adafruit.com: 104.20.38.240
Ping google.com: 240 ms
Fetching text from http://wifitest.adafruit.com/testwifi/index.html
----------------------------------------
This is a test of Adafruit WiFi!
If you can read this, its working :)
----------------------------------------

Fetching json from http://api.coindesk.com/v1/bpi/currentprice/USD.json
----------------------------------------
{'time': {'updated': 'Jan 27, 2023 11:46:00 UTC', 'updatedISO': '2023-01-27T11:46:00+00:00', 'updateduk': 'Jan 27, 2023 at 11:46 GMT'}, 'disclaimer': 'This data was produced from the CoinDesk BANNED Price Index (USD). Non-USD currency data converted using hourly conversion rate from openexchangerates.org', 'bpi': {'USD': {'code': 'USD', 'description': 'United States Dollar', 'rate_float': 22971.9, 'rate': '22,971.8639'}}}
----------------------------------------
Done!

User avatar
dastels
 
Posts: 15653
Joined: Tue Oct 20, 2015 3:22 pm

Re: Metro M4 Express AirLift (WIFI) ImportError

Post by dastels »

It looks like you have bigger problems. It looks like the connection to NETGEAR90 is sketchy. Can you move closer and/or more inline of sight?

Dave

User avatar
DBlanding
 
Posts: 21
Joined: Sun Mar 14, 2021 7:45 am

Re: Metro M4 Express AirLift (WIFI) ImportError

Post by DBlanding »

I am actually already on a line of sight at about 30 feet away. But I tried moving right next to the router and it did get better. It managed to connect after the third try.

Code: Select all

code.py output:
ESP32 SPI webclient test
ESP32 found and in idle mode
Firmware vers. bytearray(b'1.2.2\x00')
MAC addr: ['0x20', '0xbf', '0x1e', '0x51', '0x91', '0x40']
	NETGEAR90		RSSI: -31
	WRCHPD		RSSI: -82
	Kiwi		RSSI: -85
	Gators		RSSI: -86
	DUNHome		RSSI: -96
Connecting to AP...
could not connect to AP, retrying:  ('No such ssid', b'NETGEAR90')
could not connect to AP, retrying:  ('Failed to connect to ssid', b'NETGEAR90')
could not connect to AP, retrying:  ('Failed to connect to ssid', b'NETGEAR90')
Connected to NETGEAR90 	RSSI: -26
My IP address is 192.168.1.22
IP lookup adafruit.com: 104.20.39.240
Ping google.com: 3760 ms
Fetching text from http://wifitest.adafruit.com/testwifi/index.html
----------------------------------------
This is a test of Adafruit WiFi!
If you can read this, its working :)
----------------------------------------

Fetching json from http://api.coindesk.com/v1/bpi/currentprice/USD.json
----------------------------------------
{'time': {'updated': 'Jan 27, 2023 18:17:00 UTC', 'updatedISO': '2023-01-27T18:17:00+00:00', 'updateduk': 'Jan 27, 2023 at 18:17 GMT'}, 'disclaimer': 'This data was produced from the CoinDesk BANNED Price Index (USD). Non-USD currency data converted using hourly conversion rate from openexchangerates.org', 'bpi': {'USD': {'code': 'USD', 'description': 'United States Dollar', 'rate_float': 23150.2, 'rate': '23,150.1725'}}}
----------------------------------------
Done!

Code done running.

Locked
Please be positive and constructive with your questions and comments.

Return to “Metro, Metro Express, and Grand Central Boards”