Reputation: 6850
I'm trying to connect my Arduino Nano RP2040 with MicroPython to my local WiFi network and make a HTTP request.
The Nina W102 uBlox module on the board is an ESP32 and connects to the RP2040 via SPI (I'm not sure what this means but I thought it might be relevant).
I've found this code snippet that seems to do what I want
def do_connect():
import network
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
if not wlan.isconnected():
print('connecting to network...')
wlan.connect('SKYNET', 'G1V31NT3RN3T')
while not wlan.isconnected():
pass
print('network config:', wlan.ifconfig())
do_connect()
But it breaks with:
Traceback (most recent call last): File "", line 1, in ImportError: no module named 'network'
Im using Thonny as an editor and tried to search their packages for something called "Network" and found a match. But that gives me the below error/warning.
Any help or tips greatly appreciated.
UPDATE 1: Found this example with WiFi using CircuitPython. Would prefer to use MicroPython, but if all else fails I might have to switch firmwares. https://learn.adafruit.com/circuitpython-on-the-arduino-nano-rp2040-connect/wifi
UPDATE 2: Opted to use CircuitPython. Getting WiFi was then quite easy.
Upvotes: 0
Views: 919
Reputation: 7308
Raspberry Pi Pico does not have any network capability.
Your provided code looks like from micropython for chips, that has wifi inside (ESP family, some others)
Looks like Arduino RP2040 board has wifi option, but via Nina W102 uBlox, using SPI, witch is ESP32 under the hood. Probably, Nina's firmware is to provide WIFI/BLE and being controlled via SPI.
I assume, Adafruit wrote circuitpython driver to control Nina chip. My wild guess is that Nina uses AT+ commands. Sometimes circuityphons libs works on micropython. If that is not the case this time- you need network driver for it. Quick search did not gave me any result.
Conclusion- use Circuipython or write/find driver for Nina on Micropython
Upvotes: 1