https://github.com/kelnos/sen0177-rs
Rust library for reading air quality data from the SEN0177 sensor
https://github.com/kelnos/sen0177-rs
air-quality air-quality-sensor raspberry-pi rust sen0177 sensor
Last synced: about 2 months ago
JSON representation
Rust library for reading air quality data from the SEN0177 sensor
- Host: GitHub
- URL: https://github.com/kelnos/sen0177-rs
- Owner: kelnos
- License: apache-2.0
- Created: 2020-08-25T03:15:20.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2024-01-10T01:46:38.000Z (over 1 year ago)
- Last Synced: 2025-04-15T00:44:16.770Z (about 2 months ago)
- Topics: air-quality, air-quality-sensor, raspberry-pi, rust, sen0177, sensor
- Language: Rust
- Homepage:
- Size: 42 KB
- Stars: 6
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# sen0177
[![crates.io][crates-shield]][crates-url]
[![Documentation][docs-shield]][docs-url]
[![Apache 2.0][license-shield]][license-url]
[![Build Status][build-shield]][build-url]`sen0177` is a Rust library/crate that reads air quality data from the
SEN0177 air quality sensor.## Prerequisites
* You've connected the sensor to a UART or I2C bus on your device, and
your device has a crate implementing the applicable [`embedded_hal`]
traits.
* For a UART-based sensor, you've configured the UART for 9600 baud, 8
data bits, no parity, 1 stop bit, and no flow control.## Setup
Include the following in your `Cargo.toml` file:
```toml
[dependencies]
sen0177 = "0.6"
```If you are in a `no_std` environment, you may depend on this crate like so:
```toml
[dependencies]
sen0177 = { version = "0.6", default-features = false }
```## Usage
See the `examples/` directory.
Note that `linux-embedded-hal` does not (as of this writing) have a
release supporting the stable 1.x series of `embedded-hal`, so the Linux
example has to pull `linux-embedded-hal` from GitHub.Note that the serial device occasionally returns bad data. If you
receive [`SensorError::BadMagic`] or [`SensorError::ChecksumMismatch`]
from the [`AirQualitySensor::read`] call, a second try will usually succeed.## Gotchas
### Raspberry Pi
If you're using this with a Raspberry Pi, note that by default the
primary UART is set up as a Linux serial console. You will need
to disable that (by editing `/boot/cmdline.txt`) before this will work.
Instead of using a specifiy TTY device node, you should use
`/dev/serial0`, which is a symlink to the proper device.Alternatively, you can use the second UART, but you'll need to load an
overlay to assign it to GPIO pins. See [UART
configuration](https://www.raspberrypi.org/documentation/configuration/uart.md)
and the [UART-related
overlays](https://www.raspberrypi.org/documentation/configuration/uart.md)
for more information.[crates-shield]: https://img.shields.io/crates/v/sen0177.svg
[crates-url]: https://crates.io/crates/sen0177
[docs-shield]: https://docs.rs/sen0177/badge.svg
[docs-url]: https://docs.rs/sen0177
[license-shield]: https://img.shields.io/crates/l/sen0177.svg
[license-url]: https://github.com/kelnos/sen0177-rs/blob/maim/LICENSE
[build-shield]: https://img.shields.io/github/workflow/status/kelnos/sen0177-rs/CI
[build-url]: https://github.com/kelnos/sen0177-rs/actions