This example app shows how you can build an Edge Impulse model into a small Pebble watch app and upload data from Pebble sensors directly to a project in Edge Impulse.

To build this app for Pebble watches, follow these steps:
-
Install the Pebble SDK
Follow the official Pebble SDK installation guide:
Pebble SDK Installation -
Clone the Repository
Clone this repository to your local machine:git clone https://github.com/your-repo/ei-test-pebble-app.git cd ei-test-pebble-app-
Install ARM Build Tools and Update Configuration
To set up the environment, install the latest ARM build tools (version 8) and ensure they are discoverable:
-
Download and Install ARM Build Tools
Download the ARM GCC toolchain version 8 from the official ARM website:
ARM GCC Legacy Toolchain Downloads
Extract the downloaded archive to a directory of your choice. -
Make the Toolchain Discoverable
You have two options:- Set the
GCC_ARM_PATHenvironment variable to the root of your toolchain install:export GCC_ARM_PATH="/path/to/gcc-arm-none-eabi-8-2019-q3-update"
- Or, add the toolchain's
bindirectory to yourPATH:export PATH="/path/to/gcc-arm-none-eabi-8-2019-q3-update/bin:$PATH"
- Set the
-
-
-
Build the App
Use the Pebble SDK to build the app:pebble build
-
Install the App on the Pebble Emulator
Connect your Pebble Emulator and install the app:pebble install --emulator diorite --logs
-
Test the App on your watch
Once installed, test the app on your Pebble watch to ensure it works as expected. Connect your Pebble watch and install the app:pebble install --cloudpebble --logs
The app has three simple functions, the up button starts continuously running your model on the accelerometer buffer. The down button sends data up to an Edge Impulse project, and the select button allows you to see and set a few parameters (explained below). There are also settings in the mobile app via the settings page once you've installed on a real watch.
For additional details on Pebble app development, refer to the Pebble Developer Documentation.
This project already contains an example model for detecting when you're typing on a keyboard. You can replace it with a machine learning model deployed as a C++ library from an Edge Impulse.
You can set up a free Edge Impulse account to start building models for your watch. Once set up create a new project. This is where you'll build your first model. You can look at (or even clone) the example project loaded with this repository for typing detection here.
This app currently lets you collect data directly from the Pebble and upload it to an Edge Impulse project for training. To do this you'll need to copy an ingestion API key from the API Keys tab in a new Edge Impulse project dashboard. This needs to be pasted into the API Key field in the settings page for the Edge Impulse watch app, accessible via the Core Devices app on your mobile phone.
The following settings are available in the configuration page (accessed via the Core Devices app on your phone):
- Edge Impulse API Key: Enter your Edge Impulse ingestion API key. Required for uploading data to your Edge Impulse project.
- Use model's sampling frequency and max samples: Toggle to use the sampling frequency and max samples defined by the current model. If off, you can set these manually.
- Sampling Frequency (Hz): Set how often data is sampled (10, 25, 50, or 100 Hz). Only used if the above toggle is off.
- Max Samples: Set the maximum number of samples to collect per recording (0–500, in steps of 25). Only used if the above toggle is off.
- Label uploads with current model: Toggle to automatically label uploaded data with the current model’s label.
- Custom upload label: Enter a custom label for uploaded data, if not using the model label.
- Upload data to: Choose where to upload data: "Training", "Testing", or "Split" (for automatic splitting).
- Save Settings: Button to save your configuration.
On the watch itself in the app you can click the select button (...) to access a few settings including:
- Use model's sampling frequency and max samples: Toggle to use the sampling frequency and max samples defined by the current model. If off, you can set these manually.
- Sampling Frequency (Hz): Set how often data is sampled (10, 25, 50, or 100 Hz). Only used if the above toggle is off.
- Max Samples: Set the maximum number of samples to collect per recording (0–500, in steps of 25). Only used if the above toggle is off.
- Label uploads with current model: Toggle to automatically label uploaded data with the current model’s label.
- Upload data to: Choose where to upload data: "Training", "Testing", or "Split" (for automatic splitting).
Once you've set up the settings as you desire, you can use the down button to start collecting data for your new project. You'll see samples appear in the Data Acquisition page of your project if there are no errors.
Head to the Edge Impulse documentation for more guidance on getting started with training an edge AI model. There are a few key restrictions when developing for the Pebble:
- There is not a lot of RAM/ROM available on the device, keep your model small. You can set a "Custom Target" while training your model from the top right of the screen to get an idea for how much RAM/ROM and Latency your model will have on device based on the specs of the Pebble watch you're building for.
- Currently this example has only been tested working with a Classification model, compiled with the EON compiler in 8 bit quantized mode. Classical ML models, TFLite and Regression currently don't work on the device.
Once you've downloaded an int8 Quantized, EON Compiled C++ Library deployment for your model, unzip it and place all the folders at the root of the pebble app folder, replacing the edge-impulse-sdk, model-parameters and tflite-model folders.
** Update the run_edge_impulse_on_features() function **
To make your new model compile correctly you need to find this in src/pebble-cpp.cpp (around line 93) and change the line:
ei_impulse_handle_t impulse_handle = ei_impulse_handle_t(&impulse_819643_1);
and update the impulse handle with your model's handle. This can be found at the bottom of model-parameters/model_vairables.h, e.g.:
ei_impulse_handle_t& ei_default_impulse = impulse_handle_819643_1;
You're now ready to build and run the app on your watch:
-
Build the App
Use the Pebble SDK to build the app:pebble build
-
Install the App on the Pebble Emulator
Connect your Pebble Emulator and install the app:pebble install --emulator diorite --logs
-
Test the App on your watch
Once installed, test the app on your Pebble watch to ensure it works as expected. Connect your Pebble watch and install the app:pebble install --cloudpebble --logs
This project is licensed under the BSD 3-Clause License. See the LICENSE file and the license headers in the edge-impulse-sdk/ directory for details.