Comments on: Raspberry Pi: BME280 Temperature, Humidity and Pressure Sensor (Python) https://randomnerdtutorials.com/raspberry-pi-bme280-python/ Learn ESP8266, ESP32, Arduino, and Raspberry Pi Thu, 27 Feb 2025 12:27:47 +0000 hourly 1 https://wordpress.org/?v=6.8.2 By: Sara Santos https://randomnerdtutorials.com/raspberry-pi-bme280-python/#comment-1011558 Thu, 27 Feb 2025 12:27:47 +0000 https://randomnerdtutorials.com/?p=134464#comment-1011558 In reply to JD.

That’s great.
Regards,
Sara

]]>
By: JD https://randomnerdtutorials.com/raspberry-pi-bme280-python/#comment-1011077 Wed, 26 Feb 2025 01:33:22 +0000 https://randomnerdtutorials.com/?p=134464#comment-1011077 In reply to Sara Santos.

Thanks for posting! I just got an RPI 5 (I haven’t messed with my older Raspberry PI’s in ages) so it was fun using this sensor and refreshing my memory of using I2C in Python.

]]>
By: Jan https://randomnerdtutorials.com/raspberry-pi-bme280-python/#comment-982899 Wed, 13 Nov 2024 09:52:38 +0000 https://randomnerdtutorials.com/?p=134464#comment-982899 Thank you for this tutorial. I am planning to go through it and install a humidity & temperature sensor in my house very soon. Being a complete beginner, I would like to ask for some guidance on how to be able to switch a fan on or off automatically based on the readings of the sensor.
Thanks in advance for any help.

]]>
By: Tom https://randomnerdtutorials.com/raspberry-pi-bme280-python/#comment-871643 Sun, 12 Nov 2023 15:42:16 +0000 https://randomnerdtutorials.com/?p=134464#comment-871643 Hi Sara,
I can get the BME280 to work fine on ESP32, but when I try to run it on my Pi3 I get the error
“Traceback (most recent call last):
File “”, line 12, in
AttributeError: module ‘bme280’ has no attribute ‘populate_calibration_data’
I hoping you can offer some insight as to why.

Tom

]]>
By: JB https://randomnerdtutorials.com/raspberry-pi-bme280-python/#comment-871199 Fri, 10 Nov 2023 13:34:56 +0000 https://randomnerdtutorials.com/?p=134464#comment-871199 Hi.
adafruit drivers work pretty well too
with this
sudo pip3 install adafruit-circuitpython-bme280

#!/usr/bin/python3

import board
import time

import adafruit_bme280.advanced as adafruit_bme280

Create sensor object, using the board’s default I2C bus.

i2c = board.I2C() # uses board.SCL and board.SDA
#bme280 = adafruit_bme280.Adafruit_BME280_I2C(i2c)
bme280 = adafruit_bme280.Adafruit_BME280_I2C(i2c, address=0x76)

bme280.mode = adafruit_bme280.MODE_NORMAL
bme280.standby_period = adafruit_bme280.STANDBY_TC_500
bme280.iir_filter = adafruit_bme280.IIR_FILTER_X16
bme280.overscan_pressure = adafruit_bme280.OVERSCAN_X16
bme280.overscan_humidity = adafruit_bme280.OVERSCAN_X1
bme280.overscan_temperature = adafruit_bme280.OVERSCAN_X2
time.sleep(35/1000)

print(bme280.temperature)
print(bme280.relative_humidity)
print(bme280.pressure)

]]>
By: JB https://randomnerdtutorials.com/raspberry-pi-bme280-python/#comment-867462 Mon, 23 Oct 2023 12:22:32 +0000 https://randomnerdtutorials.com/?p=134464#comment-867462 Hi.
Remember to change the Quotation mark,
as they are not shown correctly here.
by the way raspberry pi zero 2w runs fine on raspberry os bookworm 64 bit.

]]>
By: JB https://randomnerdtutorials.com/raspberry-pi-bme280-python/#comment-867454 Mon, 23 Oct 2023 11:37:00 +0000 https://randomnerdtutorials.com/?p=134464#comment-867454 In reply to JB.

