dafvid / micropython-bmp280 Goto Github PK
View Code? Open in Web Editor NEWmodule for the BMP280 sensor
License: MIT License
module for the BMP280 sensor
License: MIT License
following bosch specification (revision 1.26, page 24, section 4.3.1) the chip id is only a single byte
Line 297 in f162a9f
https://www.bosch-sensortec.com/products/environmental-sensors/pressure-sensors/bmp280/#documents
Line 54-55 in bmp280.py is :
_BMP280_OS_MATRIX = [ [BMP280_PRES_OS_1, BMP280_TEMP_OS_1, 7],
But line 315 is:
t_os, p_os, self.read_wait_ms = _BMP280_OS_MATRIX[oss]
t_os and p_os should be swapped. Line 316 and 317 are correct. Bits 7-5 are osrs_t and bits 4-2 are osrs_p according to the datasheet of bmp280.
The following patch should be able to fix this issue:
--- bmp280.py.orig 2022-04-26 06:07:08.000000000 +0800 +++ bmp280.py 2022-05-02 06:43:07.000000000 +0800 @@ -312,11 +312,11 @@ def use_case(self, uc): assert 0 <= uc <= 5 pm, oss, iir, sb = _BMP280_CASE_MATRIX[uc] - t_os, p_os, self.read_wait_ms = _BMP280_OS_MATRIX[oss] + p_os, t_os, self.read_wait_ms = _BMP280_OS_MATRIX[oss] self._write(_BMP280_REGISTER_CONFIG, (iir << 2) + (sb << 5)) self._write(_BMP280_REGISTER_CONTROL, pm + (p_os << 2) + (t_os << 5)) def oversample(self, oss): assert 0 <= oss <= 4 - t_os, p_os, self.read_wait_ms = _BMP280_OS_MATRIX[oss] + p_os, t_os, self.read_wait_ms = _BMP280_OS_MATRIX[oss] self._write_bits(_BMP280_REGISTER_CONTROL, p_os + (t_os << 3), 2)
When I added all the constants from the spec the file grew quite a bit. I'm considering seperating them into a separate file you can use if you need them. This would reduce the file so that it can be more easily used on SoC with restricted storage.
Hallo,
vorab bin Anfänger!, also nehmt mir mir meine Unwissenheit nicht allzu übel.
Erfasse mit einem ESP32 und einem BMP280 die Temperatur. Bin aber nicht zufrieden mit den Meßergebnissen. Nun bich ich auf dieses Programm gestossen.
habe bisher I2C wie folgt aufgerufen:
i2c0_sda = Pin(26)
i2c0_scl = Pin(27)
i2c0 = I2C(0, sda = i2c0_sda, scl = i2c0_scl, freq = 10000)
und den Sensor:
bmp280_i2c = BMP280I2C(0x77, i2c0)
Wenn ich diesen Code aufrufe, erscheint schon bei:
bus = I2C()
eine Fehlermeldung:
TypeError: 'scl' argument required
Wie gesagt Anfänger!!!
Sicherlich muß ich noch Werte für das Argument eingeben, blos welche?
Gruß Klaus
Hi, I get the following error when using the example code in RPi Pico:
Traceback (most recent call last): File "<stdin>", line 10, in <module> File "bmp280.py", line 97, in __init__ File "bmp280.py", line 126, in _read OSError: 5
The bmp280 is visible with i2c.scan()
Also the example code should have
import bmp280
otherwise the variables are not loaded, only the class.
Line 122 in ff13a34
Looking through the code base as I'm looking for a package that does what I expect I saw this line and wondered if it should read:
if use_case is not None:
self.use_case(use_case)
I haven't tested either way yet, that is on the plan for tomorrow...
EDIT:
Apologies I didn't see #3 conversation. Will move to conversation on the PR.
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.