This post show how ESP32 flashed with adafruit nina-fw, act as WiFi Co-Processor work with Raspberry Pi Pico with CircuitPython.
adafruit nina-fw is a slight variant of the Arduino WiFiNINA core. The ESP32 used here is a ESP32-S breadout board, flash with current latest version NINA_W102-1.7.3.bin.
Raspberry Pi Pico is flashed CircuitPython 6.2.0, with adafruit_esp32spi and adafruit_requests libraries installed.
Install nina-fw on ESP32
In my practice, esptool is used to flash ESP32, on Raspberry Pi. Read Install esptool on Raspberry Pi OS.
Download adafruit nina-fw:
Visit https://github.com/adafruit/nina-fw/releases/latest, to download latest nina-fw.bin file, NINA_W102-1.7.3.bin currently.
Flash ESP32 using esptool:
Depends on your ESP32 board, connect and force it into bootloader mode, may
be:
- Press and hold GPIO0 to GND
- Reset ESP32
- Release GPIO0
Run the command:
$ esptool.py --port /dev/ttyUSB0 --before no_reset --baud 115200 write_flash 0 NINA_W102-1.7.3.bin
where:
- /dev/ttyUSB0 is the usb port connect to ESP32
-
NINA_W102-1.7.3.bin is the downloaded nina-fw file.
Connect ESP32 to Raspberry Pi Pico
ESP32 RPi Pico
3.3V 3.3V 3.3V
GND GND GND
SCK IO18 GP10
MISO IO23 GP12
MOSI IO14 GP11
CS IO5 GP13
BUSY IO33 GP14
RESET EN GP15
GPIO0 IO0
RXD RXD0
TX TXD0
Download libraries:
Visit https://circuitpython.org/libraries to download the appropriate bundle for your version of CircuitPython.
Unzip the file and copy adafruit_esp32spi folder and adafruit_requests.mpy to lib folder of Pico's CIRCUITPY driver.
Test CircuitPython code on Raspberry Pi Pico
Copy from https://learn.adafruit.com/quickstart-rp2040-pico-with-wifi-and-circuitpython/circuitpython-wifi.
import board
import busio
from digitalio import DigitalInOut
from adafruit_esp32spi import adafruit_esp32spi
import adafruit_requests as requests
print("Raspberry Pi RP2040 - ESP32SPI hardware test")
esp32_cs = DigitalInOut(board.GP13)
esp32_ready = DigitalInOut(board.GP14)
esp32_reset = DigitalInOut(board.GP15)
spi = busio.SPI(board.GP10, board.GP11, board.GP12)
esp = adafruit_esp32spi.ESP_SPIcontrol(spi, esp32_cs, esp32_ready, esp32_reset)
if esp.status == adafruit_esp32spi.WL_IDLE_STATUS:
print("ESP32 found and in idle mode")
print("Firmware vers.", esp.firmware_version)
print("MAC addr:", [hex(i) for i in esp.MAC_address])
for ap in esp.scan_networks():
print("\t%s\t\tRSSI: %d" % (str(ap['ssid'], 'utf-8'), ap['rssi']))
print("Done!")
reference:
~ adafruit learn: Quickstart IoT - Raspberry Pi Pico RP2040 with WiFi
~
adafruit_esp32spi doc
~ adafruit_requests doc
No comments:
Post a Comment