#i2c-sensors #sensirion #i2c

no-std sensirion-i2c

Common functionality for I2C based sensors from Sensirion

5 releases (3 breaking)

0.4.0 Jul 17, 2024
0.3.0 Feb 16, 2024
0.2.0 Nov 29, 2022
0.1.1 Sep 2, 2020
0.1.0 Aug 21, 2020

#1804 in Embedded development

Download history 186/week @ 2025-08-11 136/week @ 2025-08-18 378/week @ 2025-08-25 330/week @ 2025-09-01 262/week @ 2025-09-08 280/week @ 2025-09-15 283/week @ 2025-09-22 603/week @ 2025-09-29 223/week @ 2025-10-06 364/week @ 2025-10-13 577/week @ 2025-10-20 244/week @ 2025-10-27 185/week @ 2025-11-03 200/week @ 2025-11-10 243/week @ 2025-11-17 148/week @ 2025-11-24

791 downloads per month
Used in 14 crates

BSD-3-Clause

12KB
182 lines

Library with common functionality for I2C based sensors from Sensirion, based on the embedded-hal traits.

Usage

CRC8 calculation / validation

use sensirion_i2c::crc8;

let data = [0xbe, 0xef];
let crc = crc8::calculate(&data);

let data = [0xbe, 0xef, crc];
assert_eq!(Ok(()), crc8::validate(&data));

I2C

The I2C helpers work with any embedded_hal::i2c implementation.

use embedded_hal_mock::eh1::i2c::{Mock as I2cMock, Transaction as I2cTransaction};
use sensirion_i2c::i2c;

let expectations = [I2cTransaction::write(0x12, vec![0x34, 0x56])];
let mut i2c_mock = I2cMock::new(&expectations);
i2c::write_command_u16(&mut i2c_mock, 0x12, 0x3456);
i2c_mock.done();

embedded-hal-async

The i2c_async module provides versions of the I2C helpers in this crate that use the embedded-hal-async crate, rather than the blocking I2C traits from embedded-hal.

This module is only available when the embedded-hal-async Cargo feature is enabled.


sensirion-i2c-rs

Crates.io Version Crates.io Downloads No Std

Rust library with common functionality for I2C based sensors from Sensirion.

Dependencies

~61KB