-->
Page 1 of 2

Reading UDP Packets

PostPosted: Wed Jul 13, 2016 5:12 pm
by DJRed2000
I've written code to read UDP packets and then output them to an Arduino Due over serial. The packets are E1.31 (DMX over ethernet) data and each packet is 638 bytes. I can send 3 universes no problem but any more than 3 and the ESP begins to get backed up and the packets are no longer read in real time. If I stop transmitting data, the ESP continues to output that it is still reading data. I am using an ESP-01 chip. Is there anything I can do to improve the throughput?

Here is my simple test code:

Code: Select all#include <ESP8266WiFi.h>
#include <WiFiUdp.h>

char ssid[] = "******";
char pass[] = "*****";
IPAddress local_ip(192, 168, 1, 15);
IPAddress gateway(192, 168, 1, 1);
IPAddress subnet(255, 255, 255, 0);

#define E131_BUFFER_SIZE 638

unsigned int localPort = 5568;

unsigned char E131Buffer[E131_BUFFER_SIZE];

WiFiUDP udp;



void setup()
{
  Serial.begin(250000);
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, pass); //Connect to Network
  WiFi.config(local_ip, gateway, subnet);
  while (WiFi.status() != WL_CONNECTED)
  {
    delay(500);
  }
  udp.begin(localPort);

}

void loop()
{
  int packetSize = udp.parsePacket();
 
  if (packetSize)
  {
    Serial.println(packetSize);
    udp.read(E131Buffer, E131_BUFFER_SIZE);
    udp.flush();
    Serial.println(E131Buffer[114]); //Byte 114 in the packet is the universe number
  }
}

Re: Reading UDP Packets

PostPosted: Wed Jul 13, 2016 6:22 pm
by Barnabybear
Hi, have a look at this: https://github.com/forkineye/ESPixelStick EDIT: you've proberbly seen it as I've just seen some of your posts on DIYC.
What timing are you using?
And why output them to an adruino does the esp not support yor pixel type?
Serial will be slowing things down if your running 3+ universes at 100ms or less.

Re: Reading UDP Packets

PostPosted: Thu Jul 14, 2016 12:56 am
by rudy
Have you tried increasing the clock frequency?

Re: Reading UDP Packets

PostPosted: Thu Jul 14, 2016 5:00 pm
by DJRed2000
I have looked at the ESPixelStick but I am not trying to drive the pixels directly from the ESP8266. It looks like that library supports up to 4 universes. I would like to use a Due because of the large amount of pixels it can support. I do have the CPU frequency set to 160 MHz. My goal is to just pass the date to the Due and let it do all the work. The data is being sent from Vixen 3.