BMP/BME280 Temperature Sensors
These pages describe how to wire a BME/BMP 280 sensor to your Raspberry Pi
Updated
BME280 Temperature and Humidity Sensor has been ordered : Ebay Link. The best part of this is Google Translater says 14 Apr 2020 12:27am arrives in Australia. So fingers crossed it will be delivered soon.
Published by Martin on May 13, 2020
So tomorrows job try and solder the header onto that circuit board. Going to be a challenge with my Eyes at the minute. !!
Diagrams
This was the 1st advert of what I was trying to get.

This was how the 1st one actually arrived 6 weeks later.
The unfortunate part was after soldering it all together the Humidity portion of the sensor did not work so it was useless. I photographed and sent an email back to the Ebay dude and got a replacement many weeks later.
Off to a good start. Soldered the Connector and plugged it back into the Pi like this :
Picture borrowed from https://projects.raspberrypi.org/en/projects/build-your-own-weather-station/2
| Pi GPIO | BME280 |
|---|---|
| Pin 17 (3V3) | Vin |
| Pin 9 (Gnd) | Gnd |
| Pin 3 (SDA) | SDA (SDI) |
| Pin 5 (SCL) | SCL (SCK) |
Some other breakout boards may have other pins (such as SDO or CSB), but those are not generally needed.
Ran the i2detect ( i2cdetect -y 1 ) software and NO response. ( Refer here for more info : https://learn.adafruit.com/adafruits-raspberry-pi-lesson-4-gpio-setup/configuring-i2c )
Took the sensor back to the Soldering Iron and had another go. This time, when back into the Pi, I got a reply for Port 0x76 and we were away.
My first idea was to write a simple series of tests for each sensor and get them to log to the screen. Then advance the program to send it to a message queue and finally to a Mysql Server.
You can follow my setup for a Raspberry Pi : Here
And the required files startup : Here
Lets start with the libraries required for this device
pip3 install bme280
pip3 install smbus2
Install this program in a directory in the pi home directory checking the Address first ( i2cdetect -y 1 ) and replacing the 0x76 with the correct address
mkdir weather-station
cd weather-station
vi basic-bme280.py
import bme280
import smbus2
from time import sleep
port = 1
address = 0x76
bus = smbus2.SMBus(port)
bme280.load_calibration_params(bus,address)
while True:
bme280_data = bme280.sample(bus,address)
humidity = bme280_data.humidity
pressure = bme280_data.pressure
ambient_temperature = bme280_data.temperature
print(humidity, pressure, ambient_temperature)
sleep(1)
Not being a Python expert by a long shot it was good to be able to copy and paste and get this to work. A giant warning here EACH I2C connector could be on a different address. An Adafruit device is generally 0x77 and my cheap one is 0x76 !!
Run the program like this :
python3 basic-bme280.py
and you should get some results like this:
0.0 1008.2088350496889 21.576728023588657
0.0 1008.2611868818934 21.576728023588657
0.0 1008.2263109122915 21.571638555784013
0.0 1008.2263109122915 21.571638555784013
0.0 1008.2437863923265 21.566549088270403
0.0 1008.2611868818934 21.576728023588657
0.0 1008.2001352220503 21.571638555784013
To Stop the output you will need to press Ctrl-C
Thats the bme280 temperature sensor running.
BUT guess what.. After all this work the Humidity part of the sensor is actually broken and constantly read 0.0%. So off to ebay and this time ordered from a local supplier.. Now I sit and wait again.

The new sensor is here and installed. ( Same PINOUT as the first version but doesn’t have the extra 2 ). Its installed in the Breadboard and now produces :
43.189229089901986 1008.2961374224739 21.566549088270403
43.19473548213366 1008.2961374224739 21.566549088270403
43.20007743008741 1008.2700356488718 21.55128068747581
43.20024186547079 1008.2437863923265 21.566549088270403
43.18917441436585 1008.287436795908 21.561459621047835
43.19457123606487 1008.2176859231896 21.55128068747581
Splitting this up its
43.19% Humidity,
1008.217 hPa,
21.5 Degrees C
Working Perfectly Now.
The Case
Found a nice little case for the BME280 Temperature Sensor / Humidity and Pressure in Bunnings of all places. This little box had lots of different designs, was 30 cms from the case and ended up around 4 cms and painted.

This is mounted in its separate case so its not influenced by the Temperature of the Pi.

This is what it looks like inside and I silicone up the hole to stop the ants again. Will see if it gets too warm.

This is the conduit breakout box that I built. Its got a number of holes drilled in it for the air flow to pass through, but covered it in cloth to avoid the ants and spiders from getting in.
