Python module to use the SPI bus to read bmp280/bme280 sensors
Project description
BMP280 / BME280 over SPI
Homepage: https://www.learningtopi.com/python-modules-applications/bmx280_spi/
BMP280/BME280 python3 driver using the SPI bus to control and read data.
General GPIO Pin (NOT an SPI CS) used to pull the signal pin low. The SPI CS pins do not operate properly with the SPI kernel driver.
BMP280 datasheet: https://www.bosch-sensortec.com/media/boschsensortec/downloads/datasheets/bst-bmp280-ds001.pdf
BME280 datasheet: https://www.bosch-sensortec.com/media/boschsensortec/downloads/datasheets/bst-bme280-ds002.pdf
BMP280/BME280 Pinout: SCL = SCK (SPI Clock) SDO = MISO (sensor out to board in) SDA = MOSI (sensir in to board out) CSB = CS (select)
Parts:
- BMP280 (Temp and pressure) - https://amzn.to/3YVwblE
- BME280 (Temp, pressure and humidity) - https://amzn.to/3JIxtMr
Usage:
# Import bmx280 SPI class
from bmx280_spi import Bmx280Spi, MODE_NORMAL
# initialize device
# cs_chip and cs_pin from "gpioinfo". gpiod used for platform compatibility.
bmx = Bmx280Spi(spiBus=0, cs_chip=0, cs_pin=26)
bmx.set_power_mode(MODE_NORMAL)
bmx.set_sleep_duration_value(3)
bmx.set_temp_oversample(1)
bmx.set_pressure_oversample(1)
bmx.set_filter(0)
reading = bmx.update_reading() # returns instance of Bmx280Readings
print(reading)
# --or--
print(reading.temp_c, reading.temp_f, reading.pressure_psi)
Testing
Included in the module is a basic test script that can be executed with the following:
python3 -m dht11_spi [gpio]
Additional test options are available for interval, run time, dht22. Documentation is available using the "--help" option.
Example Output
DHT11: 105/105 (100.0%): Temps (min/avg/max): 73.54/75.2/75.34 deg FHumidity (min/avg/max): 17.0/17.0/17.0 %
DHT22: 112/112 (100.0%): Temps (min/avg/max): 74.48/74.51/74.66 deg FHumidity (min/avg/max): 14.1/14.21/16.0 %
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file bmx280_spi-1.0.4.tar.gz
.
File metadata
- Download URL: bmx280_spi-1.0.4.tar.gz
- Upload date:
- Size: 13.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f792f9f78a6cd3d4791899c718831522c5d6d250af4edb72a7baa8d53d22f59e |
|
MD5 | 9146c9eb5e77f257dd73cf1aba1a9b3a |
|
BLAKE2b-256 | 449ad3ae557b4f3c5178bc0a5fd030b5309f49085c20dff0cd3fca371e9c7c5b |
File details
Details for the file bmx280_spi-1.0.4-py3-none-any.whl
.
File metadata
- Download URL: bmx280_spi-1.0.4-py3-none-any.whl
- Upload date:
- Size: 14.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 770859e80874a669357a079ab0adbbcf64fbe20cd4095dfd8b11cb19a0b32483 |
|
MD5 | dd18a0a4ab16b872ef3877cf623d1b95 |
|
BLAKE2b-256 | 6c3611a59c45e478ae5b26be368e91f510a95daf781779694cd6596a0b6fc13f |