The XIAO nRF52840 has 2MB of flash ROM on board.
In my project, the battery-powered peripheral XIAO stores data collected over a long period of time in the on-board flash ROM. The data will then be uploaded to the central XIAO’s SD card on a regular basis.
I experimented to see if I could upload the data in a short time with as little load on the battery as possible.
I used Bluefruit for the BLE library, but with the default settings, it took over 10 minutes to upload 2MB of data, which was not practical.
So, I considered increasing throughput and reducing battery energy using the article and example sketch in the link below.
‘Maximizing BLE Throughput on iOS and Android - Punch Through’
\Arduino15\packages\Seeeduino\hardware\nrf52\1.1.1\libraries\Bluefruit52Lib\examples\Peripheral\throughput
The points are
- Run PHY at 2 MHz
- Minimize interval: 7.5mS
- Maximize payload: 244 bytes (MTU=243, Data Length=251)
- Use Notify mode
- Use high speed SD card and set SPI clock to maximum: 32MHz
- Implement enough FIFO to allow for the maximum write time to SD: 244*200 bytes
- Increase the number of transmissions as much as possible without going below the average write time to SD: 2.8mS
- Upload in close proximity and reduce transmit power: 0 dBm
nRF52_XIAO_onBoardFlash_upload.zip (88.4 KB)
The default setting was to send 20 bytes of data three times during 20 mS. I shortened the interval and increased the payload so that 244 bytes of data could be transmitted 2 to 3 times during 7.5 mS. I also set the transmit power to 0 dBm because the distance between the central and peripheral was very close during upload.
As a result, the transmission time, which used to take more than 10 minutes, was reduced to about 30 seconds, and the energy was also reduced to 1/10.
There are several issues to be addressed in the future. I would be glad if someone could give me some tips.
- there is a phenomenon that if something is not written to the SD card before connecting BLE, it cannot be written after connection.
nRF52_XIAO_onBoardFlashUpload_central.ino:110 - if I write the connection parameters only in the peripheral, it works as I expect. Why don’t I have to describe them in the central?
nRF52_XIAO_onBoardFlashUpload_peripheral.ino:239-251 - I’m able to achieve a throughput of about 50 kB/sec, is there any way to increase it? Can I use the ‘Connection Event Lengh Extension’?
The XIAO Expansion Board was used as central because it is equipped with an OLED display and an SD card drive.
The following libraries were used
BSP : Seeed nRF52 Borads 1.1.1, Board : Seeed nRF52 Borads / Seeed XIAO nRF52840 Sense
Adafruit SPIFlash by Adafruit 4.1.1
Adafruit GFX Library by Adafruit 1.11.4
AdafruitSSD1306 by Adafruit 2.5.7
RingBuf by D.Aaron Wisner 2.0.0
I hope this will be helpful to those interested.