EMAY SleepO2 BLE SDK
A multi-language SDK for the EMAY SleepO2 pulse oximeter's real-time Bluetooth streaming protocol. Read SpO₂ and pulse rate at 1 Hz from a $30 consumer device.
Every package exposes the same simple API. Pick your language — the
EMAYClient interface is identical across Swift, Python, Node.js, Rust,
Go, and Kotlin.
Quick Start
Swift
import EMAYSleepO2
let emay = EMAYClient()
emay.onReading = { reading in
print("SpO₂: \(reading.spo2 ?? 0)% HR: \(reading.pulse ?? 0)")
}
try await emay.start()
Python
import asyncio
from emay_sleepo2 import EMAYClient
async def main():
emay = EMAYClient()
emay.on_reading = lambda r: print(f"SpO₂: {r.spo2}% HR: {r.pulse}")
await emay.start()
await asyncio.sleep(30) # stream for 30 seconds
await emay.stop()
asyncio.run(main())
Node.js
import { EMAYClient } from '@groundeffect/emay-sleepo2';
const emay = new EMAYClient();
emay.on('reading', (r) => {
console.log(`SpO₂: ${r.spo2}% HR: ${r.pulse}`);
});
await emay.start();
// ... stream ...
await emay.stop();
Rust
use emay_sleepo2::EMAYClient;
#[tokio::main]
async fn main() {
let mut emay = EMAYClient::new().await?;
emay.on_reading(|r| println!("SpO₂: {}% HR: {}", r.spo2, r.pulse));
emay.start().await?;
tokio::time::sleep(Duration::from_secs(30)).await;
emay.stop().await?;
}
Go
package main
import (
"fmt"
"time"
emay "github.com/chenders/emay-sleepo2"
)
func main() {
client, _ := emay.NewClient(emay.DefaultAdapter())
client.OnReading = func(r emay.Reading) {
fmt.Printf("SpO₂: %d%% HR: %d\n", r.SpO2, r.Pulse)
}
client.Start()
time.Sleep(30 * time.Second)
client.Stop()
}
Kotlin (Android)
val emay = EMAYClient(context)
emay.onReading = { reading ->
println("SpO₂: ${reading.spo2}% HR: ${reading.pulse}")
}
emay.start(scope = lifecycleScope)
API Reference
Every binding exposes the same minimal interface:
class EMAYClient {
// Lifecycle
start() — connect and begin streaming
stop() — stop streaming and disconnect
isStreaming: bool — whether currently streaming
// Data
onReading: (Reading) -> void — called at ~1 Hz with new readings
// Status
status: Status — Idle | Scanning | Connecting | Streaming | Failed
onStatusChange: (Status) -> void
// Advanced
start(address) — connect to a specific device by address
batteryLevel: Int? — battery percentage (after connection)
heartbeatInterval: Duration — default 1.5s
// CSV (parse only, no BLE)
static parseCSV(data) -> [Reading]
static parseCSVFile(path) -> [Reading]
}
Reading Type
Reading {
spo2: Int? // SpO₂ percent (0–100), nil when finger off
pulse: Int? // Pulse rate in bpm, nil when no reading
timestamp: Instant // When this reading was captured
}
The Protocol (tl;dr)
- BLE service
FF12, writeFF01, notifyFF02 - Commands:
payload + sum(payload) & 0x7F - Start sequence:
hello → deviceState → startRealtime → getBattery - Sustain with a heartbeat command every ~1.5 s
- Data frames: 8 bytes —
EB 01 05 [PR] [SpO2] 7F 00 [cks] - Full specification:
spec.md
Packages
| Language | Source | Platform | BLE Library |
|---|---|---|---|
| Swift | swift/ |
iOS/macOS | CoreBluetooth |
| Python | python/ |
macOS/Linux/Windows/RPi | bleak |
| Node.js | node/ |
macOS/Linux/Windows/RPi | noble |
| Rust | rust/ |
macOS/Linux/Windows | btleplug |
| Go | go/ |
macOS/Linux/Windows/embedded | TinyGo BLE |
| Kotlin | kotlin/ |
Android 8.0+ | Android BLE |
About
The EMAY SleepO2 is a $30 continuous pulse oximeter capable of overnight streaming. No public documentation existed for its protocol. We reverse-engineered it and open-source the result so health-app developers, researchers, and tinkerers can stream oxygen data without cracking the spec themselves.
License
MIT
Metadata
Release files for emay-sleepo2 1.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| emay_sleepo2-1.0.6.tar.gz | 14.1 kB | Without provenance | Details for emay_sleepo2-1.0.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| emay_sleepo2-1.0.6-py3-none-any.whl | Python 3 | none | any | Details for emay_sleepo2-1.0.6-py3-none-any.whl |
Total release size: 26.0 kB
Release files / emay_sleepo2-1.0.6.tar.gz
| Download URL | emay_sleepo2-1.0.6.tar.gz |
|---|---|
| Size | 14.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2cab50837fe3470647adca7b132b6edd9998b3596cefd619e1d6687c4562fe34
|
|
BLAKE2b-256 checksum How to use checksums |
e70e5920ffc91211af3512c94625a5ddb50607915085733312d1437e0de3f0ae
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Release files / emay_sleepo2-1.0.6-py3-none-any.whl
| Download URL | emay_sleepo2-1.0.6-py3-none-any.whl |
|---|---|
| Size | 11.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6816a679f591a8fced6cd3c8f9edffbc27a68e88b7f6d223c4ac4dbab026d46f
|
|
BLAKE2b-256 checksum How to use checksums |
53b34f6aa80fd1f5c9474492e5ac5aff9b7f2ed82eab369313079ed045d96cd4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Security for emay-sleepo2 1.0.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.