Send accel data from M5Stack Core 2 to TouchDesigner via OSC
-
Hi, I'm a complete beginner with programming, and as well as, using M5Stack Core 2 and TouchDesiger.
Does anyone know how to send accel data from M5Stack Core 2 to TouchDesigner via OSC?Below is the code that I copied from several sources.
I could connect to the WiFi, but no response from TouchDesigner.
I am not sure what's missing..
Can someone teach me?#include <M5Core2.h> #include <WiFi.h> #include <WiFiUdp.h> #include <OSCBundle.h> const char *ssid = "***"; const char *password = "***"; const char *udpAddress ="***"; const int udpPort = 10000; WiFiUDP udp; float accX = 0.0F; float accY = 0.0F; float accZ = 0.0F; float gyroX = 0.0F; float gyroY = 0.0F; float gyroZ = 0.0F; float pitch = 0.0F; float roll = 0.0F; float yaw = 0.0F; float temp = 0.0F; uint32_t Now = 0; uint32_t lastUpdate = 0; float deltat = 0.0f; void setup(){ M5.begin(); M5.IMU.Init(); delay(2000); Serial.println("*** setup *** aaa ***"); delay(1000); WiFi.begin(ssid, password); while(WiFi.status() != WL_CONNECTED){ delay(500); M5.Lcd.print("."); } M5.Lcd.println("WiFi Connected"); M5.Lcd.print("IP address= "); M5.Lcd.println(WiFi.localIP()); } void loop(){ M5.update(); if(WiFi.status() == WL_CONNECTED){ OSCBundle bndl; udp.beginPacket(udpAddress, udpPort); bndl.send(udp); udp.endPacket(); bndl.empty(); } delay(10); M5.IMU.getAccelData(&accX,&accY, &accZ); M5.IMU.getTempData(&temp); deltat = ((Now - lastUpdate)/1000000.0f); lastUpdate = Now; MahonyAHRSupdateIMU(gyroX, gyroY, gyroZ, accX, accY, accZ, &pitch, &roll, &yaw); }
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login