How to change the MTU of a nRF52 Bluefruit LE in Arduino
![Oscar de la Hera Gomez](https://www.delasign.com/CDN/headshots/profile.webp)
![Two flowers that represent Arduino and Bluetooth side by side with the text "Set Bluefruit MTU" beneath them.](https://www.delasign.com/CDN/images/How-to-change-the-MTU-of-a-Bluefruit-in-Arduino.webp)
To change the Maximum Transmission Unit (MTU), use the Bluefruit's library configPrphBandwidth or configCentralBandwidth function along with a Bandwidth Enum.
A nRF52 Bluefruit LE's MTU is set to 20 bytes by default, but can be expanded to a maximum of 247 bytes by calling the configPrphBandwidth and configCentralBandwidth function with a Bandwidth enum before calling the Bluefruit.begin() function.
The available bandwidth enums are:
- BANDWIDTH_AUTO
- BANDWIDTH_LOW
- BANDWIDTH_NORMAL
- BANDWIDTH_HIGH
- BANDWIDTH_MAX
Consult the link below to see the these enums affect the Bluefruit's MTU.
Examples
To configure the nRF52 Bluefruit LE to act as a peripheral with a maximum of 247 bytes, call the function below before Bluefruit.begin().
Bluefruit.configPrphBandwidth(BANDWIDTH_MAX);
To configure the nRF52 Bluefruit LE to act as a central manager with a maximum of 128 bytes, call the function below before Bluefruit.begin().
Bluefruit.configCentralBandwidth(BANDWIDTH_HIGH);