Skip to content

Commit

Permalink
Add support for BME680. #682
Browse files Browse the repository at this point in the history
  • Loading branch information
theyosh committed Apr 1, 2022
1 parent 3fd5fa3 commit 1780187
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 0 deletions.
20 changes: 20 additions & 0 deletions docs/_hardware/bme680_sensor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
title: BME680 sensor
categories: [Hardware, Sensor]
tags: [sensor, temperature, humidity, pressure, altitude]

image:
path: /assets/img/bme680.webp
src: /assets/img/bme680.webp
alt: "BME680 sensor header image"

device_types: [temperature, humidity, pressure, altitude]
device_address: "[I2C Address],[I2C Bus](/TerrariumPI/hardware#i2c-bus) <br />Ex: `0x3f,3`"
device_url: https://shop.pimoroni.com/products/bme680-breakout?variant=12491552129107
---

## Information

The BME680 is the first gas sensor that integrates high-linearity and high-accuracy gas, pressure, humidity and temperature sensors. It is especially developed for mobile applications and wearables where size and low power consumption are critical requirements. The BME680 guarantees - depending on the specific operating mode - optimized consumption, long-term stability and high EMC robustness. In order to measure air quality for personal wellbeing the gas sensor within the BME680 can detect a broad range of gases such as volatile organic compounds (VOC).

{% include_relative _sensor_detail.md %}
2 changes: 2 additions & 0 deletions docs/_tabs/hardware.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ By default there is only 1 I2C bus available. [But it is possible to add more I2

For `[I2C Address]` you can use the number shown in the i2cdetect. Adding '**0x**' in front is allowed. So either **3c**, **3c,1**, **0x3c** and **0x3c,1** are valid and the same I2C addresses.

The `[I2C Bus number]` is optional and can be omitted. The default value is 1.

Run the command `i2cdetect -y 1` in order to see what is connected to your I2C bus. A correct working I2C bus should produce the following outcome:

```console
Expand Down
Binary file added docs/assets/img/bme680.webp
Binary file not shown.
29 changes: 29 additions & 0 deletions hardware/sensor/bme680_sensor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from . import terrariumI2CSensor

# pip install bme680
import bme680

class terrariumBME680Sensor(terrariumI2CSensor):
HARDWARE = 'bme680'
TYPES = ['temperature','humidity','altitude','pressure']
NAME = 'BME680 sensor'

def _get_data(self):
data = None
with self._open_hardware() as i2c_bus:
sensor = bme680.BME680(self.device[0], i2c_bus)

if sensor.get_sensor_data():
data = {}
data['temperature'] = sensor.data.temperature
data['humidity'] = sensor.data.humidity
data['pressure'] = sensor.data.pressure
# What to do with this data...
data['gas'] = sensor.data.gas_resistance

# https://github.com/avislab/sensorstest/blob/master/BME280/BME280.py#L176
data['altitude'] = data['pressure'] / 101325.0
data['altitude'] = 1 - pow(data['altitude'], 0.19029)
data['altitude'] = round(44330.0 * data['altitude'], 3)

return data
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ simple-pid==1.0.1
sparkfun-qwiic-relay==0.0.2
sensirion_i2c_driver==1.0.0
sensirion_i2c_sht==1.0.0
bme680==1.1.1

# Webcam packages
Pillow==9.0.1
Expand Down

0 comments on commit 1780187

Please sign in to comment.