circuitpython-fake-bme280 1.1__tar.gz → 1.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. {circuitpython_fake_bme280-1.1 → circuitpython_fake_bme280-1.2}/PKG-INFO +1 -1
  2. {circuitpython_fake_bme280-1.1 → circuitpython_fake_bme280-1.2}/circuitpython_fake_bme280.egg-info/PKG-INFO +1 -1
  3. {circuitpython_fake_bme280-1.1 → circuitpython_fake_bme280-1.2}/circuitpython_fake_bme280.egg-info/SOURCES.txt +2 -0
  4. circuitpython_fake_bme280-1.2/examples/fake_bme280_advanced.py +49 -0
  5. circuitpython_fake_bme280-1.2/fake_bme280/advanced.py +269 -0
  6. {circuitpython_fake_bme280-1.1 → circuitpython_fake_bme280-1.2}/pyproject.toml +1 -1
  7. {circuitpython_fake_bme280-1.1 → circuitpython_fake_bme280-1.2}/.github/PULL_REQUEST_TEMPLATE/adafruit_circuitpython_pr.md +0 -0
  8. {circuitpython_fake_bme280-1.1 → circuitpython_fake_bme280-1.2}/.github/workflows/build.yml +0 -0
  9. {circuitpython_fake_bme280-1.1 → circuitpython_fake_bme280-1.2}/.github/workflows/failure-help-text.yml +0 -0
  10. {circuitpython_fake_bme280-1.1 → circuitpython_fake_bme280-1.2}/.github/workflows/release_gh.yml +0 -0
  11. {circuitpython_fake_bme280-1.1 → circuitpython_fake_bme280-1.2}/.github/workflows/release_pypi.yml +0 -0
  12. {circuitpython_fake_bme280-1.1 → circuitpython_fake_bme280-1.2}/.gitignore +0 -0
  13. {circuitpython_fake_bme280-1.1 → circuitpython_fake_bme280-1.2}/.pre-commit-config.yaml +0 -0
  14. {circuitpython_fake_bme280-1.1 → circuitpython_fake_bme280-1.2}/.pylintrc +0 -0
  15. {circuitpython_fake_bme280-1.1 → circuitpython_fake_bme280-1.2}/.readthedocs.yaml +0 -0
  16. {circuitpython_fake_bme280-1.1 → circuitpython_fake_bme280-1.2}/LICENSE +0 -0
  17. {circuitpython_fake_bme280-1.1 → circuitpython_fake_bme280-1.2}/LICENSES/CC-BY-4.0.txt +0 -0
  18. {circuitpython_fake_bme280-1.1 → circuitpython_fake_bme280-1.2}/LICENSES/MIT.txt +0 -0
  19. {circuitpython_fake_bme280-1.1 → circuitpython_fake_bme280-1.2}/LICENSES/Unlicense.txt +0 -0
  20. {circuitpython_fake_bme280-1.1 → circuitpython_fake_bme280-1.2}/README.rst +0 -0
  21. {circuitpython_fake_bme280-1.1 → circuitpython_fake_bme280-1.2}/README.rst.license +0 -0
  22. {circuitpython_fake_bme280-1.1 → circuitpython_fake_bme280-1.2}/circuitpython_fake_bme280.egg-info/dependency_links.txt +0 -0
  23. {circuitpython_fake_bme280-1.1 → circuitpython_fake_bme280-1.2}/circuitpython_fake_bme280.egg-info/requires.txt +0 -0
  24. {circuitpython_fake_bme280-1.1 → circuitpython_fake_bme280-1.2}/circuitpython_fake_bme280.egg-info/top_level.txt +0 -0
  25. {circuitpython_fake_bme280-1.1 → circuitpython_fake_bme280-1.2}/docs/_static/favicon.ico +0 -0
  26. {circuitpython_fake_bme280-1.1 → circuitpython_fake_bme280-1.2}/docs/_static/favicon.ico.license +0 -0
  27. {circuitpython_fake_bme280-1.1 → circuitpython_fake_bme280-1.2}/docs/api.rst +0 -0
  28. {circuitpython_fake_bme280-1.1 → circuitpython_fake_bme280-1.2}/docs/api.rst.license +0 -0
  29. {circuitpython_fake_bme280-1.1 → circuitpython_fake_bme280-1.2}/docs/conf.py +0 -0
  30. {circuitpython_fake_bme280-1.1 → circuitpython_fake_bme280-1.2}/docs/examples.rst +0 -0
  31. {circuitpython_fake_bme280-1.1 → circuitpython_fake_bme280-1.2}/docs/examples.rst.license +0 -0
  32. {circuitpython_fake_bme280-1.1 → circuitpython_fake_bme280-1.2}/docs/index.rst +0 -0
  33. {circuitpython_fake_bme280-1.1 → circuitpython_fake_bme280-1.2}/docs/index.rst.license +0 -0
  34. {circuitpython_fake_bme280-1.1 → circuitpython_fake_bme280-1.2}/docs/requirements.txt +0 -0
  35. {circuitpython_fake_bme280-1.1 → circuitpython_fake_bme280-1.2}/examples/fake_bme280_simpletest.py +0 -0
  36. {circuitpython_fake_bme280-1.1 → circuitpython_fake_bme280-1.2}/fake_bme280/__init__.py +0 -0
  37. {circuitpython_fake_bme280-1.1 → circuitpython_fake_bme280-1.2}/fake_bme280/basic.py +0 -0
  38. {circuitpython_fake_bme280-1.1 → circuitpython_fake_bme280-1.2}/fake_bme280/protocol.py +0 -0
  39. {circuitpython_fake_bme280-1.1 → circuitpython_fake_bme280-1.2}/optional_requirements.txt +0 -0
  40. {circuitpython_fake_bme280-1.1 → circuitpython_fake_bme280-1.2}/requirements.txt +0 -0
  41. {circuitpython_fake_bme280-1.1 → circuitpython_fake_bme280-1.2}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: circuitpython-fake-bme280
