An open API service indexing awesome lists of open source software.

https://github.com/chakflying/bme-sensors

Rust program reading the BME688 sensor using the BSEC library.
https://github.com/chakflying/bme-sensors

bme688 iot raspberry-pi rust

Last synced: 2 months ago
JSON representation

Rust program reading the BME688 sensor using the BSEC library.

Awesome Lists containing this project

README

        

# BME688 Data Logger

This combines the BSEC library from Bosch and `bme68x-rust` to read and process data from the BME688 sensor, and send it to a graphite server. The project runs on a Raspberry Pi 4B with a armv7l 32-bit OS, with the sensor on a Adafruit breakout board connected with I2C.

## Hardware

- Raspberry Pi 4B
- Adafruit BME688
- STEMMA QT / Qwiic JST SH 4-pin Cable with Premium Female Sockets

## Dependencies

- Bosch BSEC Library `2.2.0`

Download from the [Bosch website](https://www.bosch-sensortec.com/software-tools/software/bme688-software/#Library).

Located in the dowloaded zip archive, `algo/normal_version/bin/RaspberryPi/PiThree_ArmV6/`, copy the files

- `bsec_datatypes.h`,
- `bsec_interface.h`,
- `libalgobsec.a`

into the project folder `lib/`.

## Configuration

The Graphite server location is configured via environment variables. You can also create file `.env` in the project root, and input the graphite server location:

```shell
GRAPHITE_URL=:2003
```

## Usage

Build the program in release mode:

```shell
cargo build --release
```

Then the CLI program can be run in the background with:

```shell
nohup {project directory}/target/release/bme-sensors & disown
```

You can also setup a systemd service such that it runs on startup.

```shell
[Unit]
Description=BME Sensors service
After=network.target
StartLimitIntervalSec=0

[Service]
Type=simple
Restart=always
RestartSec=1
Environment="RUST_LOG=warn"
User=
WorkingDirectory=/
ExecStart=//target/release/bme-sensors

[Install]
WantedBy=multi-user.target
```

Use VictoriaMetrics Agent to buffer data in case of network issues:

```shell
[Unit]
Description=Victoria Metrics Agent service
After=network.target
StartLimitIntervalSec=0

[Service]
Type=simple
Restart=always
RestartSec=1
User=root
WorkingDirectory=/tmp
ExecStart=/usr/local/bin/vmagent -remoteWrite.url=http://:8428/api/v1/write -graphiteListenAddr=:2003

[Install]
WantedBy=multi-user.target
```