Skip to content

Commit 93376de

Browse files
committed
updated documentation
1 parent 9aa7f61 commit 93376de

File tree

3 files changed

+77
-11
lines changed

3 files changed

+77
-11
lines changed

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"module": "bmx280_spi",
1212
"justMyCode": true,
1313
"args": [
14-
"--spi", "1",
14+
"--spi", "0",
1515
"--time", "120",
1616
"--pressure", "psi",
1717
"--temp-f",

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@ BMP280 datasheet: https://www.bosch-sensortec.com/media/boschsensortec/downloads
1010

1111
BME280 datasheet: https://www.bosch-sensortec.com/media/boschsensortec/downloads/datasheets/bst-bme280-ds002.pdf
1212

13+
BMP280/BME280 Pinout:
14+
SCL = SCK (SPI Clock)
15+
SDO = MISO (sensor out to board in)
16+
SDA = MOSI (sensir in to board out)
17+
CSB = CS (select)
18+
19+
### Parts:
20+
- BMP280 (Temp and pressure) - https://amzn.to/3YVwblE
21+
- BME280 (Temp, pressure and humidity) - https://amzn.to/3JIxtMr
22+
1323
## Usage:
1424

1525

bmx280_spi/__init__.py

Lines changed: 66 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,79 @@
11
'''
2-
PyPi Package: bmx280_spi
3-
Homepage:
4-
Git:
2+
# BMP280 / BME280 over SPI
53
6-
TODO: Test with traditional SPI CS pins
4+
Homepage: https://www.learningtopi.com/python-modules-applications/bmx280_spi/
75
8-
Description:
9-
Library to configure and collect data from BMP280 / BME280 via SPI. After
10-
testing several python libraries that either didn't support BMP280 device
11-
or simply failed to function, I put together yet another BMP/BME280 library.
6+
BMP280/BME280 python3 driver using the SPI bus to control and read data.
127
8+
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.
139
14-
BMP280/BME280 SPI controller library
15-
BMP280 Pinout:
10+
BMP280 datasheet: https://www.bosch-sensortec.com/media/boschsensortec/downloads/datasheets/bst-bmp280-ds001.pdf
11+
12+
BME280 datasheet: https://www.bosch-sensortec.com/media/boschsensortec/downloads/datasheets/bst-bme280-ds002.pdf
13+
14+
BMP280/BME280 Pinout:
1615
SCL = SCK (SPI Clock)
1716
SDO = MISO (sensor out to board in)
1817
SDA = MOSI (sensir in to board out)
1918
CSB = CS (select)
2019
20+
Parts:
21+
- BMP280 (Temp and pressure) - https://amzn.to/3YVwblE
22+
- BME280 (Temp, pressure and humidity) - https://amzn.to/3JIxtMr
23+
24+
## Usage:
25+
26+
27+
# Import bmx280 SPI class
28+
from bmx280_spi import Bmx280Spi, MODE_NORMAL
29+
30+
# initialize device
31+
# cs_chip and cs_pin from "gpioinfo". gpiod used for platform compatibility.
32+
bmx = Bmx280Spi(spiBus=0, cs_chip=0, cs_pin=26)
33+
bmx.set_power_mode(MODE_NORMAL)
34+
bmx.set_sleep_duration_value(3)
35+
bmx.set_temp_oversample(1)
36+
bmx.set_pressure_oversample(1)
37+
bmx.set_filter(0)
38+
reading = bmx.update_reading() # returns instance of Bmx280Readings
39+
print(reading)
40+
# --or--
41+
print(reading.temp_c, reading.temp_f, reading.pressure_psi)
42+
43+
## Testing
44+
Included in the module is a basic test script that can be executed with the following:
45+
46+
python3 -m dht11_spi [gpio]
47+
48+
Additional test options are available for interval, run time, dht22. Documentation is available using the "--help" option.
49+
50+
### Example Output
51+
52+
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 %
53+
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 %
54+
55+
MIT License
56+
57+
Copyright (c) 2023 LearningToPi
58+
59+
Permission is hereby granted, free of charge, to any person obtaining a copy
60+
of this software and associated documentation files (the "Software"), to deal
61+
in the Software without restriction, including without limitation the rights
62+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
63+
copies of the Software, and to permit persons to whom the Software is
64+
furnished to do so, subject to the following conditions:
65+
66+
The above copyright notice and this permission notice shall be included in all
67+
copies or substantial portions of the Software.
68+
69+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
70+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
71+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
72+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
73+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
74+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
75+
SOFTWARE.
76+
2177
'''
2278
import spidev
2379
import logging_handler

0 commit comments

Comments
 (0)