Skip to content

Memfault

Published On:
Jul 1, 2024
Last Updated:
Sep 24, 2024

Memfault is a commercial cloud-based service designed for managing and analysing faults/data from a fleet of internet-connected embedded devices. It also allows you to manage and deploy OTA (over-the-air) updates to your devices.

The Memfault logo1.

Dashboard

Memfault has a web-based dashboard for viewing data from your devices and managing things like OTA updates.

A screenshot of the Memfault dashboard on their demo account2.

Heartbeats

Heartbeats are one of the common ways of sending data from your embedded device to Memfault. Not only do they indicate to Memfault that your device is still alive, but heartbeats can also contain user-defined metrics that you can use to monitor things like battery life, temperature, and more.

As of June 2024, all Memfault pricing plans allow up to 24 heartbeats per day3.

Heartbeats can be triggered manually with memfault_metrics_heartbeat_debug_trigger().

Metrics

Metrics are parameters you can track on your embedded device. The data is cached locally and sent to Memfault on the next heartbeat.

Metrics are defined with MEMFAULT_METRICS_KEY_DEFINE() macro in your memfault_metrics_heartbeat_config.def file4.

The macro takes two parameters, the name of the metric and it’s type. For example:

MEMFAULT_METRICS_KEY_DEFINE(my_metric, kMemfaultMetricType_Unsigned);

Then, in your code, you can set/update the metric with MEMFAULT_METRIC_SET_xxx() or MEMFAULT_METRIC_ADD() marcos:

#include "memfault/metrics/metrics.h"
void main() {
// ...
MEMFAULT_METRIC_SET_UNSIGNED(my_metric, 1234); // Directly set the metric to 1234
MEMFAULT_METRIC_ADD(my_metric, 1); // Increment the metric by 1
// ...
}

The following metric types are supported4:

  • kMemfaultMetricType_Signed
  • kMemfaultMetricType_Unsigned
  • kMemfaultMetricType_Timer
  • kMemfaultMetricType_String

You can either manually define metrics via the Memfault web dashboard or by uploading the built .elf file. You need to make sure you define your metrics, otherwise you won’t see them come through, as Memfault will ignore any unrecognized metrics that are posted to it’s API.

Memfault imposes quotas on the amount of different metrics you can have per project.

More about metrics can be read in the Memfault Docs here.

Traces

Memfault gives you the ability to send traces from your embedded device. A trace is designed to be sent when a significant issue occurs. By defaults, traces send you emails.

nRF Memfault Phone App

The nRF Memfault app by Nordic Semiconductor is a phone app (available for Android and iOS) which allows you to connect to devices running Memfault and publishing on the Memfault Diagnostic Service (MDS). The MDS is a Bluetooth GATT service. The app connects to these devices and streams the “chunks” from the device to the Memfault cloud.

The nRF Memfault app displays the application key (project key) and device ID.

A screenshot of the nRF Memfault app with a device connected to it. You can see the chunks of data which have been downloaded of the device and uploaded to Memfault.

Memfault CLI

Memfault CLI is a Python tool for interacting with the Memfault Cloud API via the command line. It is useful for automating tasks (as an alternative to using the manual web GUI) such as uploading firmware, symbol files, and more from your CI/CD pipeline.

Installation

The Memfault CLI is on PyPI can be installed using pip with the command:

Terminal window
pip3 install memfault-cli

It is recommended to install the CLI in a virtual environment to avoid conflicts with other Python packages.

Footnotes

  1. Memfault. Memfault Docs. Retrieved 2024-07-03, from https://docs.memfault.com/.

  2. Memfault. Demo Dashboard. Retrieved 2024-07-03, from https://demo.memfault.com/organizations/acme-inc/projects/shapemate/dashboards/memfault-overview.

  3. Memfault. Pricing Plan. Retrieved 2024-07-04, from https://memfault.com/pricing/#mcu.

  4. Memfault. MCU Metrics [documentation]. Retrieved 2024-07-04, from https://docs.memfault.com/docs/mcu/metrics-api. 2