Reputation: 1
I'm using microPython on a Arduino Nano Connect RP2040 and I'm trying to request an https website using the "urequests" library. Every time I try, I get the error message: "ImportError: no module named 'ussl'". I thought microPython would contain the ussl module. However, somehow that doesn't seem to be the case. I've tried several micropython versions and searched everywhere but could not find a way to fix this.
import urequests as requests
url = "https://api.spotify.com/v1/me/player/next?device_id=****"
token = '****'
headers = {
"Authorization": "Bearer" + token,
"Accept": "application/json",
"Content-Type": "application/json"
}
result = requests.post(url, headers=headers)
print(result.status_code)
MicroPython: v1.18-omv-r13
IDE: OpenMV (v4.3.3)
HAL: v1.3.0
BOARD: Arduino Nano RP2040 Connect-RP2040
Upvotes: 0
Views: 1173
Reputation: 1
first of all:
With these insights, I cloned the micropython repo and modified the firmware files for my Arduino Nano RP2040 Connect. With the new modification i build a new firmware.
You need to clone the repo to build a firmware. The .git is necessary for the build process
micropython repo: https://github.com/micropython/micropython
arduino folder: micropython/ports/rp2/boards/ARDUINO_NANO_RP2040_CONNECT/
I just added
"set(MICROPY_PY_USSL 1)" in the mpconfigboard.cmake
"#define MICROPY_PY_USSL (1)" in the mpconfigboard.h
After deployment, it is no longer possible to use an IDE to boot the board. You can edit the main.py normally while the board is connected to your PC. However, you must disconnect the power briefly after editing to allow a reboot.
Upvotes: 0