---
title: Building a Simple Asset Tracker
description: Build a compact, self-contained asset tracker using the Notecard Cell+WiFi's built-in GNSS module and the Notecarrier CX's onboard Cygnet MCU.
source_url: https://dev.blues.io/example-apps/samples/building-a-simple-asset-tracker/
canonical_url: https://dev.blues.io/example-apps/samples/building-a-simple-asset-tracker/
markdown_url: https://dev.blues.io/example-apps/samples/building-a-simple-asset-tracker.md
---

# Building a Simple Asset Tracker

## Introduction

This sample demonstrates how to build a compact, self-contained asset tracker using the [Blues Notecarrier CX](https://shop.blues.com/products/notecarrier-cx?utm_source=dev-blues\&utm_medium=web\&utm_campaign=store-link) and the [Blues Notecard Cell+WiFi](https://shop.blues.com/products/notecard-cell-wifi?utm_source=dev-blues\&utm_medium=web\&utm_campaign=store-link). The sample leverages the Notecard Cell+WiFi's built-in GNSS module, keeping the hardware footprint small and the setup straightforward.

The Notecarrier CX is a Notecarrier X and a Blues Cygnet (STM32L433) combined into a single board. This means you get a carrier board with an onboard host MCU out of the box, with no external microcontroller required. For a simple asset tracker, the Notecard handles GPS acquisition and cloud synchronization autonomously. The Cygnet MCU can be used to configure the Notecard on first boot or to add application logic over time.

### Wireless Connectivity with Blues

This sample is built around the [Blues Notecard](https://blues.com/products/notecard/) and [Blues Notehub](https://blues.com/notehub/).

The **Blues Notecard** is the easiest way for developers to add secure, robust, and affordable pre-paid wireless connectivity to their microcontroller or single-board computer of choice. Notecard is a System-on-Module (SoM) that combines pre-paid data, low-power hardware (\~8μA–18μA when idle), and secure communications. It acts as a device-to-cloud data pump to communicate with the Blues cloud service Notehub.

**Notehub** is the Blues cloud service for routing Notecard-provided data to third-party cloud applications, deploying OTA firmware updates, and securely managing fleets of Notecards. Notehub allows for secure communications between edge devices and the cloud without certificate management or manual provisioning of devices.

## General Information

### System Hardware

This article’s pattern can be implemented with any Notecard Cellular or Notecard Cell+WiFi, any host microcontroller, and any battery. For demonstration purposes, this article uses the following hardware.

| Component                                                                                                                                                    | Purpose                                                                                                                   |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------- |
| [Blues Notecard Cell+WiFi](https://shop.blues.com/products/notecard-cell-wifi?utm_source=dev-blues\&utm_medium=web\&utm_campaign=store-link)                 | Wireless connectivity module with built-in GNSS for location tracking.                                                    |
| [Blues Notecarrier CX](https://shop.blues.com/products/notecarrier-cx?utm_source=dev-blues\&utm_medium=web\&utm_campaign=store-link)                         | Carrier board with onboard STM32L433 host MCU (Cygnet), M.2 Notecard socket, LiPo connector, and u.FL antenna connectors. |
| [LiPo Battery](https://shop.blues.com/collections/accessories/products/5-000-mah-lipo-battery?utm_source=dev-blues\&utm_medium=web\&utm_campaign=store-link) | Power source.                                                                                                             |

### List of Acronyms

| Acronym | Definition                                                                                                                       |
| ------- | -------------------------------------------------------------------------------------------------------------------------------- |
| MCU     | Microcontroller                                                                                                                  |
| SoM     | System-on-Module                                                                                                                 |
| GPS     | Global Positioning System, a satellite-based radio navigation system                                                             |
| GNSS    | Global Navigation Satellite System, a generic term for any satellite constellation that provides positioning and timing services |

## Summary

The Notecard Cell+WiFi includes a built-in GNSS receiver, making it possible to build an asset tracker without any external GPS module. The key design consideration is that the Notecard's cellular modem and its built-in GPS cannot operate simultaneously. The Notecard handles this constraint automatically: it alternates between acquiring a GPS fix and connecting to Notehub to sync the location data.

For applications where real-time, sub-minute location updates are not required, this periodic approach is an ideal fit. The Notecard autonomously manages the GPS/cellular duty cycle, and the Notecarrier CX's onboard Cygnet MCU can be used to configure the Notecard on first boot, add custom sensor readings alongside the location data, or enter a low-power sleep state to extend battery life.

> **Note:**
>
> If your use case demands simultaneous cellular connectivity and GPS sampling—for example, a vehicle tracker that must upload location data continuously with minimal latency—consider using an external GPS module instead. See the [Continuous Asset Tracking with External GPS](https://dev.blues.io/example-apps/samples/continuous-asset-tracking-with-external-gps-and-immediate-location-sync.md) sample for that approach.

### Requirements

1. A Notehub project to receive the location data. Create a free project at [notehub.io](https://notehub.io/).

## Technical Implementation

> **Tip:**
>
> **Let AI write your firmware.** Blues Expert MCP connects your AI coding assistant (Claude Code, GitHub Copilot, Cursor) directly to our API docs, providing live request validation and firmware best practices for Arduino, C, Zephyr, and Python. [Install the Blues Expert MCP →](https://dev.blues.io/tools-and-sdks/generative-ai-tools/blues-expert-mcp.md)

### Hardware Setup

Begin by assembling the hardware:

1. Insert the Notecard Cell+WiFi into the M.2 connector on the Notecarrier CX and secure it with the included screw.
2. Connect the cellular LTE antenna to the `LTE` u.FL connector on the Notecard.
3. Connect the GPS/GNSS antenna to the `GPS` u.FL connector on the Notecard.
4. Connect a LiPo battery to the JST-PH connector on the Notecarrier CX.

![Notecard + Notecarrier CX + LiPo battery](https://dev.blues.io/images/example-apps/simple-asset-tracker/cx.png?v=74b4acda)

> **Note:**
>
> For optimal GPS performance, place the GPS/GNSS antenna where it has a clear, unobstructed view of the sky. A metallic enclosure or indoor deployment will significantly reduce GPS signal quality and acquisition speed.

### Notecard Configuration

The following Notecard API requests configure the device for periodic asset tracking. You can send these requests using the [In-Browser Terminal](https://dev.blues.io/terminal/), the [Notecard CLI](https://dev.blues.io/tools-and-sdks/notecard-cli.md), or programmatically from the Cygnet using host firmware (see the [Host Firmware](#host-firmware) section below).

> **Note:**
>
> Because these requests are stored in the Notecard's flash memory, they only need to be sent once. The configuration persists across power cycles.

**Step 1: Associate the Notecard with a Notehub project.**

The [hub.set API](https://dev.blues.io/api-reference/notecard-api/hub-requests/latest.md#hub-set) links the Notecard to your Notehub project and sets the synchronization behavior. `periodic` mode is used here so the Notecard alternates between GPS acquisition and cellular sync, since they cannot run simultaneously.

The `vinbound` and `voutbound` arguments use [voltage-variable](https://dev.blues.io/notecard/notecard-walkthrough/low-power-firmware-design.md#customizing-voltage-variable-behaviors) sync intervals to reduce modem usage when the battery is low, extending field life.

**JSON**

```json
{
  "req": "hub.set",
  "product": "<your-product-uid>",
  "mode": "periodic",
  "vinbound": "usb:10;high:60;normal:180;low:360;dead:0",
  "voutbound": "usb:10;high:60;normal:180;low:360;dead:0"
}
```

**C/C++**

```cpp
J *req = NoteNewRequest("hub.set");
JAddStringToObject(req, "product", "<your-product-uid>");
JAddStringToObject(req, "mode", "periodic");
JAddStringToObject(req, "vinbound", "usb:10;high:60;normal:180;low:360;dead:0");
JAddStringToObject(req, "voutbound", "usb:10;high:60;normal:180;low:360;dead:0");
NoteRequest(req);
```

**Step 2: Inform the Notecard of the battery type.**

The [card.voltage API](https://dev.blues.io/api-reference/notecard-api/card-requests/latest.md#card-voltage) tells the Notecard what kind of power source is in use so it can correctly interpret voltage readings for the voltage-variable intervals set above.

**JSON**

```json
{
  "req": "card.voltage",
  "mode": "lipo"
}
```

**C/C++**

```cpp
J *req = NoteNewRequest("card.voltage");
JAddStringToObject(req, "mode", "lipo");
NoteRequest(req);
```

**Step 3: Configure the GPS location sampling interval.**

The [card.location.mode API](https://dev.blues.io/api-reference/notecard-api/card-requests/latest.md#card-location-mode) tells the Notecard how often to power on its GPS receiver and attempt to acquire a location fix. A 5-minute interval (`300` seconds) is a reasonable default for a battery-powered tracker.

**JSON**

```json
{
  "req": "card.location.mode",
  "mode": "periodic",
  "seconds": 300
}
```

**C/C++**

```cpp
J *req = NoteNewRequest("card.location.mode");
JAddStringToObject(req, "mode", "periodic");
JAddNumberToObject(req, "seconds", 300);
NoteRequest(req);
```

**Step 4: Enable location tracking.**

The [card.location.track API](https://dev.blues.io/api-reference/notecard-api/card-requests/latest.md#card-location-track) instructs the Notecard to automatically record each GPS fix to the [`_track.qo` system Notefile](https://dev.blues.io/api-reference/system-notefiles.md#track-qo). The `heartbeat` argument ensure the device "phones home" at least once every 24 hours, even when stationary.

**JSON**

```json
{
  "req": "card.location.track",
  "start": true,
  "heartbeat": true
}
```

**C/C++**

```cpp
J *req = NoteNewRequest("card.location.track");
JAddBoolToObject(req, "start", true);
JAddBoolToObject(req, "heartbeat", true);
NoteRequest(req);
```

### Host Firmware

Host firmware is not required for basic asset tracking—the Notecard operates autonomously once configured. However, running firmware on the Notecarrier CX's onboard Cygnet MCU is useful for sending the configuration commands programmatically on first boot, rather than manually via the In-Browser Terminal.

The firmware below uses the [Notecard Arduino library](https://dev.blues.io/tools-and-sdks/firmware-libraries/arduino-library.md) to initialize the Notecard and send the four configuration requests described above.

> **Note:**
>
> Complete the [Cygnet Quickstart](https://dev.blues.io/quickstart/cygnet-quickstart.md) to learn how to flash firmware to the Notecarrier CX's host MCU.

#### Firmware

```cpp
#include <Notecard.h>

#define myProductUID "<your-product-uid>"

Notecard notecard;

void setup() {
  Serial.begin(115200);
  delay(1000);

  notecard.begin();
  notecard.setDebugOutputStream(Serial);

  // Associate the Notecard with a Notehub project and enable periodic sync.
  // sendRequestWithRetry handles the race condition on cold boot.
  J *req = notecard.newRequest("hub.set");
  if (req) {
    JAddStringToObject(req, "product", myProductUID);
    JAddStringToObject(req, "mode", "periodic");
    JAddStringToObject(req, "vinbound", "usb:10;high:60;normal:180;low:360;dead:0");
    JAddStringToObject(req, "voutbound", "usb:10;high:60;normal:180;low:360;dead:0");
    notecard.sendRequestWithRetry(req, 5);
  }

  // Inform the Notecard that it is running on a LiPo battery so it can
  // correctly interpret the voltage-variable sync intervals above.
  req = notecard.newRequest("card.voltage");
  if (req) {
    JAddStringToObject(req, "mode", "lipo");
    notecard.sendRequest(req);
  }

  // Sample GPS every 5 minutes.
  req = notecard.newRequest("card.location.mode");
  if (req) {
    JAddStringToObject(req, "mode", "periodic");
    JAddNumberToObject(req, "seconds", 300);
    notecard.sendRequest(req);
  }

  // Record each GPS fix to _track.qo.
  // Send a heartbeat every 24 hours even when the asset is not moving.
  req = notecard.newRequest("card.location.track");
  if (req) {
    JAddBoolToObject(req, "start", true);
    JAddBoolToObject(req, "heartbeat", true);
    notecard.sendRequest(req);
  }

  Serial.println("Asset tracker configured.");
}

void loop() {
  // The Notecard autonomously manages GPS sampling and Notehub sync.
  // The Cygnet can remain idle here, or be extended with additional sensors
  // or put to sleep using card.attn to reduce power consumption.
  delay(60000);
}
```

> **Note:**
>
> The Notecard stores these configuration requests in non-volatile memory, so they persist across power cycles.

> **Note:**
>
> To further reduce power consumption, the Cygnet can be put to sleep between wakeups using the Notecard's `card.attn` command, in the same pattern described in the [Putting a Host to Sleep Between Sensor Readings](https://dev.blues.io/example-apps/samples/putting-a-host-to-sleep-between-sensor-readings.md) sample.

### Expected Results

After the device is powered on it will:

1. Make an initial cellular connection to sync the clock.
2. Begin periodic GPS acquisition every 5 minutes, when in motion.
3. Sync location data to Notecard according to the configured `voutbound` value.

Location events appear in Notehub under the `_track.qo` Notefile.

![List of \_track.qo Notes in Notehub](https://dev.blues.io/images/example-apps/simple-asset-tracker/track-qo-notes.png?v=0d17731a)

Each Note's JSON will include GPS data in the `best_location` fields.

```json
{
  "best_location_type": "gps",
  "best_lat": 42.7522525,
  "best_lon": -84.74562109375,
  "best_location": "Grand Ledge MI",
  "best_country": "US",
  "best_timezone": "America/Detroit",
  "best_when": 1704717310
}
```

> **Note:**
>
> With the current configuration, `_track.qo` Notes are synced to Notehub according to the configured `voutbound` schedule—every 10 minutes on USB power, every 60 minutes on high battery, and every 3 hours on normal battery by default.
>
> You can reduce these intervals in the `hub.set` request for more frequent uploads, but intervals under 5 minutes are not recommended when using the Notecard's built-in GPS. Because cellular and GPS cannot run simultaneously, very short intervals leave insufficient time for the Notecard to alternate between acquiring a fix and connecting to sync. If your use case requires sub-5-minute location updates, consider using an external GPS module instead—see the [Continuous Asset Tracking with External GPS](https://dev.blues.io/example-apps/samples/continuous-asset-tracking-with-external-gps-and-immediate-location-sync.md) sample.

#### Potential Issues

1. **No GPS fix**: If the Notecard cannot acquire a GPS fix, confirm the GNSS antenna is properly connected and the device has a clear view of the sky. GPS acquisition can take several minutes in a new location. See [Diagnosing GPS Issues on the Notecard](https://dev.blues.io/support/diagnosing-gps-issues.md) for more information.
2. **No cellular connection**: The Notecard must establish an initial cellular connection before GPS is enabled. Verify the cellular antenna is connected and that the device is within cellular coverage. See [Diagnosing Cellular Connectivity Issues](https://dev.blues.io/support/diagnosing-cellular-connectivity-issues.md) for more information.

## Additional Resources

- [Asset Tracking with GPS Guide](https://dev.blues.io/guides-and-tutorials/notecard-guides/asset-tracking-with-gps.md)
- [Working with GPS on the Notecard](https://dev.blues.io/notecard/notecard-walkthrough/time-and-location-requests.md#working-with-gps-on-the-notecard)
- [Diagnosing GPS Issues on the Notecard](https://dev.blues.io/support/diagnosing-gps-issues.md)
- [Notecarrier CX Datasheet](https://dev.blues.io/datasheets/notecarrier-datasheet/notecarrier-cx-v1-7.md)
- [Cygnet Quickstart](https://dev.blues.io/quickstart/cygnet-quickstart.md)
- [Low-Power Firmware Design](https://dev.blues.io/notecard/notecard-walkthrough/low-power-firmware-design.md)
- [Putting a Host to Sleep Between Sensor Readings](https://dev.blues.io/example-apps/samples/putting-a-host-to-sleep-between-sensor-readings.md)
