Send OSC messages through W5100 ethernet shield

Hi There!

A little help might be useful. I’m trying to run a simple arduino sketch that sends an OSC message (so I can read it on Processing) over UDP. I’m using Arduino UNO and W5100 Ethernet shield.

As you can see at the end of the code I’m printing something just to know when it has sent a message but the code does never reach the print instruction. IP addresses and port are correct and DHCP works just fine. The problem seems to be when I try to beginPacket, send the OSC message and endPacket.

Here goes the source code (most interesting part is at the end):

#include <OSCMessage.h>

Make an OSC message and send it over UDP
#include <Ethernet.h>
#include <EthernetUdp.h>
#include <SPI.h>    
#include <OSCMessage.h>
#include <stdlib.h>
EthernetUDP Udp;

//the Arduino's IP
IPAddress ip(192, 168, 0, 121);
//destination IP
IPAddress outIp(192, 168, 0, 124);
const unsigned int outPort = 9999;

byte mac[] = {  
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; // you can find this written on the board of some Arduino Ethernets or shields
void setup() {
  // Open serial communications and wait for port to open:
  // this check is only needed on the Leonardo:
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only

  // start the Ethernet connection:
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // no point in carrying on, so do nothing forevermore:
  // print your local IP address:
  Serial.print("My IP address: ");
  for (byte thisByte = 0; thisByte < 4; thisByte++) {
    // print the value of each byte of the IP address:
    Serial.print(Ethernet.localIP()[thisByte], DEC);

void loop(){
//the message wants an OSC address as first argument
  OSCMessage msg("/analog/0");

//PROBLEM SEEMS TO OCCUR HERE. When I comment the following 3 lines, it runs.
  Udp.beginPacket(outIp, outPort);
  msg.send(Udp); // send the bytes to the SLIP stream
  Udp.endPacket(); // mark the end of the OSC Packet

  msg.empty(); // free space occupied by message
  Serial.print("\nosc message sent");


This is what is printed on serial monitor

My IP address:

By the way, no errors printed. Network running file, I can exchange messages between Pure Data and Processing using the same IPs and ports. Any hints on how to send a simple osc message from arduino?


I don't see a UDP.begin(localPort) call in setup. That will cause a fail.

We fixed that bug a while ago, please take a fresh look at this: