Embedded·2024

BLE Indoor Positioning and Tracking System

A BLE 5.1 indoor positioning system built for logistics warehousing, using AoA direction-finding technology with 30cm positioning accuracy for real-time tracking of goods and personnel

clientLogistics & Warehousing Company
duration5 months
categoryEmbedded
stack
Nordic nRF52840BLE 5.0AoA/AoDRustReactNode.jsPostgreSQLWebSocket

Project Overview

A BLE 5.1 indoor positioning system developed for a logistics and warehousing company. Utilizing the Nordic nRF52840 chip with AoA (Angle of Arrival) direction-finding technology, the system achieves sub-meter positioning accuracy. It can track over 5,000+ cargo tags and 200+ employees in real time within the warehouse, improving picking efficiency and warehouse management.

Core Technologies

1. BLE 5.1 AoA Direction Finding

Leveraging BLE 5.1 Direction Finding capabilities, the system calculates signal angle of arrival through antenna arrays:

// nRF52840 AoA reception processing (Rust implementation)
use nrf52840_hal as hal;
use embedded_hal::digital::v2::OutputPin;

pub struct AoAReceiver {
    radio: hal::Radio,
    antenna_array: [hal::gpio::Pin; 12],
    iq_samples: [Complex<i8>; 128],
}

impl AoAReceiver {
    pub fn measure_angle(&mut self) -> Result<(f32, f32), Error> {
        // Enable CTE reception mode
        self.radio.configure_cte_rx(CteMode::AoA);

        // Configure antenna switching pattern
        self.configure_antenna_switching();

        // Wait for packet reception
        let packet = self.radio.receive_with_cte()?;

        // Extract IQ samples
        self.extract_iq_samples(&packet);

        // MUSIC algorithm for angle calculation
        let (azimuth, elevation) = self.music_algorithm()?;

        Ok((azimuth, elevation))
    }

    fn music_algorithm(&self) -> Result<(f32, f32), Error> {
        // Compute covariance matrix
        let cov_matrix = self.compute_covariance_matrix();

        // Eigenvalue decomposition
        let (eigenvalues, eigenvectors) = cov_matrix.eig();

        // Scan spatial spectrum
        let spectrum = self.scan_spatial_spectrum(&eigenvectors);

        // Find peak angles
        let (azimuth, elevation) = spectrum.find_peaks();

        Ok((azimuth, elevation))
    }
}

2. Multi-Point Positioning Fusion

Combining AoA measurements from multiple anchors, the system uses least squares method to calculate precise positions:

  • Anchor deployment: One anchor per 10m x 10m on the ceiling
  • Redundancy design: At least 3 anchors visible from each position
  • Kalman filtering: Smooths trajectories and predicts movement direction

3. Low-Power Tag Design

Cargo tags use CR2032 coin-cell batteries and can operate for over 2 years:

  • Broadcast interval: Once per 10 seconds when stationary, once per second when moving
  • Motion detection: Built-in accelerometer detects movement state
  • Ultra-low power: Average current < 20uA

System Architecture

+----------------------------------------------------------+
|                    Warehouse Ceiling                       |
|  +--------+  +--------+  +--------+  +--------+          |
|  |Anchor 1|  |Anchor 2|  |Anchor 3|  |Anchor 4|          |
|  |nRF52840|  |nRF52840|  |nRF52840|  |nRF52840|          |
|  +----+---+  +----+---+  +----+---+  +----+---+          |
|       |           |           |           |               |
|       +-----------+-----+-----+-----------+               |
|                         | PoE Network                     |
|                         v                                 |
|               +-----------------+                         |
|               | Positioning     |                         |
|               | Engine Server   |                         |
|               | (Node.js)       |                         |
|               +--------+--------+                         |
|                        |                                  |
|         +--------------+--------------+                   |
|         v              v              v                   |
|   +----------+  +----------+  +----------+               |
|   |PostgreSQL|  | Real-time|  |   API    |               |
|   |  Location|  |   Map    |  |  Service |               |
|   |  History |  | (React)  |  |          |               |
|   +----------+  +----------+  +----------+               |
+----------------------------------------------------------+

        BLE Tags (Cargo)          Employee Badges
           ^ Broadcast                ^ Broadcast

Project Results

  • Positioning accuracy: 95% error < 50cm
  • Update frequency: 1Hz for moving objects, 0.1Hz for stationary objects
  • Coverage area: 10,000 square meter warehouse
  • Simultaneous tracking: 5,000+ tags
$ ls projects/embedded/

More work in Embedded.