pimoroni / bme280-python Goto Github PK
View Code? Open in Web Editor NEWPython library for the BME280 temperature, pressure and humidity sensor
Home Page: https://shop.pimoroni.com/products/bme280-breakout
License: MIT License
Python library for the BME280 temperature, pressure and humidity sensor
Home Page: https://shop.pimoroni.com/products/bme280-breakout
License: MIT License
Missing ")" @ end of line:
bme280-python/examples/local_altitude.py
Line 33 in 78b7f57
The closing square bracket on line 64 of the install.sh script needs a preceding space.
Done!
./install.sh: line 64: [: missing `]'
Using config.txt in /boot
Hi Team,
I have a basic question.
Do we need to externally connect pull up resistors to establish a I2C communication ?
I see the break out board already having some SMD along with sensor and Diodes..
Are the terminals output points already having the pullup resistors ?
I am using a NXPk66F dev board.
I'm finding that when I'm using the library in forced mode after a number of sensor reads, the Raspberry Pi hangs.
Is there a known issue with repeatedly reading the sensor in forced mode? I'm reading the sensor every minute, but after a while something is locking up the Raspberry Pi.
On Rasbian: 2019-09-26-raspbian-buster-lite
As per install instructions
sudo pip install pimoroni-bme280
git clone https://github.com/pimoroni/bme280-python
cd bme280-python
sudo ./install.sh
Error received:
...
Installing for Python 3..
Traceback (most recent call last):
File "setup.py", line 26, in <module>
from setuptools import setup
ModuleNotFoundError: No module named 'setuptools'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "setup.py", line 28, in <module>
from distutils.core import setup
ModuleNotFoundError: No module named 'distutils.core'
Done!
Hi,
When updating the sensor values the setup
method is called before triggering a measurement when in forced mode, and reading the latest values.
bme280-python/library/bme280/__init__.py
Lines 249 to 255 in 97c80ce
Calling the method with no arguments will overwrite any arguments you may have set previous with the defaults (including setting normal mode, so it looks like the force mode logic in the if block in update_sensor
may never be called) and forces a 0.1s sleep. Is it necessary to call setup
this way every time?
from bme280 import _bme280, CHIP_ID
fails to import _bme280
. The fix is to instantiate the BME280 class and then access _bme280
through that.
Trying to run some examples, but not working real well
pi@Grow4:~/bme280-python/examples $ ls all-values.py dump-calibration.py relative-altitude.py temperature-forced-mode.py compensated-temperature.py local_altitude.py temperature-compare.py pi@Grow4:~/bme280-python/examples $ python compensated-temperature.py Traceback (most recent call last): File "/home/pi/bme280-python/examples/compensated-temperature.py", line 6, in <module> from bme280 import BME280 ImportError: cannot import name 'BME280' from 'bme280' (/usr/local/lib/python3.9/dist-packages/bme280/__init__.py) pi@Grow4:~/bme280-python/examples $ python dump-calibration.py Traceback (most recent call last): File "/home/pi/bme280-python/examples/dump-calibration.py", line 7, in <module> from bme280 import BME280 ImportError: cannot import name 'BME280' from 'bme280' (/usr/local/lib/python3.9/dist-packages/bme280/__init__.py) pi@Grow4:~/bme280-python/examples $ python relative-altitude.py Traceback (most recent call last): File "/home/pi/bme280-python/examples/relative-altitude.py", line 9, in <module> from bme280 import BME280 ImportError: cannot import name 'BME280' from 'bme280' (/usr/local/lib/python3.9/dist-packages/bme280/__init__.py) pi@Grow4:~/bme280-python/examples $
Jeff
Hi Team,
Multiple links from url point to bme680:
Github, and related section Statistics.
Sorry if this is not the best place to raise it.
Thank you!
installed the PIMORONI BME280 breakout on pins 1, 3, 5, 7, 9, on my RaspberryPI-4 however - when I run the allvalues.py example i get the following error:
Ctrl+C to exit
Traceback (most recent call last):
File "/home/pi/BME280 test.py", line 19, in
print('{:05.2f}*C {:05.2f}hPa {:05:2f}%'.format(temperature, pressure, humidity))
ValueError: Invalid format specifier
Would I be able to use this on a different SBC, I have a ROCK 4 C+ and looking to use this in a waveguide dehydrator monitoring project
Took me a while to realise that the I2C interface needed turning on using sudo raspi-config
... worth putting in the readme?
Not submitting this as a PR to the documentation as I'm not confident in it at all, but wanted to capture this atrocity I've just cooked up, to read a BME280 via the Binho Nova host adapter's Python library:
class BinhoSmbusShim:
def __init__(self, host_adapter):
self.binho = host_adapter
def read_i2c_block_data(self, i2c_address, register, length):
return self.binho.i2c.transfer(i2c_address, [register], length)
def write_i2c_block_data(self, i2c_address, register, values):
self.binho.i2c.transfer(i2c_address, [register] + values, 0)
Usage instructions:
binho = binhoHostAdapter()
binho.operationMode = "I2C"
bme280 = BME280(i2c_dev=BinhoSmbusShim(binho))
bme280.setup()
# you can now follow examples/
Fairly confident this glosses over a lot of details (like register width?), but this was enough to get temperature/humidity/pressure out of the sensor so I can carry on with software.
I'm also aware you're no longer stocking Binho Nova, so no worries if you don't want to add in support/documentation for use โ this note is just to capture this info in the public domain for next time I need it ๐
Fresh install of the latest PiOS on a Pi Zero W.
pHat Stack with Breakout Garden Mini i2c SPI and Mini i2c
BME280, RV3028, LTR-599 in the mini i2c BG
0.96 SPI Color LCD in the mini i2c SPI BG
My BME280 breakout is giving me the following error when I run the all-values.py file.
Either from thoony or via command line.
from bme280 import BME280
ImportError: No module named bme280
i2c is enabled and it is detected.
I have run the following.
sudo pip install pimoroni-bme280 smbus
sudo pip3 install pimoroni-bme280 smbus
and also did the following
git clone https://github.com/pimoroni/bme280-python
cd bme280-python
sudo ./install.sh
and rebooted several times.
Tried two different BME280โs, one that was working before I reimaged my SD card, and one new one I just received today.
Both give the above error.
This would allow you to correct the temperature and in turn get more sensible relative humidity values.
please could somone guide me though the procedure on running the python programm all-values.py from the sample programs
bit new to the pi and what sudo etc amd what program i use to run to work the bme280
help gladly taken
Hi there,
Started playing with bme280 - I can't initialise it correctly on my RPI + Breakout Garden + BME280 (and a few others breakout)
#!/usr/bin/env python3
# std lib imports
import os
import logging
import argparse
import sys
import time
# extra imports
try:
from smbus2 import SMBus
except ImportError:
from smbus import SMBus
from bme280 import BME280
# Set logs
logger = logging.getLogger('bme280')
logger.setLevel(logging.INFO)
# Log format
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
# Console Handler
ch = logging.StreamHandler()
ch.setLevel(logging.INFO)
ch.setFormatter(formatter)
logger.addHandler(ch)
def temperature():
# Initialise the BME280
bus = SMBus(1)
bme280 = BME280(i2c_dev=bus)
temperature = bme280.get_temperature()
pressure = bme280.get_pressure()
humidity = bme280.get_humidity()
print('{:05.2f}*C {:05.2f}hPa {:05.2f}%'.format(temperature, pressure, humidity))
time.sleep(1)
def main():
"""
parser = argparse.ArgumentParser()
parser.add_argument('--url', default="http://localhost", help="url")
args = parser.parse_args()
"""
temperature()
if __name__ == "__main__":
main()
Leads to:
Traceback (most recent call last):
File "/home/pi/airborne/airborne/environment.py", line 52, in <module>
main()
File "/home/pi/airborne/airborne/environment.py", line 49, in main
temperature()
File "/home/pi/airborne/airborne/environment.py", line 36, in temperature
temperature = bme280.get_temperature()
File "/home/pi/.local/lib/python3.9/site-packages/bme280/__init__.py", line 264, in get_temperature
self.update_sensor()
File "/home/pi/.local/lib/python3.9/site-packages/bme280/__init__.py", line 250, in update_sensor
self.setup()
File "/home/pi/.local/lib/python3.9/site-packages/bme280/__init__.py", line 228, in setup
raise RuntimeError("Unable to find bme280 on 0x{:02x}, CHIP_ID returned {:02x}".format(self._i2c_addr, chip.id))
RuntimeError: Unable to find bme280 on 0x76, CHIP_ID returned 58
whereas it's on 0X76:
i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- --
10: 10 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- 38 -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- 76 --
Any changes on the chip that should be updated in the lib ?
Thanks
Hi,
I noticed that update_sensor()
appears to be called twice in a row when calling get_altitude
. First self.update_sensor()
is called followed by self.get_pressure()
,
bme280-python/library/bme280/__init__.py
Lines 275 to 279 in 97c80ce
However, the first line of get_pressure
is also self.update_sensor()
,
bme280-python/library/bme280/__init__.py
Lines 267 to 269 in 97c80ce
So, if we unrolled this we would get something like
self.update_sensor()
self.update_sensor()
pressure = self.pressure
I'm happy to open a PR changing this if it isn't intended.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.