Code Monkey home page Code Monkey logo

sgp30-rs's Introduction

Rust SGP30 Driver

Build status Crates.io Version Crates.io Downloads No Std

This is a platform agnostic Rust driver for the Sensirion SGP30 gas sensor, based on the embedded-hal or embedded-hal-async traits.

Docs: https://docs.rs/sgp30

The Device

The Sensirion SGP30 is a low-power gas sensor for indoor air quality applications with good long-term stability. It has an I²C interface with TVOC (Total Volatile Organic Compounds) and CO₂ equivalent signals.

Datasheet: https://www.sensirion.com/file/datasheet_sgp30

Status

  • Measure air quality
  • Get and set baseline
  • Set humidity
  • Get feature set
  • Get raw signals
  • Get serial number
  • Support on-chip self-test
  • CRC checks
  • Docs
  • [`embedded-hal-async] support

License

Licensed under either of

Contributing

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.

sgp30-rs's People

Contributors

dbrgn avatar dependabot[bot] avatar hawkw avatar rnestler avatar slim-bean avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

sgp30-rs's Issues

ESP32 & spg30-rs

Hi,
how to use spg30-rs with https://github.com/esp-rs/esp-idf-template ?

There is no device: /dev/i2c-1

cargo generate --git https://github.com/esp-rs/esp-idf-template cargo
cd projectname
cargo add sgp30
cargo add esp-idf-hal
. ~/export-esp.sh
cargo check


use esp_idf_hal::blocking::delay::DelayMs;
use hal::Delay;
use sgp30::Measurement;

fn main() {
    // It is necessary to call this function once. Otherwise some patches to the runtime
    // implemented by esp-idf-sys might not link properly. See https://github.com/esp-rs/esp-idf-template/issues/71
    esp_idf_svc::sys::link_patches();

    // Bind the log crate to the ESP Logging facilities
    esp_idf_svc::log::EspLogger::initialize_default();


loop {
    let measurement: Measurement = sgp.measure().unwrap();
    println!("CO₂eq parts per million: {}", measurement.co2eq_ppm);
    println!("TVOC parts per billion: {}", measurement.tvoc_ppb);
    Delay.delay_ms(1000u16 - 12);
}

}


error[E0433]: failed to resolve: could not find `blocking` in `esp_idf_hal`
 --> src/main.rs:1:18
  |
1 | use esp_idf_hal::blocking::delay::DelayMs;
  |                  ^^^^^^^^ could not find `blocking` in `esp_idf_hal`

error[E0432]: unresolved import `hal`
 --> src/main.rs:2:5
  |
2 | use hal::Delay;
  |     ^^^ help: a similar path exists: `esp_idf_svc::hal`

error[E0425]: cannot find value `sgp` in this scope
  --> src/main.rs:15:36
   |
15 |     let measurement: Measurement = sgp.measure().unwrap();
   |                                    ^^^ not found in this scope

Some errors have detailed explanations: E0425, E0432, E0433.
For more information about an error, try `rustc --explain E0425`.
error: could not compile `esp32-spg30` (bin "esp32-spg30") due to 3 previous errors

thanks

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.