Issues Receiving OSC Messages via OSC In DAT

Hi all,

I’m trying to connect an ESP32 to TouchDesigner via Ethernet, and I’ve gotten as far as being able to ping the ethernet, meaning that I can communicate with the ESP32. However, the message packets are just not being received in my OSC In Dat, and I don’t know what the issue is.

I attached my code and OSC In DAT below, though I scrubbed the IPs of my laptop, but I placed those in const IPAddress outIp() and in the Local Address parameter.

Here is my Arduino code below (sorry about the awful formatting, the code formatting feature keeps crashing my page):

#include <Ethernet.h>

#include <OSCMessage.h>

#include <SPI.h>




#define ETH_SPI_SCS 5   // CS (Chip Select), Green




// Define MAC and IP

byte mac[] = { 0x94, 0xB9, 0x7E, 0x6B, 0x10, 0x14 };

IPAddress ip(169, 254, 116, 118);




EthernetUDP Udp;                                // A UDP instance to let us send and receive packets over UDP

const IPAddress outIp(*);        // remote IP of your computer

const unsigned int outPort = 9999;          // remote port to receive OSC

const unsigned int localPort = 8888;        // local port to listen for OSC packets (actually not used for sending)





void setup() {

  Serial.begin(9600);

  delay(1000);

  Serial.println("Starting Ethernet connection...");




  SPI.begin(18, 19, 23);  // SCK, MISO, MOSI




  //Set the CS pin, required for ESP32 as the arduino default is different

  Ethernet.init(ETH_SPI_SCS); 




  //Start the Ethernet connection

  Ethernet.begin(mac, ip);




    //Hardware check

  Serial.println("Checking Ethernet hardware...");

  if (Ethernet.hardwareStatus() == EthernetNoHardware) {

    Serial.println("ERROR: No Ethernet hardware detected!");

    return;

  }

  else {

    Serial.println("Ethernet hardware detected!");

  }




  //Check if cable is connected

  if (Ethernet.linkStatus() == LinkOFF) {

    Serial.println("Link is OFF. Check cable connection.");

  }

  else {

    Serial.println("Link is ON. Cable is connected. Ready to go!");

    Serial.print("To test connection, please ping: ");

    Serial.println(ip);

  }




  Udp.begin(localPort);

  #ifdef ESP32

    Serial.println(localPort);

  #else

      Serial.println(Udp.localPort());

  #endif

}

 

void loop() {

  OSCMessage msg("/test");

  msg.add("hello, osc.");




  Serial.print("Sending OSC to ");

  Serial.print(outIp);

  Serial.print(":");

  Serial.println(outPort);




  Udp.beginPacket(outIp, outPort);

  msg.send(Udp);

  Udp.endPacket();

  msg.empty();




  delay(500);

}

And here is a screenshot of my parameters for the OSC In DAT:

Hi, I’ve been doing some of what you’re working on, only with multicast OSC, but more or less the same thing.

here’s the function that I’m using. You can probably do Udp.beginPacket(outIp, outPort); instead of the Udp.beginMulticastPacket();

void sendMulticastMessage(const char *message, uint16_t value) {
OSCMessage msg(message);
msg.add(value);
Udp.beginMulticastPacket();
msg.send(Udp);
Udp.endPacket();
msg.empty();
}

There are a couple things ESP-wise that you may want to try:

(1) show a random number between 0.0 and 1.0 each cycle
msg.add(random(1000) / 1000.0);

this will give you a random number between 0-1.0 for each iteration, and then you can do a select chop/trail to see the numbers graphed in TD.

(2) use a non-blocking time in the esp32 code

delay(500) will block up the processes, so the udp messages could be not being properly serviced.

using millis() and checking the timer would be a better solution.

I’ve encapsulated this in a simple MSTimer C++ object with this GitHub repo

(3) you can also check a separate app like Protokol (Mac) which can show you active OSC messages from your wifi, so you can see if the ESP32 is actually sending data as it should. Sometimes there are some issues on certain home wifi networks b/c of router issues, and a separate app that does OSC sniffing might help you track this down.

I have my own wifi router I use just for this sort of thing.

Also, here is my oscin chop which could be useful. I’m not great with TD but know my ESP32 stuff very well, so that’s where I’d start

Hi,

Thanks for the suggestions! I downloaded Protokol, and it seems that my ESP32 isn’t sending OSC messages at all through Ethernet. I don’t really know where to go from here though; if it is an Ethernet issue, should I try a different cable?

I’m fairly certain that all my hardware stuff concerning ESP32 and W5500 wiring is correct, and the code is pretty similar to most ESP32 OSC codes.