I got my raspberrypi set up as an access point with this.
Just find the mac address of your pi with ifconfig, under wlan0 ether and change this to yours.
sudo nmcli con modify TEST-AP wifi.cloned-mac-address d8:3a:dd:32:7b:cb

#sudo nmcli con delete TEST-AP
sudo nmcli con add type wifi ifname wlan0 mode ap con-name TEST-AP ssid TEST autoconnect true
sudo nmcli con modify TEST-AP wifi.band bg
sudo nmcli con modify TEST-AP wifi.channel 7
sudo nmcli con modify TEST-AP wifi.cloned-mac-address d8:3a:dd:32:7b:cb
sudo nmcli con modify TEST-AP wifi-sec.key-mgmt wpa-psk
sudo nmcli con modify TEST-AP wifi-sec.proto rsn
sudo nmcli con modify TEST-AP wifi-sec.group ccmp
sudo nmcli con modify TEST-AP wifi-sec.pairwise ccmp
sudo nmcli con modify TEST-AP wifi-sec.psk “yourpassword”
sudo nmcli con modify TEST-AP ipv4.method shared ipv4.address 192.168.4.1/24
sudo nmcli con modify TEST-AP ipv6.method disabled
sudo nmcli con up TEST-AP

]]>
By: JB https://randomnerdtutorials.com/raspberry-pi-bme280-python/#comment-865821 Sun, 15 Oct 2023 09:24:45 +0000 https://randomnerdtutorials.com/?p=134464#comment-865821 The way to set up a static ip address has also changed,
but this should work.
sudo nmcli con mod “your ssid” ipv4.addresses “192.168.0.250/24” ipv4.gateway “192.168.0.1” ipv4.dns “8.8.8.8” ipv4.method manual
sudo systemctl restart NetworkManager

Does anyone here know how to
Create wireless access point on the new bookworm,
unfortunately that has also changed

]]>
By: JB https://randomnerdtutorials.com/raspberry-pi-bme280-python/#comment-865820 Sun, 15 Oct 2023 09:12:31 +0000 https://randomnerdtutorials.com/?p=134464#comment-865820 on the new raspberry os bookworm you have to use

sudo pip install –upgrade pip –break-system-packages
sudo pip install RPI.BME280 –break-system-packages

otherwise you will get this message
error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
python3-xyz, where xyz is the package you are trying to
install

If you wish to install a non-Debian-packaged Python package,
create a virtual environment using python3 -m venv path/to/venv.
Then use path/to/venv/bin/python and path/to/venv/bin/pip. Spouse
make sure you have python3-full installed.

For more information visit http://rptl.io/venv

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing –break-system-packages.

]]>
By: Marc Draco https://randomnerdtutorials.com/raspberry-pi-bme280-python/#comment-863724 Tue, 03 Oct 2023 17:28:44 +0000 https://randomnerdtutorials.com/?p=134464#comment-863724 In reply to Sara Santos.

This extends even to the 680s which are also sold on the “black” market.

They identify themselves over IIC as the correct part but give out readings that are clearly not even close to what they should be. I got about 20 of the BME280s and not a single one worked as it should. Took me a couple of goes with the (more expensive) 680 to find on that was the real deal.

It’s not surprising really – considering that these Chinese fake manufacturers have even cloned relative cheap ICs like the XR2206 – and that goes back years. You can tell you have a fake as the real one operates all the way to its specified maximum voltage whereas the fakes work up to around 12V (far more than most stuff works at these days) but above that they go wonky.

I suspect the others are just whatever they can get cheap and then they remove the marking and replace it with markings from the more expensive chip. That’ll teach me to use DigiKey or Mouser rather than some fly-by-night seller on eBay based in China. 😉

]]>