If it matters: I am receiving 25fps in a art-net protcol to control a led matrix
I shorted the code, but the problem stays...
Code: Select all
### configuration ###
TIMEOUT = 5 # time out socket
HOST = "192.168.4.1" # listing for this host
PORT = 1030 # listing on this port from the host
### imports ###
import time
import board
from digitalio import DigitalInOut
from adafruit_esp32spi import adafruit_esp32spi
import adafruit_esp32spi.adafruit_esp32spi_socket as socket
import udp_decoder
import neopixel
# Get wifi details and more from a secrets.py file
# adafruit standard
try:
from secrets import secrets
except ImportError:
print("WiFi secrets are kept in secrets.py, please add them there!")
raise
### wired pins ###
# to esp32
spi = board.SPI()
esp32_cs = DigitalInOut(board.D13)
esp32_ready = DigitalInOut(board.D11)
esp32_reset = DigitalInOut(board.D12)
esp = adafruit_esp32spi.ESP_SPIcontrol(spi, esp32_cs, esp32_ready, esp32_reset)
connected = 0
while not connected:
try:
# connect to wifi AP (RPI)
esp.connect(secrets)
print(connected)
connected = 1
except:
print("Tryng to connect again")
print("My IP address is", esp.pretty_ip(esp.ip_address))
# test for connectivity to server
print("Server ping:", esp.ping(HOST), "ms")
# create the socket
socket.set_interface(esp)
socketaddr = socket.getaddrinfo(HOST, PORT)[0][4]
s = socket.socket(type=socket.SOCK_DGRAM)
s.settimeout(TIMEOUT)
s.connect(socketaddr, conntype=esp.UDP_MODE)
ii = 0
while 1:
print("looping")#see if still alive
# amount = s.available() # also not vorking
amount = s.recv(1500)
if amount:
# here would be my code
print(ii)
ii += 1
time.sleep(0.0025) #estimated time for neopixel control of my matrix