Switch Science has released the BME280 temperature / humidity / barometric pressure sensor. Humidity can also be measured compared to the same Bosch BMP180. If you have one BME280, you can use it conveniently as an environmental sensor. Unfortunately, Bosch only publishes C's BME280_driver and [How to use](http://trac.switch-science.com/wiki/ BME280) page and The New Bosch BME280 (Temp, Humidity, BMP) I could only find the sample code of Arduino on my blog. Rewriting with Python for Raspberry Pi is a difficult task, and thankfully Switch Science wrote a Python library in haste.
While looking at the Arduino schematic in How to use, wire the Raspberry Pi 2 as follows. As a result of checking, Vcore and Vio to be wired to 3.3V are connected on the board, so it seems that only one of them is required.
SDI (BME280) -> GPIO2 P03 (Raspberry Pi SDA1)
SCK (BME280) -> GPIO3 P05 (Raspberry Pi SCL1)
GND,SDO (BME280) -> GND P09 (Raspberry Pi)
Vio,CSB (BME280) -> 3.3v P01 (Raspberry Pi)
After wiring the jumper wire, check with i2cdetect. I'm using a 0x76 address.
$ sudo i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- 76 --
You can find sample Python code in the Switch Science BME280 repository. Create an appropriate directory and download it.
$ mkdir ~/python_apps/ss
$ cd !$
$ wget https://raw.githubusercontent.com/SWITCHSCIENCE/BME280/master/Python27/bme280_sample.py
Run the sample code.
$ sudo python bme280_sample.py
temp : 28.18 ℃
pressure : 995.69 hPa
hum : 60.62 %
The following data was acquired.
Recommended Posts