Hey all -
I'm running into an unknown (to me) issue trying to convert the logic from the Adafruit BNO055 orientation sensor to OSC (Open Sound Control)
Currently - no data is passed from the BNO055 to OSC. If I create a BNO055 to Serial sketch, it works fine. Separately, if I create an OSC sketch that sends arbitrary OSC values, that works fine as well. But for some reason when I combine the two, I get nothing.
My guess is that the data coming in from the BNO055 is in the wrong format and possibly at too fast a rate?
Thoughts appreciated. Thanks!
////////////////////////////////////////
/*
Adafruit BNO055 to OSC
2015-09-20
*/
#include <Ethernet.h>
#include <EthernetUdp.h>
#include <SPI.h>
#include <OSCBundle.h>
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BNO055.h>
#include <utility/imumaths.h>
EthernetUDP Udp;
Adafruit_BNO055 bno = Adafruit_BNO055(55);
// Board IP
IPAddress ip(2, 0, 0, 100);
// Board MAC
byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
// Destination IP
IPAddress outIp(2, 0, 0, 101);
// OSC Port
const unsigned int outPort = 8000;
void setup() {
Ethernet.begin(mac,ip);
Udp.begin(outPort);
}
void loop(){
sensors_event_t event;
bno.getEvent(&event);
OSCBundle bndl;
bndl.add("/axis/X").add((float)event.orientation.x);
bndl.add("/axis/Y").add((float)event.orientation.y);
bndl.add("/axis/Z").add((float)event.orientation.z);
Udp.beginPacket(outIp, outPort);
bndl.send(Udp); // send the bytes to the SLIP stream
Udp.endPacket(); // mark the end of the OSC Packet
bndl.empty(); // empty the bundle to free room for a new one
delay(1000);
}