Giter Site home page Giter Site logo

sht4x's Introduction

Sensirion SHT4x Driver for Embedded HAL

A platform agnostic device driver for the Sensirion SHT4x temperature and humidity sensor family. It is based on embedded-hal traits and works in no_std environments.

In theory, it supports all of the sensor family's devices but has only been tested with the SHT40-AD1B so far.

Build Status crates.io Documentation

Features

  • Blocking operation
  • Async operation if the async feature is specified
  • Uses the latest embedded_hal 1.0.0
  • Supports all commands specified in the datasheet
  • Explicitly borrows DelayNs for command execution so that it could be shared (among multiple sensors)
  • Could be instantiated with the alternative I2C address for the SHT40-BD1B
  • Uses fixed-point arithmetics for converting raw sensor data into measurements in SI units
    • Based on I16F16 from the fixed crate
    • Allows conversion to floating-point values, if needed
    • Convenience methods for fixed-point conversions to milli degree Celsius or milli percent relative humidity which are commonly used by drivers for other humidity and temperature sensors from Sensirion
  • Optional support for defmt

Example

use embedded_hal::delay::DelayNs;
use sht4x::Sht4x;
// Device-specific use declarations.

let mut delay = // Device-specific initialization of delay.
let i2c = // Device-specific initialization of I2C peripheral.
let mut sht40 = Sht4x::new(i2c);

let serial = sht40.serial_number(&mut delay);
defmt::info!("serial number: {}", serial);

let measurement = sht40.measure(Precision::Low, &mut delay);
defmt::info!("measurement: {}", &measurement);

if let Ok(measurement) = measurement {
    // Convert temperature measurand into different formats for further
    // processing.
    let int: i32 = measurement.temperature_milli_celsius();
    let fixed: I16F16 = measurement.temperature_celsius();
    let float: f32 = measurement.temperature_celsius().to_num();
}

Related Work

sensor-temp-humidity-sht40 is another driver for this sensor family.

License

Licensed under either of

at your discretion.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

sht4x's People

Contributors

sirhcel avatar bbustin avatar madmo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.