Skip to main content

pamoja_sensors/
lib.rs

1#![no_std]
2
3//! Concrete sensor drivers for the pamoja SDK.
4//!
5//! [`pamoja-gpio`](https://docs.rs/pamoja-gpio) builds the address and mode bytes a
6//! controller puts on an I2C or SPI bus; this crate is the layer just above it, the
7//! per-part knowledge that turns the raw register bytes a specific sensor returns
8//! into a physical reading. Each module is one named part: it knows that part's
9//! register map, builds the bytes that configure it, and decodes what it sends back,
10//! applying the exact conversion the manufacturer's datasheet specifies.
11//!
12//! Like the rest of the SDK's hardware crates, these are the decode-and-configure
13//! half ahead of the actual bus driver: pure logic with no I/O, so the same code runs
14//! on a microcontroller and in a test. A caller pairs a module here with whatever
15//! performs the transfers (a `pamoja-gpio` Linux backend, an `embedded-hal` bus, or a
16//! simulator) and gets calibrated readings without re-deriving a datasheet.
17//!
18//! The conversions are anchored to each datasheet's own reference values, since they
19//! are where memory-driven bugs hide. The BME280 compensation is ported from Bosch's
20//! published reference code and cross-checked against its floating-point form; the
21//! DS18B20 decode is pinned to the datasheet's temperature/data table and its CRC to
22//! the Maxim 1-Wire polynomial; the INA219 math is checked against the datasheet's
23//! worked design example; the ADS1115 full-scale conversion against its per-gain LSB
24//! sizes. The parts added after those follow the same rule: the BMP280 port of Bosch's
25//! integer compensation against its floating-point form; the SHT3x and SCD4x
26//! conversions against the endpoints of their linear formulas, their command words
27//! against the tables, and their CRC-8 against Sensirion's published check value; the
28//! TMP117 decode against its temperature data table; the HDC1080 equations against
29//! their endpoints and identification registers; the OPT3001 lux decode against its
30//! table of worked result words and its full-scale table; the INA226 math against the
31//! datasheet's calibration example.
32//!
33//! - [`bme280`] - Bosch temperature, pressure, and humidity over I2C or SPI.
34//! - [`bmp280`] - Bosch pressure and temperature, the BME280 without humidity.
35//! - [`ds18b20`] - Maxim 1-Wire digital thermometer, with CRC-checked scratchpads.
36//! - [`hdc1080`] - Texas Instruments low-power I2C humidity and temperature sensor.
37//! - [`ina219`] - Texas Instruments high-side current, voltage, and power monitor.
38//! - [`ina226`] - Texas Instruments high- or low-side current, voltage, and power
39//!   monitor with an alert pin.
40//! - [`ads1115`] - Texas Instruments 16-bit I2C analog-to-digital converter.
41//! - [`opt3001`] - Texas Instruments ambient light sensor with a human-eye response.
42//! - [`scd4x`] - Sensirion SCD40 and SCD41 photoacoustic CO2 sensors with humidity and
43//!   temperature, over I2C.
44//! - [`sht3x`] - Sensirion humidity and temperature sensor, with CRC-checked words.
45//! - [`tmp117`] - Texas Instruments ±0.1 °C digital temperature sensor with alert limits.
46
47pub mod ads1115;
48pub mod bme280;
49pub mod bmp280;
50pub mod ds18b20;
51pub mod hdc1080;
52pub mod ina219;
53pub mod ina226;
54pub mod opt3001;
55pub mod scd4x;
56pub mod sht3x;
57pub mod tmp117;
58
59mod error;
60
61pub use error::SensorError;