Team11 temperature and humidity sensor
Jump to navigation
Jump to search
Contents
SENS BME680 Temperature, Humidity, Air Pressure & Gas Sensor
The SENS BME680 is a temperature, humidity, air pressure and gas (air quality) sensor. The breakout board is equipped with a 3.3V regulator and I2C as well as SPI digital interface. This lets you use it safely with any kind of microcontroller with 3.3V-5V power or logic.
- Temperature - operation range from -40 to 85°C with an accuracy of ±1°C (full accuracy from 0 to 65°C)
- Humidity - operation range from 0 to 100% with an accuracy of ±3%
- Air pressure - operation range from 300 to 1100 hPa with an accuracy of ±1 hPa
- Air quality - a MOX (Metal-oxide) sensor that detects VOCs (like ethanol and carbon monoxide) in the air
Technical Specifications
The SENS BME680 is an I2C and SPI sensor. That means it uses the two I2C/SPI data/clock wires available on most microcontrollers and can share those pins with other sensors as long as they don't have an address collision.
Pinout
- VCC – power pin which can take 3-5VDC and safely converts it down using the built-in voltage regulator
- GND
- SCL - SCL pin for I2C communication / SCK pin for SPI communication
- SDA - SDA pin for I2C communication / SDI (MOSI) pin for SPI communication
- SDO - SDO (MISO) pin for SPI communication
- CS - Chip select pin for SPI communication
Advantages and Disadvantages
Advantages
- Best alternative to the DHT22 sensor which is a popular standard. However, it would be too large/clunky as a smartwatch component
- I2C and SPI bus interface
- 4-in-1 digital sensor
Disadvantages
- Size 30 x 14 x 10mm
- Relatively heavy (10g) in comparison to similar sensors
How to get it to work
Wiring with an ESP8266
- Connect VCC to the power supply (3-5V is fine) - 3V
- Connect GND to common power/data ground - G
- Connect SCL to the I2C clock SCL pin on your microcontroller - GPIO5 (D1)
- Connect SDA to the I2C data SDA pin on your microcontroller - GPIO4 (D2)
Required Library
- Download and save following code as bme680.py
- upload library to your microcontroller
Code Example
1 # import modules
2 from machine import Pin, I2C
3 from time import sleep
4 from bme680 import *
5
6 # Create sensor object, communicating over the board's default I2C bus
7 i2c = I2C(scl=Pin(5), sda=Pin(4))
8 bme = BME680_I2C(i2c=i2c)
9
10 # Print out temperature, humidity, air pressure and air quality values
11 while True:
12 temp = str(round(bme.temperature, 2)) + ' °C'
13 hum = str(round(bme.humidity, 2)) + ' %'
14 pres = str(round(bme.pressure, 2)) + ' hPa'
15 gas = str(round(bme.gas/1000, 2)) + ' KOhms'
16
17 print('Temperature:', temp)
18 print('Humidity:', hum)
19 print('Pressure:', pres)
20 print('Gas:', gas)
21 print('----------')
22
23 sleep(5)
Instructional Video