11 releases
Uses new Rust 2024
| 0.1.12 | Feb 2, 2026 |
|---|---|
| 0.1.11 | Feb 1, 2026 |
| 0.1.9 | Jan 22, 2026 |
#703 in Hardware support
Used in 4 crates
(2 directly)
600KB
11K
SLoC
aranet-core
Core BLE library for Aranet environmental sensors.
This crate provides low-level Bluetooth Low Energy (BLE) communication with Aranet sensors including the Aranet4, Aranet2, AranetRn+ (Radon), and Aranet Radiation devices.
Features
- Device discovery — Scan for nearby Aranet devices via BLE
- Current readings — CO₂, temperature, pressure, humidity, radon, radiation
- Historical data — Download measurement history with timestamps and resumable checkpoints
- Device settings — Read/write measurement interval, Bluetooth range
- Auto-reconnection — Configurable backoff and retry logic with exponential delays
- Real-time streaming — Subscribe to sensor value changes
- Multi-device support — Manage multiple sensors simultaneously with adaptive polling
- Passive monitoring — Monitor devices via BLE advertisements without connecting
- Platform support — Platform-specific configuration for macOS, Linux, and Windows
- Diagnostics — Bluetooth adapter diagnostics, connection stats, and error tracking
- Cross-platform aliases — Device aliasing system for consistent identification
Supported Devices
| Device | Sensors |
|---|---|
| Aranet4 | CO₂, Temperature, Pressure, Humidity |
| Aranet2 | Temperature, Humidity |
| AranetRn+ | Radon (Bq/m³), Temperature, Pressure, Humidity |
| Aranet Radiation | Dose Rate (µSv/h), Total Dose (mSv) |
Installation
[dependencies]
aranet-core = "0.1"
Usage
use aranet_core::{Device, scan};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Scan for devices
let devices = scan::scan_for_devices().await?;
println!("Found {} devices", devices.len());
// Connect to a device
let device = Device::connect("Aranet4 12345").await?;
// Read current values
let reading = device.read_current().await?;
println!("CO₂: {} ppm", reading.co2);
println!("Temperature: {:.1}°C", reading.temperature);
// Read device info
let info = device.read_device_info().await?;
println!("Serial: {}", info.serial);
// Download history
let history = device.download_history().await?;
println!("Downloaded {} records", history.len());
Ok(())
}
Platform Notes
Device identification varies by platform:
- macOS: Devices are identified by a UUID assigned by CoreBluetooth (stable per Mac, but differs between Macs)
- Linux/Windows: Devices are identified by their Bluetooth MAC address (e.g.,
AA:BB:CC:DD:EE:FF)
Examples
Run the examples with:
# Scan for nearby devices
cargo run --example scan_devices
# Read current sensor values
cargo run --example read_sensor
# Download measurement history
cargo run --example download_history
Related Crates
This crate is part of the aranet workspace:
| Crate | crates.io | Description |
|---|---|---|
| aranet-types | Shared types for sensor data | |
| aranet-store | Local data persistence | |
| aranet-cli | Command-line interface | |
| aranet-tui | Terminal UI dashboard | |
| aranet-service | Background collector and REST API | |
| aranet-gui | Desktop GUI application |
License
MIT
Made with ❤️ by Cameron Rye
Dependencies
~11–47MB
~587K SLoC