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.

  • Ok. How then can I implement this feature such that data is not lost when a remote device is not in range. The idea here is that I have a peripheral that transmits ECG data 100 times per second to an android device. When the connected android device goes out of range, the connection is lost and then the peripheral, which is nrf51822 should start saving the data to flash while at the same time waiting for the android device to reconnect. Is it possible for the android device, which already has the address of the peripheral from the former connection, to reconnect without the peripheral advertising? If not, how do I implement this feature? Thanks.

  • 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.

Related