Please note: Friday June 18 is a holiday celebrating Juneteenth, please allow extra time for your order to arrive and plan accordingly.
0

very slow esp32spi on Arduino Nano Connect
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

very slow esp32spi on Arduino Nano Connect

by asura on Thu Jun 03, 2021 4:08 pm

68bps :(

Code below:
Code: Select all | TOGGLE FULL SIZE
# This example is CircuitPython from https://github.com/adafruit/circuitpython/pull/4802
# had to use https://raw.githubusercontent.com/adafruit/Adafruit_CircuitPython_ESP32SPI/f97db45bbe6072ae08c56773ba49eb9f5b779725/adafruit_esp32spi/adafruit_esp32spi_wsgiserver.py

import busio
import board
import digitalio

import adafruit_requests as requests
import adafruit_esp32spi.adafruit_esp32spi_socket as socket
from adafruit_esp32spi import adafruit_esp32spi_wsgiserver as server
from adafruit_esp32spi import adafruit_esp32spi
from adafruit_wsgi.wsgi_app import WSGIApp

import secrets

esp32_cs = digitalio.DigitalInOut(board.CS1)
esp32_ready = digitalio.DigitalInOut(board.ESP_BUSY)
esp32_reset = digitalio.DigitalInOut(board.ESP_RESET)

spi = busio.SPI(board.SCK1, board.MOSI1, board.MISO1)

# Default:
#>>> spi.frequency
#7812500
while not spi.try_lock():
    continue
spi.configure(baudrate=62500000)
spi.unlock()
#>>> spi.frequency
#62500000

esp = adafruit_esp32spi.ESP_SPIcontrol(spi, esp32_cs, esp32_ready, esp32_reset)

def connect():
    esp.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])

    print('Connecting to AP')

    while not esp.is_connected:
        print("Connecting...")
        try:
            esp.connect_AP(secrets.ssid, secrets.password)
        except RuntimeError as e:
            print("Failed to connect, retrying: ", e)
            continue

    print(f'Connected to {str(esp.ssid, "utf-8")}, RSSI: {esp.rssi}')
    print(f'IP: {esp.pretty_ip(esp.ip_address)}')

app = WSGIApp()

@app.route("/test")
def webapp_test(request):
    return('200 OK', [], ['a'] * 1024)

@app.route("/reboot")
def webapp_reboot(request):
    print('Restarting')
    import microcontroller
    microcontroller.reset()

@app.route("/reconnect")
def webapp_reconnect(request):
    esp.reset()

led = digitalio.DigitalInOut(board.LED)
led.direction = digitalio.Direction.OUTPUT

connect()

server.set_interface(esp)
wsgiServer = server.WSGIServer(80, application=app)

wsgiServer.start()

while True:
    try:
        wsgiServer.update_poll()
        # other stuff
    except (TypeError, ValueError, RuntimeError) as e:
        connect()
        server.set_interface(esp)
        wsgiServer = server.WSGIServer(80, application=app)

        wsgiServer.start()

# Version:
#Adafruit CircuitPython 7.0.0-alpha.2-646-g7df5d74d9 on 2021-05-22; Arduino Nano RP2040 Connect with rp2040

# Output:
#ESP32 found and in idle mode
#Firmware vers. bytearray(b'1.4.5\x00')
#MAC addr: <macid>
#Connecting to AP
#Connecting...
#Connected to <ssid>, RSSI: -38
#IP: <IP>
#closing

# Client:
#$ wget <IP>/test
#--2021-06-03 14:47:48--  http://<IP>/test
#Connecting to <IP>:80... connected.
#HTTP request sent, awaiting response... 200 OK
#Length: unspecified
#Saving to: ‘test’
#
#test                              [                   <=>                          ]   1.00K  68.4 B/s    in 15s     
#
#2021-06-03 14:48:03 (68.6 B/s) - ‘test’ saved [1024]

asura
 
Posts: 3
Joined: Thu Jun 03, 2021 4:07 pm

Please be positive and constructive with your questions and comments.