Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
ALICE-Edge
Part of ALICE-Eco-System — 260+ crate Edge-to-Cloud data pipeline (SDF / Physics / LLM / Motion / Font / TTS)
Embedded Model Generator - "Don't send data. Send the law."
Installation
Add to your Cargo.toml:
[]
= "0.1"
# With sensor drivers and MQTT:
= { = "0.1", = ["sensors", "mqtt"] }
# Full edge pipeline (depth camera → SDF → ML → streaming):
= { = "0.1", = ["edge-pipeline"] }
Minimum Supported Rust Version (MSRV): 1.70+ (edition 2021)
The Philosophy
Raw sensor data never leaves the device. Instead, we fit a mathematical model on-device and transmit only the coefficients.
Traditional IoT: 1000 samples × 4 bytes = 4,000 bytes transmitted
ALICE-Edge: 1000 samples → y = ax + b → 8 bytes transmitted
Compression: 500x
Privacy: raw data discarded on-device
Benchmark: Raspberry Pi 5 (Cortex-A76, Criterion --release)
| Operation | 10 samples | 100 samples | 1000 samples | 4096 samples |
|---|---|---|---|---|
| fit_linear_fixed | 20 ns | 91 ns | 751 ns | 3.0 µs |
| fit_constant_fixed | 8.4 ns | 33 ns | 218 ns | 870 ns |
| full_pipeline | — | 90 ns | 752 ns | — |
| Single Operation | Measured |
|---|---|
| evaluate_linear (1000-point reconstruct) | 2.1 µs |
| compute_residual_error (1000 samples) | 619 ns |
| should_use_linear (model selection) | 3.4 µs |
| Q16 conversion (1000×) | 1.1 µs |
| Metric | Value |
|---|---|
| Throughput | 1.33M models/sec (1000 samples each) |
| Compression ratio | 500x (4000 B → 8 B per sensor) |
| Multi-sensor hub (8 sensors × 1000) | 571x (32 KB → 56 B) |
| Dashboard throughput | 11,943 models/sec with HLL + CMS |
| Stack usage | 48 bytes |
| Binary size (no_std core) | < 1 KB |
| Dependencies (no_std) | Zero |
Architecture
┌───────────────────────────────────────────────────────────────────────┐
│ ALICE-Edge on Raspberry Pi 5 │
│ │
│ ┌──────────┐ I2C/SPI/GPIO/UART ┌──────────────┐ │
│ │ BME280 │─────────────────────▶│ │ ┌──────────┐ │
│ │ DHT22 │ │ fit_linear │──▶│ 8 bytes │ │
│ │ ADXL345 │ │ _fixed() │ │ (slope, │ │
│ │ GPS │ │ │ │ intercept│ │
│ └──────────┘ │ Q16.16 │ └────┬─────┘ │
│ │ Fixed-Point │ │ │
│ ┌──────────────┐ └──────────────┘ │ │
│ │ ALICE- │ ▼ │
│ │ Analytics │◀──latency, compression stats ┌──────────────┐ │
│ │ Dashboard │ │ MQTT Publish │ │
│ │ (HLL, CMS) │ │ AWS IoT Core │ │
│ └──────────────┘ │ Azure IoT Hub│ │
│ │ Mosquitto │ │
│ Raw data → DISCARDED (privacy by design) └──────────────┘ │
└───────────────────────────────────────────────────────────────────────┘
Quick Start
1. Simulated Sensors (any platform)
# Run simulated sensor demo (no hardware required)
# Multi-sensor hub with compression table
2. Real Hardware on Raspberry Pi 5
# BME280 (I2C) + DHT22 (GPIO) + ADXL345 (SPI)
3. MQTT to Cloud
# Local Mosquitto
# AWS IoT Core
4. Dashboard
Wiring Guide (Raspberry Pi 5)
BME280 (Temperature / Humidity / Pressure) — I2C
BME280 Pi 5
────── ────
VIN ────────── 3.3V (Pin 1)
GND ────────── GND (Pin 6)
SDA ────────── GPIO 2 / SDA1 (Pin 3)
SCL ────────── GPIO 3 / SCL1 (Pin 5)
DHT22 (Temperature / Humidity) — GPIO
DHT22 Pi 5
────── ────
VCC ────────── 3.3V (Pin 1)
GND ────────── GND (Pin 9)
DATA ────────── GPIO 4 (Pin 7)
(10kΩ pull-up between DATA and VCC)
ADXL345 (3-Axis Accelerometer) — SPI
ADXL345 Pi 5
────── ────
VCC ────────── 3.3V (Pin 17)
GND ────────── GND (Pin 20)
CS ────────── GPIO 8 / CE0 (Pin 24)
SDO ────────── GPIO 9 / MISO (Pin 21)
SDA ────────── GPIO 10 / MOSI (Pin 19)
SCL ────────── GPIO 11 / SCLK (Pin 23)
GPS Module (NEO-6M / NEO-7M) — UART
GPS Pi 5
────── ────
VCC ────────── 3.3V (Pin 1)
GND ────────── GND (Pin 14)
TX ────────── GPIO 15 / RXD (Pin 10)
RX ────────── GPIO 14 / TXD (Pin 8)
API
Core (no_std, zero dependencies)
use ;
// Sensor readings (e.g., temperature × 100)
let samples = ; // 25.00°C rising
// Fit model ON DEVICE — raw data never leaves!
let = fit_linear_fixed;
// Transmit only 8 bytes
transmit;
transmit;
// On receiver: reconstruct any point
let temp_at_10 = evaluate_linear_fixed;
let celsius = q16_to_int as f32 / 100.0;
Sensor Drivers (feature: sensors / sensors-hw)
use ;
let mut sensor = new; // I2C bus 1
sensor.init?;
let batch = sensor.read_samples?;
let = fit_linear_fixed;
// 4000 bytes → 8 bytes (500x compression)
MQTT Bridge (feature: mqtt)
use ;
let config = local;
let mut publisher = new?;
publisher.publish_coefficients?;
publisher.publish_binary?; // 24 bytes
Dashboard (feature: dashboard)
use EdgeDashboard;
let mut dashboard = new;
dashboard.record_compression;
dashboard.print_dashboard; // Terminal output
let json = dashboard.to_json; // JSON for API
Feature Flags
| Feature | Dependencies | Description |
|---|---|---|
| (default) | None | no_std core: fit/evaluate/Q16.16 |
sensors |
serde, serde_json | Sensor drivers (simulated) |
sensors-hw |
rppal, serialport | Real GPIO/I2C/SPI/UART on Pi |
mqtt |
rumqttc | MQTT publish to cloud |
dashboard |
alice-analytics | HLL/CMS/latency dashboard |
pyo3 |
pyo3, numpy | Python bindings (zero-copy NumPy) |
zip |
alice-zip | ALICE-Zip compression bridge |
codec |
alice-codec | Wavelet denoising bridge |
db |
alice-db | Coefficient persistence bridge |
ml |
alice-ml | 1.58-bit ternary classification |
depth-camera |
rusb | Dolphin D5 Lite depth camera |
sdf |
alice-sdf | SDF point cloud compression |
asp |
libasp | ALICE Streaming Protocol bridge |
edge-pipeline |
(all above) | Full depth → SDF → ML pipeline |
Q16.16 Fixed-Point Format
ALICE-Edge uses Q16.16 fixed-point arithmetic (no FPU required):
16 bits integer | 16 bits fraction
Range: -32768.0 to +32767.99998
Value 25.50°C (as 2550 raw):
Q16.16 = 2550 × 65536 = 167,116,800
Convert back: 167,116,800 / 65536 = 2550 → 25.50°C
Memory & Stack Usage
| Function | Stack | Description |
|---|---|---|
fit_linear_fixed |
48 B | O(N) loop, O(1) x-sums |
evaluate_linear_fixed |
16 B | Single MLA instruction |
fit_constant_fixed |
24 B | Mean value |
compute_residual_error |
32 B | Sum of squared errors |
Project Structure
ALICE-Edge/
├── Cargo.toml
├── src/
│ ├── lib.rs # Core: fit_linear_fixed, Q16.16 (no_std)
│ ├── sensors.rs # BME280, DHT22, ADXL345, GPS drivers
│ ├── mqtt_bridge.rs # MQTT publish (AWS IoT, Azure, Mosquitto)
│ ├── dashboard.rs # ALICE-Analytics dashboard (HLL, CMS)
│ ├── python.rs # PyO3 bindings (zero-copy NumPy)
│ ├── zip_bridge.rs # ALICE-Zip compression
│ ├── codec_bridge.rs # Wavelet denoising
│ ├── db_bridge.rs # Coefficient persistence
│ ├── ml_bridge.rs # Ternary neural network (~80 B model)
│ ├── depth_capture.rs # Dolphin D5 Lite depth camera
│ ├── sdf_compress.rs # SDF point cloud compression
│ ├── object_classifier.rs # Edge object classification
│ ├── asp_bridge.rs # ALICE Streaming Protocol
│ └── edge_pipeline.rs # Full depth → SDF → ML pipeline
├── examples/
│ ├── simulate_sensors.rs # Simulated sensor demo (any platform)
│ ├── bme280_compress.rs # BME280 compression (Pi or simulated)
│ ├── multi_sensor_hub.rs # Multi-sensor compression table
│ ├── mqtt_local.rs # MQTT to local Mosquitto
│ ├── mqtt_aws_iot.rs # MQTT to AWS IoT Core
│ ├── dashboard_demo.rs # ALICE-Analytics dashboard
│ └── python_batch.py # Python + NumPy batch processing
├── benches/
│ └── pi5_bench.rs # Criterion benchmarks
└── README.md
Bindings
ALICE-Edge provides cross-language bindings via C-ABI FFI:
C/C++
int32_t data = ;
AliceLinearResult r = ;
int32_t predicted = ;
float celsius = / 100.0f;
Build: cargo build --release --features ffi → libalice_edge.dylib / .so / .dll
Header: bindings/alice_edge.h
Unity (C#)
using AliceEdge;
int[] samples = {2500, 2510, 2520, 2530, 2540};
var (slope, intercept) = AliceModel.FitLinear(samples);
float temp = AliceModel.Q16ToFloat(
AliceModel.EvaluateLinear(slope, intercept, 10)) / 100f;
DllImport wrapper: bindings/AliceEdge.cs
Python (PyO3 + NumPy)
=
, =
=
Build: maturin develop --features pyo3
Quality
| Metric | Value |
|---|---|
| Tests | 249 (243 lib + 6 doc), 0 failures |
| clippy pedantic | 0 warnings |
| cargo doc | 0 warnings |
| cargo fmt | clean |
| FFI functions | 19 (fitting, evaluate, robust, SIMD, filter, delta, zeroize) |
| Bindings | C/C++ header, Unity C#, Python PyO3 |
Security Model
┌──────────────────────────────────────────────────────────────────┐
│ EDGE DEVICE │
│ ┌────────────┐ ┌────────────┐ ┌──────────────┐ │
│ │ Sensor │───▶│ fit_linear │───▶│ Coefficients │───▶ Network│
│ │ (raw) │ │ _fixed() │ │ (8 bytes) │ │
│ └────────────┘ └────────────┘ └──────────────┘ │
│ │ │
│ ▼ │
│ [DISCARDED] ← Raw data NEVER leaves device │
└──────────────────────────────────────────────────────────────────┘
Privacy by Design: Raw sensor data is processed and immediately discarded. Only mathematical coefficients (8 bytes) are transmitted. Ideal for:
- Medical devices (HIPAA compliance)
- Industrial sensors (trade secrets)
- Smart home (user privacy)
ALICE Ecosystem Integration
| Bridge | Source Crate | Usage |
|---|---|---|
| Sensor compression | ALICE-Edge (core) | Q16.16 linear regression |
| Model storage | ALICE-DB | Coefficient time-series |
| Wavelet denoising | ALICE-Codec | Pre-processing sensor data |
| Binary compression | ALICE-Zip | Artifact packaging |
| Analytics | ALICE-Analytics | HLL, CMS, latency tracking |
| Neural classification | ALICE-ML | 1.58-bit ternary inference |
| SDF compression | ALICE-SDF | Point cloud → SDF |
| Streaming | ALICE-Streaming-Protocol | Low-bandwidth video |
Build
On Raspberry Pi 5 (recommended)
# Install Rust (one-time)
|
# Clone
# Build (release)
# Run benchmarks
Cross-compile (macOS → aarch64 Linux)
Supported Platforms
| Platform | no_std Core | Sensors (HW) | MQTT | Dashboard |
|---|---|---|---|---|
| Raspberry Pi 5 | Y | Y | Y | Y |
| Raspberry Pi 4/3 | Y | Y | Y | Y |
| Raspberry Pi Pico (RP2040) | Y | - | - | - |
| ARM Cortex-M (M0/M3/M4/M7) | Y | - | - | - |
| ESP32 / ESP8266 | Y | - | - | - |
| RISC-V | Y | - | - | - |
| macOS / Linux (x86_64) | Y | sim | Y | Y |
Troubleshooting (Raspberry Pi)
"Permission denied" on GPIO:
&&
"I2C device not found (0x76)":
"SPI bus not available":
Contributing
See CONTRIBUTING.md for build, test, and lint instructions.
Changelog
See CHANGELOG.md for version history.
License
MIT (Core)
Note: The core no_std library is licensed under MIT. However, enabling certain feature flags (e.g., dashboard, db, ml) links against AGPL-3.0 components from the broader ALICE ecosystem. Binaries built with these features enabled are subject to the terms of the AGPL-3.0 license.
Author
Moroya Sakamoto
"The best sensor network is one where data never travels."