Can someone tell me please where I can obtain the numbers in order to connect the M5Stick and the Computer to receive the info?
//libraries:
// https://github.com/m5stack/M5StickC //tested version 0.2.3
// https://github.com/hideakitai/ArduinoOSC
// select Board: M5StickC
// for M5StickC-Plus then the library should be this:
// https://github.com/m5stack/M5StickC-Plus
#include <Arduino.h>
#include <Wire.h>
//#include <M5StickC.h> //for M5StickC
#include "M5StickCPlus.h" //for M5StickC-Plus
//#include <WiFi.h>
//#include <ArduinoOSC.h>
#include <ArduinoOSCWiFi.h>
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;
int whichUnit = 0;
#define PRINT_SPEED 50 // 250 ms between prints
static unsigned long lastPrint = 0; // Keep track of print time
// WiFi stuff
const char* ssid = "Faboweb"; //the wi-fi name
const char* pwd = "12031986"; //the wi-fi password
const IPAddress ip(192, 168, 1, 205); // la direccion de ip de la m5
const IPAddress gateway(192, 168, 0, 1);
const IPAddress subnet(255, 255, 255, 0);
// for ArduinoOSC
//const char* host = "192.168.1.102"; //computer to send data to
const char* host = "192.168.0.203"; //computer to send data to
const int recv_port = 54321;
const int bind_port = 54345;
const int send_port = 55555; // <-------- this is the sending port of thew stick
const int publish_port = 54445;
int lastUpdate = 0; //timer period for IMU update
void setup() {
// put your setup code here, to run once:
// Initialize Serial port
Serial.begin(115200);
#ifdef ESP_PLATFORM
WiFi.disconnect(true, true); // disable wifi, erase ap info
delay(1000);
WiFi.mode(WIFI_STA);
#endif
WiFi.begin(ssid, pwd);
WiFi.config(ip, gateway, subnet);
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(500);
}
Serial.print("WiFi connected, IP = ");
Serial.println(WiFi.localIP());
M5.begin();
M5.IMU.Init();
M5.Lcd.setRotation(3);
M5.Lcd.fillScreen(BLACK);
M5.Lcd.setTextSize(1);
M5.Lcd.setCursor(45, 0);
M5.Lcd.print("IMU UNIT ");
M5.Lcd.print(whichUnit+1);
M5.Lcd.setCursor(40, 20);
M5.Lcd.println("mac Address");
M5.Lcd.setCursor(0, 50);
M5.Lcd.println(" Pitch Roll Yaw");
//Serial.println(WiFi.macAddress());
Serial.print("IP address is: ");
Serial.println(ip);
M5.Lcd.setCursor(30, 30);
//M5.Lcd.print(WiFi.macAddress());
M5.Lcd.print(ip);
}
void loop() {
// put your main code here, to run repeatedly:
if(millis()-lastUpdate > 25)
{
M5.IMU.getGyroData(&gyroX,&gyroY,&gyroZ);
M5.IMU.getAccelData(&accX,&accY,&accZ);
M5.IMU.getAhrsData(&pitch,&roll,&yaw);
M5.IMU.getTempData(&temp);
lastUpdate = millis();
}
if ((lastPrint + PRINT_SPEED) < millis())
{
M5.Lcd.setCursor(0, 60);
M5.Lcd.printf(" %5.2f %5.2f %5.2f ", pitch, roll, yaw);
//example from https://forum.arduino.cc/index.php?topic=551310.0
OscWiFi.send(host, send_port, "/imu", pitch, roll, yaw);
OscWiFi.send(host, send_port, "/raw", accX, accY, accZ, gyroX, gyroY, gyroZ);
lastPrint = millis(); // Update lastPrint time
}
OscWiFi.post(); // to publish osc
M5.update();
//delay(2);
}