mhamilt / max-hardware-library

Library of utility objects for MaxMSP aimed at interacting with electronics hardware like Arduino
GNU General Public License v3.0
17 stars 0 forks source link

How to get the serial print messages to appear on Max/MSP console ? #5

Open andiolai opened 1 month ago

andiolai commented 1 month ago

Hello, Thank you for making this available. I would like to explore the possibilities to send sensor data to max wirelesslyI am familiar with wired serial communication between Arduino and Max/MSP.

I tried and used some BLE board following the example to upload Ardiuno ble-notify file without any modification , the device can connect and shown up but that was all I can get in Max and the console. For this example, I am not sure how to progress to get the on/off message notification to appear in Max (&Console) and further use the data. Would appreciate some guidance and explanation,Thanks!

image

p.s.I looked to the architecture of BLE and understand the ideas of services & characteristics but probably not familiar with the coding side of them enough...

mhamilt commented 1 month ago

Hello @andiolai,

The ble-notify.ino sketch should just send out data on every connect message.

I think I set it up to allow for subscribing as well. The BLENotify on this line should mean you can send a message like

subscribe <device_UUID> 19B10000-E8F2-537E-4F6C-D104768A1214 19B10000-E8F2-537E-4F6C-D104768A1214

And on every update of the ledState a message will be sent out the Notification outlet (outlet 2).

The print you show gives Value: (null) which suggests the data couldn't be read which is odd.

Let me know how you get on with subscribing and we'll take it from there.

andiolai commented 1 month ago

@mhamilt Thanks for your help and explanation.

I tried with some other example of peripherals on the Arduino BLE library (using Analog pin 0 value) using the subscribe message above from you, finally can get the messages strings to Max and after filtering out the uuid by patching, I can get the value messages to my patch .

I will try the BLEnotify later again. Will also start trying with sensors or some potentiometer further. Thanks again.

mhamilt commented 1 month ago

@andiolai, If you could, please share any Max patches and Arduino sketches in this issue and which boards you were using. That way can alter the documentation and help files to be bit more friendly.

andiolai commented 1 month ago

Thanks @mhamilt :

Here it is, I am using an Aruduino BLE nano 33 sense with the Arduino BLE library template example code of Peripheral here to test the subscribe sending data: https://www.arduino.cc/reference/en/libraries/arduinoble/ https://github.com/arduino-libraries/ArduinoBLE/blob/master/examples/Peripheral/BatteryMonitor/BatteryMonitor.ino

The following Max patch is based on yours answer and modified on the example of your library.


----------begin_max5_patcher----------
1068.3oc0Y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