Hi there, mdexdev01
So the maximum size of a single data packet for BLE 4.0 is 23 bytes. This includes 20 bytes of data and a 3-byte protocol wrapper. The maximum allowed length of an attribute value (the ATT payload) is 512 bytes. that being said,
The default MTU size for ArduinoBLE is 32 bytes, but it can be negotiated up to 256 bytes after the connection has been made. The MTU size is usually set during connection establishment with the “MTU Request” command.
Afaik the maximum number of bytes that can be sent in one packet using BLE on the Arduino Nano 33 BLE Sense board is usually 20, unless you enable the extension on both ends.
HTH
GL PJ
here is some of my code snips for a project sending the string over BLE
BLEService systemStatusService("19B1000C-E8F2-537E-4F6C-D104768A1214"); // UUID for the service
BLEStringCharacteristic systemStatusCharacteristic("19B1000B-E8F2-537E-4F6C-D104768A1214", BLERead | BLEWrite, 200 ); // UUID for the characteristic
if (central) {
// Send the system status string to the central when the characteristic is read
if (systemStatusCharacteristic.written()) {
systemStatusCharacteristic.writeValue(statusString);
}
String createStatusString() { // Function to create the status string
String statusString = __DATE__ " at " __TIME__ "," + BleId; //("Test program compiled on " __DATE__ " at "__TIME__);
if (imuParked) {
statusString += "Parked,";
} else {
statusString += "Not parked,";
}
if (droppedFlag) {
statusString += "DROPPED,";
} else {
statusString += "Not dropped,";
}
if (motionAlarm) {
statusString += "Motion alarm ON,";
} else {
statusString += "Motion alarm OFF,";
}
if (freeFallalarm) { //enableFallDetection on or off
statusString += "Drop alarm ON,";
} else {
statusString += "Drop alarm OFF,";
}
if (tapToOpen) {
statusString += "Tap to open ON,(" + tapsNumber + ")TAPS," ;
} else {
statusString += "Tap to open OFF,";
}
statusString += "Battery level 92%," + imuOrientation + "," + imutemperature + ";"; //+ ","; // batteryLevel
return statusString;
}
Here’s what the Serial OUTput looks like, The Android MIT AI app displays the string sent on the Phone.
System status:
Apr 17 2023 at 17:38:18,Not parked,Not dropped,Motion alarm ON,Drop alarm OFF,Tap to open ON,(2)TAPS,Battery level 92%,SIDEWAYS LEFT,86.96°;
Advertising Bluetooth Device
as: ABodyGuard F02B