This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Logging realtime sensor data to flash

I would like to know if it is possible to log realtime sensor data to flash while advertising. I would like to have a device which transmits real time ECG data over ble UART to an android device when in range and once out of range, should start logging the data to the nrf51822 flash. It should resume transferring the data to android device once it is in range again and connected. I would be glad if you could give me a clue as to how to realise this if it is possible.

Parents
  • Hi

    You should not do advertising and perform flash operation at the same time. This is ensured in i.e. the ble_app_hrs example in nRF51 SDK 6.1.0, see the advertising_start in main.c. Also in nRF51 SDK 8.0.0, see ble_advertising_start.

    So if you want to flash application data, then stop advertising, perform the flash operations and then restart advertising again.

  • Yes, you are correct, it is not possible to store data in flash 100 times per second and advertise at the same time. What you could do is to store the data in RAM instead, i.e. in a variable. If you have bonded with the central device (Android device) then the peripheral should have all information about the central device. Then you could periodically perform direct advertising (ADV_DIRECT_IND), which will take maximum 1.28 seconds. It will try to connect directly with a specific central. For those 1.28 seconds, you can store ECG data in RAM. If the device has not connected after 1.28 seconds, you can store the RAM data in flash in order to preserve RAM space before advertising again. You could also advertise normally (ADV_IND slower advertising interval) and include only the specific central address in a whitelist for the advertising.

Reply
  • Yes, you are correct, it is not possible to store data in flash 100 times per second and advertise at the same time. What you could do is to store the data in RAM instead, i.e. in a variable. If you have bonded with the central device (Android device) then the peripheral should have all information about the central device. Then you could periodically perform direct advertising (ADV_DIRECT_IND), which will take maximum 1.28 seconds. It will try to connect directly with a specific central. For those 1.28 seconds, you can store ECG data in RAM. If the device has not connected after 1.28 seconds, you can store the RAM data in flash in order to preserve RAM space before advertising again. You could also advertise normally (ADV_IND slower advertising interval) and include only the specific central address in a whitelist for the advertising.

Children
No Data
Related