Creat and send a file over BLE

Hi,

I use NCS 2.4.2 and i want to save data sensor with a hight frequency in a nrf5340 device and send it over BLE to a nrf52840 dongle device. The nrf5340 is the peripheral.
The sensor data are at a ver hight frequency (more than 400Hz), that's why i need to save it in a file and send it by block.

I need help to find the right solution to perform this. I saw Throughput Service, Objet transfer service, NUS but i can't figure out what is the best solution.

I use coded phy also.

Regards,

Pierre-Yves

Parents
  • Hi Pierre-Yves,

    To efficiently send the data, I'd suggest keeping it in a RAM buffer until it is sent. I'm not sure how many bytes each measurement is, but the more you can fit into each notification packet, the better.

    I use coded phy also.

    This will greatly reduce the theoretical throughput of the connection. If possible, it would be better to increase the TX power using an external PA/LNA such as the nRF21540 and stay on 1M.

    Best regards,

    Vidar

  • Do you have example of this ? and what services do i need to use ?

    each mesurement is composed of 3 float for the 3 axes and i also need to have the time in milisecond hour per hour, it's a long uint i think. Then one mesurement should be around 20 bytes each 1ms or each 2ms .


    I use already a nrf21540 and i need to use phy coded because  i need long rang connexion

    I tried to use throughput but with the sample central and peripheral when i config in coded_s8 it's really too slow instead of when i use ble nus

    Regards,

    Pierre-Yves

  • I don't see any reason for storing the data to flash if the goal is to immediately relay the data to the connected client. This would make more sense if you want to store sensor data while the device is "offline".

    => it's because i can sometimes lose connexion beetween my devices, my peripheral is in motion
    And i could use this file as a black box also, do you know how to do this ?

    i succed to use ots object with both sample in coded and i succed to read the object from the peripheral, but the data that i read i want to save them directly with my device in my pc, do you know if it's possible and how to do it ?

  • => it's because i can sometimes lose connexion beetween my devices, my peripheral is in motion
    And i could use this file as a black box also, do you know how to do this ?

    it's possible to back up sensor measurements to the external flash and attempt to send them to the client as soon as the connection is re-established. You can use the flash API to store the raw sensor values for this as suggested earlier. However, there are some considerations that need to be made. For example, let's say for a given connection, you only have the bandwidth to send data currently being sampled. In such cases, how would you handle the backup? 

    i succed to use ots object with both sample in coded and i succed to read the object from the peripheral, but the data that i read i want to save them directly with my device in my pc, do you know if it's possible and how to do it ?

    It depends on how you're receiving the data on your PC. If it's being written to the console, you could simply redirect this data to a new file.

    https://askubuntu.com/questions/420981/how-do-i-save-terminal-output-to-a-file 

  • Hi,
    Sry i was not able to test before, that's why i don't answer before.
    I succed to use ots service and use multiple object to send data in large packets.

    I don't know haw to handle the backups, do have any idea ?

    I have a dongle ble that is used as a central device. I use the bluetooth shell sample on it. The device is plug on a rasberry. I create a software that connect to my dongle nrf52840 that extract all output from my dongle. on the other hand my peripheral send many datas. I print them on my dongle with some commands and it ake the output and put it in a file. I have rally too many data, that's why i asked if it was possible to have a thread that take only the data from the acc and put it directely on a file in my pc ?
    Because i don't want to print them if possible

  • Hi,

    The simplest solution is likely just to parse the accelerometer data from your log output and then store that data in a file or a database. You didn't mention which programming language you used to create your program on the Pi.

  • i use C to programme it.
    Indeed the easiest is to parse the accelerometer data from my log, but i is it possible to do it in another way ?
    Because i have really many data in my log that i parse and if possible i want to find another way.

Reply Children
Related