M5Stack and MAX/MSP via WiFi, UDP

Yurike Chandra's icon

Hi,

I want to send some data from MAX to M5Stack via WiFi and UDP.
I tried following some articles, but my M5Stack still can't receive any data.

This is the M5Stack code:

----------------------------------------
----------------------------------------

#include <M5Stack.h>
#include <WiFi.h>
#include <WiFiUdp.h>

const char* ssid = "wifi name";
const char* password = "wifi password";
const char* host = "ip address";

const unsigned int inPort = 80;

WiFiClient client;
WiFiUDP Udp;

void setup() {
// put your setup code here, to run once:
Serial.begin(115200);

M5.begin();
M5.Speaker.setVolume(1);
WiFi.disconnect();
delay(1000);
M5.Lcd.println("START");
WiFi.begin(ssid, password );
while ((!WiFi.status()== WL_CONNECTED)){
delay(300);
M5.Lcd.println("...");
}
M5.Lcd.println("connected");
Udp.begin(inPort);
}

void loop(){
int packetSize = Udp.parsePacket();
if(packetSize > 0){
M5.Lcd.println("received data");
}
}

----------------------------------------
----------------------------------------

And this is the maxpatch:

I wonder if it's because the port is incorrect, how can I find the right port...
Or is it the IP address that is wrong?
Do both MAX/MSP and M5stack have to connect to the same wifi?

Please advise if there's anything wrong with the code/patch.

Thank you in advance.

Best regards!

Source Audio's icon

Where did You get that M5Stack code ?
Do You know how to set wifi and wifiudp ?
And meanning of IP address, client mode, etc etc?

As first You need to replace
const char* ssid = "wifi name";
const char* password = "wifi password";
const char* host = "ip address";

with real infos.
That above is just example, and You need to fill in proper values.
setting host Ip address means that You have a static IP address
, is that so ?
Read somewhere about :
WiFiClient client;
and what does it mean.
Otherwise leave it out.
And use some other udp port like 6666, or whatever.
From Max You can broadcast messages
using udpsend 255.255.255.255 6666
6666 being the port number

and yes both computer and that device must be on the same network
in order to communicate.

Yurike Chandra's icon

Hi,

Yes, I've changed the wifi name, wifi password, and ip address.
Ok. I'll try with changing the port and connecting them to the same wifi..

Thanks for your help!