3
- Version: 1.1
3
+ Version: 1.2
4
4
  Summary: BME280 Driver for CircuitPython used for testing functionality with no hardware attached
5
5
  Author-email: Adafruit Industries <circuitpython@adafruit.com>
6
6
  License-Expression: MIT
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: circuitpython-fake-bme280
3
- Version: 1.1
3
+ Version: 1.2
4
4
  Summary: BME280 Driver for CircuitPython used for testing functionality with no hardware attached
5
5
  Author-email: Adafruit Industries <circuitpython@adafruit.com>
6
6
  License-Expression: MIT
@@ -31,7 +31,9 @@ docs/index.rst.license
31
31
  docs/requirements.txt
32
32
  docs/_static/favicon.ico
33
33
  docs/_static/favicon.ico.license
34
+ examples/fake_bme280_advanced.py
34
35
  examples/fake_bme280_simpletest.py
35
36
  fake_bme280/__init__.py
37
+ fake_bme280/advanced.py
36
38
  fake_bme280/basic.py
37
39
  fake_bme280/protocol.py
@@ -0,0 +1,49 @@
1
+ # SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
2
+ # SPDX-License-Identifier: MIT
3
+
4
+ """
5
+ Example showing how the BME280 library can be used to set the various
6
+ parameters supported by the sensor.
7
+ Refer to the BME280 datasheet to understand what these parameters do
8
+
9
+ NOTE: This is a mock. The settings exposed here are simply stored and read back.
10
+ """
11
+
12
+ import time
13
+ import board
14
+ from fake_bme280 import advanced as adafruit_bme280
15
+
16
+ # Create sensor object, using the board's default I2C bus.
17
+ i2c = board.I2C() # uses board.SCL and board.SDA
18
+ # i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller
19
+ # Return random plausible readings with no network access or configuration.
20
+ bme280 = adafruit_bme280.Adafruit_BME280_I2C(i2c, use_openweather=False)
21
+ # OR fetch live data from the OpenWeatherMap API (requires settings.toml/.env)
22
+ # bme280 = adafruit_bme280.Adafruit_BME280_I2C(i2c, use_openweather=True)
23
+
24
+ # Configure the sensor with non-default settings and store in the `bme280` object
25
+ bme280.sea_level_pressure = 1013.25
26
+ bme280.mode = adafruit_bme280.MODE_NORMAL
27
+ bme280.standby_period = adafruit_bme280.STANDBY_TC_500
28
+ bme280.iir_filter = adafruit_bme280.IIR_FILTER_X16
29
+ bme280.overscan_pressure = adafruit_bme280.OVERSCAN_X16
30
+ bme280.overscan_humidity = adafruit_bme280.OVERSCAN_X1
31
+ bme280.overscan_temperature = adafruit_bme280.OVERSCAN_X2
32
+
33
+ # Print out the settings to confirm storage in the `bme280` object
34
+ print(f"Mode: {bme280.mode}")
35
+ print(f"Standby Period: {bme280.standby_period}")
36
+ print(f"IIR Filter: {bme280.iir_filter}")
37
+ print(f"Overscan Pressure: {bme280.overscan_pressure}")
38
+ print(f"Overscan Humidity: {bme280.overscan_humidity}")
39
+ print(f"Overscan Temperature: {bme280.overscan_temperature}")
40
+
41
+ # The sensor will need a moment to gather initial readings
42
+ time.sleep(1)
43
+
44
+ while True:
45
+ print(f"\nTemperature: {bme280.temperature:0.1f} C")
46
+ print(f"Humidity: {bme280.relative_humidity:0.1f} %")
47
+ print(f"Pressure: {bme280.pressure:0.1f} hPa")
48
+ print(f"Altitude = {bme280.altitude:0.2f} meters")
49
+ time.sleep(2)
@@ -0,0 +1,269 @@
1
+ # SPDX-FileCopyrightText: 2017 ladyada for Adafruit Industries
2
+ #
3
+ # SPDX-License-Identifier: MIT
4
+
5
+ """
6
+ `fake_bme280.advanced`
7
+ =========================================================================================
8
+
9
+ CircuitPython driver from BME280 Temperature, Humidity and Barometric
10
+ Pressure sensor
11
+
12
+ NOTE: This is a mock. The settings exposed here are simply stored and read back.
13
+
14
+ * Author(s): ladyada, Jose David M.
15
+
16
+ Implementation Notes
17
+ --------------------
18
+
19
+ **Hardware:**
20
+
21
+ * `Adafruit BME280 Temperature, Humidity and Barometric Pressure sensor
22
+ <https://www.adafruit.com/product/2652>`_ (Product ID: 2652)
23
+
24
+
25
+ **Software and Dependencies:**
26
+
27
+ * Adafruit CircuitPython firmware for the supported boards:
28
+ https://circuitpython.org/downloads
29
+ """
30
+
31
+ from micropython import const
32
+
33
+ from fake_bme280.basic import Adafruit_BME280
34
+ from fake_bme280.protocol import I2C_Impl
35
+
36
+ try:
37
+ import typing # pylint: disable=unused-import
38
+
39
+ from busio import I2C
40
+ except ImportError:
41
+ pass
42
+
43
+ __version__ = "1.2"
44
+ __repo__ = "https://github.com/brentru/CircuitPython_Fake_BME280.git"
45
+
46
+ # I2C ADDRESS/BITS/SETTINGS
47
+ # -----------------------------------------------------------------------
48
+ _BME280_ADDRESS = const(0x77)
49
+
50
+ """iir_filter values"""
51
+ IIR_FILTER_DISABLE = const(0)
52
+ IIR_FILTER_X2 = const(0x01)
53
+ IIR_FILTER_X4 = const(0x02)
54
+ IIR_FILTER_X8 = const(0x03)
55
+ IIR_FILTER_X16 = const(0x04)
56
+
57
+ _BME280_IIR_FILTERS = (
58
+ IIR_FILTER_DISABLE,
59
+ IIR_FILTER_X2,
60
+ IIR_FILTER_X4,
61
+ IIR_FILTER_X8,
62
+ IIR_FILTER_X16,
63
+ )
64
+
65
+ """overscan values for temperature, pressure, and humidity"""
66
+ OVERSCAN_DISABLE = const(0x00)
67
+ OVERSCAN_X1 = const(0x01)
68
+ OVERSCAN_X2 = const(0x02)
69
+ OVERSCAN_X4 = const(0x03)
70
+ OVERSCAN_X8 = const(0x04)
71
+ OVERSCAN_X16 = const(0x05)
72
+
73
+ _BME280_OVERSCANS = {
74
+ OVERSCAN_DISABLE: 0,
75
+ OVERSCAN_X1: 1,
76
+ OVERSCAN_X2: 2,
77
+ OVERSCAN_X4: 4,
78
+ OVERSCAN_X8: 8,
79
+ OVERSCAN_X16: 16,
80
+ }
81
+
82
+ """mode values"""
83
+ MODE_SLEEP = const(0x00)
84
+ MODE_FORCE = const(0x01)
85
+ MODE_NORMAL = const(0x03)
86
+
87
+ _BME280_MODES = (MODE_SLEEP, MODE_FORCE, MODE_NORMAL)
88
+ """
89
+ standby timeconstant values
90
+ TC_X[_Y] where X=milliseconds and Y=tenths of a millisecond
91
+ """
92
+ STANDBY_TC_0_5 = const(0x00) # 0.5ms
93
+ STANDBY_TC_10 = const(0x06) # 10ms
94
+ STANDBY_TC_20 = const(0x07) # 20ms
95
+ STANDBY_TC_62_5 = const(0x01) # 62.5ms
96
+ STANDBY_TC_125 = const(0x02) # 125ms
97
+ STANDBY_TC_250 = const(0x03) # 250ms
98
+ STANDBY_TC_500 = const(0x04) # 500ms
99
+ STANDBY_TC_1000 = const(0x05) # 1000ms
100
+
101
+ _BME280_STANDBY_TCS = (
102
+ STANDBY_TC_0_5,
103
+ STANDBY_TC_10,
104
+ STANDBY_TC_20,
105
+ STANDBY_TC_62_5,
106
+ STANDBY_TC_125,
107
+ STANDBY_TC_250,
108
+ STANDBY_TC_500,
109
+ STANDBY_TC_1000,
110
+ )
111
+
112
+
113
+ class Adafruit_BME280_Advanced(Adafruit_BME280):
114
+ """Driver from BME280 Temperature, Humidity and Barometric Pressure sensor
115
+
116
+ .. note::
117
+ This is a mock. The settings exposed here are simply stored and read
118
+ back - nothing is written to a real device.
119
+
120
+ """
121
+
122
+ @property
123
+ def standby_period(self) -> int:
124
+ """
125
+ Control the inactive period when in Normal mode
126
+ Allowed standby periods are the constants STANDBY_TC_*
127
+ """
128
+ return self._t_standby
129
+
130
+ @standby_period.setter
131
+ def standby_period(self, value: int) -> None:
132
+ if not value in _BME280_STANDBY_TCS:
133
+ raise ValueError(f"Standby Period '{value}' not supported")
134
+ self._t_standby = value
135
+
136
+ @property
137
+ def overscan_humidity(self) -> int:
138
+ """
139
+ Humidity Oversampling
140
+ Allowed values are the constants OVERSCAN_*
141
+ """
142
+ return self._overscan_humidity
143
+
144
+ @overscan_humidity.setter
145
+ def overscan_humidity(self, value: int) -> None:
146
+ if not value in _BME280_OVERSCANS:
147
+ raise ValueError(f"Overscan value '{value}' not supported")
148
+ self._overscan_humidity = value
149
+
150
+ @property
151
+ def overscan_temperature(self) -> int:
152
+ """
153
+ Temperature Oversampling
154
+ Allowed values are the constants OVERSCAN_*
155
+ """
156
+ return self._overscan_temperature
157
+
158
+ @overscan_temperature.setter
159
+ def overscan_temperature(self, value: int) -> None:
160
+ if not value in _BME280_OVERSCANS:
161
+ raise ValueError(f"Overscan value '{value}' not supported")
162
+ self._overscan_temperature = value
163
+
164
+ @property
165
+ def overscan_pressure(self) -> int:
166
+ """
167
+ Pressure Oversampling
168
+ Allowed values are the constants OVERSCAN_*
169
+ """
170
+ return self._overscan_pressure
171
+
172
+ @overscan_pressure.setter
173
+ def overscan_pressure(self, value: int) -> None:
174
+ if not value in _BME280_OVERSCANS:
175
+ raise ValueError(f"Overscan value '{value}' not supported")
176
+ self._overscan_pressure = value
177
+
178
+ @property
179
+ def iir_filter(self) -> int:
180
+ """
181
+ Controls the time constant of the IIR filter
182
+ Allowed values are the constants IIR_FILTER_*
183
+ """
184
+ return self._iir_filter
185
+
186
+ @iir_filter.setter
187
+ def iir_filter(self, value: int) -> None:
188
+ if not value in _BME280_IIR_FILTERS:
189
+ raise ValueError(f"IIR Filter '{value}' not supported")
190
+ self._iir_filter = value
191
+
192
+ @property
193
+ def measurement_time_typical(self) -> float:
194
+ """Typical time in milliseconds required to complete a measurement in normal mode"""
195
+ meas_time_ms = 1.0
196
+ if self.overscan_temperature != OVERSCAN_DISABLE:
197
+ meas_time_ms += 2 * _BME280_OVERSCANS.get(self.overscan_temperature)
198
+ if self.overscan_pressure != OVERSCAN_DISABLE:
199
+ meas_time_ms += 2 * _BME280_OVERSCANS.get(self.overscan_pressure) + 0.5
200
+ if self.overscan_humidity != OVERSCAN_DISABLE:
201
+ meas_time_ms += 2 * _BME280_OVERSCANS.get(self.overscan_humidity) + 0.5
202
+ return meas_time_ms
203
+
204
+ @property
205
+ def measurement_time_max(self) -> float:
206
+ """Maximum time in milliseconds required to complete a measurement in normal mode"""
207
+ meas_time_ms = 1.25
208
+ if self.overscan_temperature != OVERSCAN_DISABLE:
209
+ meas_time_ms += 2.3 * _BME280_OVERSCANS.get(self.overscan_temperature)
210
+ if self.overscan_pressure != OVERSCAN_DISABLE:
211
+ meas_time_ms += 2.3 * _BME280_OVERSCANS.get(self.overscan_pressure) + 0.575
212
+ if self.overscan_humidity != OVERSCAN_DISABLE:
213
+ meas_time_ms += 2.3 * _BME280_OVERSCANS.get(self.overscan_humidity) + 0.575
214
+ return meas_time_ms
215
+
216
+
217
+ class Adafruit_BME280_I2C(Adafruit_BME280_Advanced):
218
+ """Driver for BME280 connected over I2C
219
+
220
+ :param ~busio.I2C i2c: The I2C bus the BME280 is connected to.
221
+ :param int address: I2C device address. Defaults to :const:`0x77`.
222
+ but another address can be passed in as an argument
223
+
224
+ .. note::
225
+ The operational range of the BMP280 is 300-1100 hPa.
226
+ Pressure measurements outside this range may not be as accurate.
227
+
228
+ **Quickstart: Importing and using the BME280**
229
+
230
+ Here is an example of using the :class:`Adafruit_BME280_I2C`.
231
+ First you will need to import the libraries to use the sensor
232
+
233
+ .. code-block:: python
234
+
235
+ import board
236
+ import fake_bme280.advanced as adafruit_bme280
237
+
238
+ Once this is done you can define your `board.I2C` object and define your sensor object
239
+
240
+ .. code-block:: python
241
+
242
+ i2c = board.I2C() # uses board.SCL and board.SDA
243
+ bme280 = adafruit_bme280.Adafruit_BME280_I2C(i2c)
244
+
245
+ You need to setup the pressure at sea level
246
+
247
+ .. code-block:: python
248
+
249
+ bme280.sea_level_pressure = 1013.25
250
+
251
+ Now you have access to the :attr:`temperature`, :attr:`relative_humidity`
252
+ :attr:`pressure` and :attr:`altitude` attributes
253
+
254
+ .. code-block:: python
255
+
256
+ temperature = bme280.temperature
257
+ relative_humidity = bme280.relative_humidity
258
+ pressure = bme280.pressure
259
+ altitude = bme280.altitude
260
+
261
+ """
262
+
263
+ def __init__(
264
+ self,
265
+ i2c: I2C,
266
+ address: int = _BME280_ADDRESS,
267
+ use_openweather: bool = True,
268
+ ) -> None:
269
+ super().__init__(I2C_Impl(i2c, address), use_openweather=use_openweather)
@@ -13,7 +13,7 @@ requires = [
13
13
  [project]
14
14
  name = "circuitpython-fake-bme280"
15
15
  description = "BME280 Driver for CircuitPython used for testing functionality with no hardware attached"
16
- version = "1.1"
16
+ version = "1.2"
17
17
  readme = "README.rst"
18
18
  authors = [
19
19
  {name = "Adafruit Industries", email = "circuitpython@adafruit.com"}