Formatting OSC messages with Float Values

Hi guys I'm finally getting somewhere with my Arduino OSC project, Basically I'm trying to make a handset which when buttons are pressed OSC commands are sent so that I don't need to use TouchOSC and I have something more tactile.

I've made a little test sketch and Currently I can connect to the Wifi and broadcast OSC messages.

Using an OSC monitor I can seeing the messages on my laptop however I need to send a float value which isn't working, can someone help me with this?

The correct formatting using the TouchOSC remote is:

"/Hardware/Enter/4 1.000 (float)"
"/Hardware/Enter/4 0.000 (float)"

When sent from the Arduino The OSC monitor is seeing no float value:

"/Hardware/Enter/4"
"/Hardware/Enter/4"

I tried to add float data (Commented out below) and the OSC Monitor saw this:

"/Hardware/Enter/4 (typed)"
"/Hardware/Enter/4 (typed)"

I'm using the esp OSC Librabry from GitHub - sandeepmistry/esp8266-OSC: OSC: Arduino and Teensy implementation of OSC encoding esp8266-OSC Library and I've read here about sending the message including the float value but I'm probably missing something. http://cnmat.berkeley.edu/library/oscuino/omessage

Here is my Void Loop:

void loop(){
 //Press Enter Key 3
 OSCMessage msgOUT("/Hardware/Enter/4");
 //msgOUT.add(1.000); // Float Data
 //msgOUT.getFloat(0);
 Udp.beginPacket(Udp.remoteIP(), destPort);
 msgOUT.send(Udp); // send the bytes
 Udp.endPacket(); // mark the end of the OSC Packet
 msgOUT.empty(); // free space occupied by message
 Serial.println("Press Enter 4");
delay(50);  

 //Release Enter Key 3
 OSCMessage msgOUTr("/Hardware/Enter/4");
 //msgOUTr.add(0.000); // Float Data
 //msgOUTr.getFloat(0);
 Udp.beginPacket(Udp.remoteIP(), destPort);
 msgOUTr.send(Udp); // send the bytes
 Udp.endPacket(); // mark the end of the OSC Packet
 msgOUTr.empty(); // free space occupied by message
 Serial.println("Release Enter 4");
delay(5000);
}

Any Help would be much appreciated!

Thanks

Tim

When sent from the Arduino The OSC monitor is seeing:

Because the code for making the value part of the package is commented out.

 OSCMessage msgOUT("/Hardware/Enter/4");
 //msgOUT.add(1.000); // Float Data
 //msgOUT.getFloat(0);
 Udp.beginPacket(Udp.remoteIP(), destPort);
 msgOUT.send(Udp); // send the bytes

The whole order of operations looks strange. You create a OSCMessage object and a Udp packet. You send the packet before marking that the end of the packet has been defined. That looks strange to me.

Thankyou for your fast response, I added those lines to an example but when I uncomment them the OSC monitor sees this:

"/Hardware/Enter/4 (typed)"
"/Hardware/Enter/4 (typed)"

//Release Enter Key 3
 OSCMessage msgOUTr("/Hardware/Enter/4");
 msgOUTr.add(0.000); // Float Data
 msgOUTr.getFloat(0);
 Udp.beginPacket(Udp.remoteIP(), destPort);
 msgOUTr.send(Udp); // send the bytes
 Udp.endPacket(); // mark the end of the OSC Packet
 msgOUTr.empty(); // free space occupied by message
 Serial.println("Release Enter 4");

I admit I know nothing about an OSCMessage object, but this:

 //msgOUTr.add(0.000); // Float Data

looks strange since you are trying to add it to what, to me at least, looks like a string. What happens if you change it to:

msgOUTr.add("0.000"); // Float Data

Ou.. Thats better, thankyou.

Still not quite correct as its seen as a string.

I'm now getting:

"/Hardware/Enter/4 1.000 (string)"
"/Hardware/Enter/4 0.000 (string)"

Sussed it!

Thankyou for pointing me in the right direction.

//Release Enter Key 3
 OSCMessage msgOUTr("/Hardware/Enter/4");
 float Press = 1.000;
 msgOUT1.add(Press); // Float Data
 Udp.beginPacket(Udp.remoteIP(), destPort);
 msgOUTr.send(Udp); // send the bytes
 Udp.endPacket(); // mark the end of the OSC Packet
 msgOUTr.empty(); // free space occupied by message
 Serial.println("Release Enter 4");