In the following tutorial we will discuss how to use the Memfault SDK data export API to collect "chunks" from a device and then post them to the Memfault cloud for analysis.
Add call to
The data export module uses the SDK data packetizer APIs to read the data which has been collected. It then base64 encode it and dump the result to a destination of your choosing.
First you will need to find a location in your project to trigger the export such as a code path that runs periodically or on-demand via a user triggered action such as a CLI command.
Optional: Override where data is exported to
By default, the data_export module will dump results to the console using the
memfault_platform_log implementation that was added as part of the
However, the location can be overriden so data can be published elsewhere (i.e directly to a file):
A Project key will be needed in order to communicate with Memfault's web services. Go to https://app.memfault.com/, navigate to the project you want to use and select 'Settings'→'General'. The 'Project Key' listed is what you will want to use.
To install it, make sure you have a recent version of Python 3.x installed and run:
Start your console with your favorite terminal client. Let the system run for a
bit, periodically dumping data to the console by calling
You should see strings with the format:
MC:BASE64_ENCODED_CHUNK: in the dump.
It's perfectly fine for other logs to be interleaved with the exported data.
Save the resulting logs to a file such as logs.txt
Run the desktop Memfault CLI tool on your saved log file. The utility will parse the logs, extract the Memfault data, and post it here for processing!