Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: MaikNeubert/bme280
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: rm-hull/bme280
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Able to merge. These branches can be automatically merged.
  • 4 commits
  • 14 files changed
  • 3 contributors

Commits on Dec 22, 2021

  1. Version 0.2.4

    rm-hull committed Dec 22, 2021

    Verified

    This commit was signed with the committer’s verified signature.
    rm-hull Richard Hull
    Copy the full SHA
    8204641 View commit details
  2. Drop support for Python 2.7 (rm-hull#21)

    * drop python 2.7 support
    
    * ci: move to github actions
    
    * update metadata
    
    Co-authored-by: Richard Hull <[email protected]>
    thijstriemstra and rm-hull authored Dec 22, 2021

    Partially verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    We cannot verify signatures from co-authors, and some of the co-authors attributed to this commit require their commits to be signed.
    Copy the full SHA
    6daf914 View commit details

Commits on Dec 23, 2021

  1. fix docs build (rm-hull#23)

    * fix docs build
    
    * tox: add doc target
    
    * fix docstring indentation
    
    * disable unused html_static_path
    
    * add modules
    
    * add py3.11
    
    * ci: test against py3.11
    
    * update ci badge
    thijstriemstra authored Dec 23, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    ddb68b8 View commit details

Commits on Aug 19, 2022

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    426d41b View commit details
Showing with 160 additions and 80 deletions.
  1. +63 −0 .github/workflows/main.yml
  2. +38 −0 .github/workflows/publish-to-pypi.yml
  3. +0 −22 .travis.yml
  4. +4 −0 CHANGES.rst
  5. +1 −1 LICENSE.rst
  6. +11 −18 README.rst
  7. +12 −11 bme280/__init__.py
  8. +4 −4 doc/conf.py
  9. +2 −0 doc/index.rst
  10. +10 −7 setup.py
  11. +2 −7 tests/test_bme280.py
  12. +1 −1 tests/test_const.py
  13. +2 −7 tests/test_reader.py
  14. +10 −2 tox.ini
63 changes: 63 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: RPi.bme280

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
python-minor-version: [6, 7, 8, 9, 10, 11-dev]
name: Python 3.${{ matrix.python-minor-version }}
steps:
- uses: actions/checkout@v2
- name: Setup pip cache
uses: actions/cache@v2
id: pipcache
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.${{ matrix.python-minor-version }}
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Install Python packages
run: pip install --upgrade setuptools pip wheel tox coveralls
- name: Run tests
env:
TOX_ENV: py3${{ matrix.python-minor-version }}
run: |
python_env=$(echo $TOX_ENV | sed -e s/-dev$//)
python -m tox -e ${python_env}
- name: QA
env:
TOX_ENV: qa,doc
run: python -m tox -e $TOX_ENV
- name: Coveralls
run: coveralls --service=github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_FLAG_NAME: ${{ matrix.test-name }}
COVERALLS_PARALLEL: true

coveralls:
name: Coveralls
needs: build
runs-on: ubuntu-latest
container: python:3-slim
steps:
- name: Finished
run: |
pip3 install --upgrade coveralls
coveralls --finish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38 changes: 38 additions & 0 deletions .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Publish Package

on:
push:
branches:
- main

jobs:
build-and-publish:
name: Build and publish Python package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install pypa/build
run: |
python -m pip install --upgrade setuptools pip wheel
python -m pip install build --user
- name: Build a binary wheel and a source tarball
run: python -m build --sdist --wheel --outdir dist/ .
- name: Publish package to test PyPI
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
- name: Publish package to PyPI
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}


22 changes: 0 additions & 22 deletions .travis.yml

This file was deleted.

4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
BME280 ChangeLog
================

0.2.4
-----
* [Bug fix] compensated_readings: make 'timestamp' tz-aware.

0.2.3
-----
* [Bug fix] Format compensated reading timestamp to always include the milliseconds
2 changes: 1 addition & 1 deletion LICENSE.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
MIT License
===========

Copyright (c) 2016 Richard Hull
Copyright (c) 2016-2021 Richard Hull

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
29 changes: 11 additions & 18 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
BME280 Sensor Driver
====================
.. image:: https://travis-ci.org/rm-hull/bme280.svg?branch=master
:target: https://travis-ci.org/rm-hull/bme280
.. image:: https://github.com/rm-hull/bme280/workflows/RPi.bme280/badge.svg?branch=master
:target: https://github.com/rm-hull/bme280/actions?workflow=RPi.bme280

.. image:: https://coveralls.io/repos/github/rm-hull/bme280/badge.svg?branch=master
:target: https://coveralls.io/github/rm-hull/bme280?branch=master
@@ -12,11 +12,11 @@ BME280 Sensor Driver
.. image:: https://img.shields.io/pypi/v/rpi-bme280.svg
:target: https://pypi.python.org/pypi/rpi-bme280

.. image:: https://img.shields.io/maintenance/yes/2020.svg?maxAge=2592000
.. image:: https://img.shields.io/maintenance/yes/2021.svg?maxAge=2592000


Interfacing a Bosch BME280 digital sensor module (capable of sensing
temperature, humidity and pressure) in Python 2 or 3 using I2C on the Raspberry
temperature, humidity and pressure) in Python 3 using I2C on the Raspberry
Pi. The particular kit I bought can be acquired for a few pounds from `eBay
<http://www.ebay.co.uk/itm/311728184519>`_. Further technical details for the
BME280 sensor can be found in the `datasheet
@@ -103,22 +103,15 @@ use 0 for the bus not 1)::

Installing the Python Package
-----------------------------
For python2, from the bash prompt, enter::
From the bash prompt, enter::

$ sudo python setup.py install
$ sudo python3 setup.py install

This will install the Python files in ``/usr/local/lib/python2.7``
making them ready for use in other programs.

Alternatively for python3, type::

$ sudo python3 setup.py install

Cheeseshop install
^^^^^^^^^^^^^^^^^^
PyPi install
^^^^^^^^^^^^
Alternatively, a version on PyPi is available, just do::

$ sudo pip install RPi.bme280
$ sudo pip3 install RPi.bme280

Software Driver - Example Usage
-------------------------------
@@ -163,7 +156,7 @@ This then should print something like::
timestamp=2016-11-18 17:33:28.937863, temp=20.563 °C,
pressure=980.91 hPa, humidity=48.41 % rH)

For a data-logger like application, periodically call ``bme2.sample(bus, address, calibration_params)`` to
For a data-logger like application, periodically call ``bme280.sample(bus, address, calibration_params)`` to
get time-based readings.

See the `weatherstation project <https://github.com/rm-hull/weatherstation>`_ for
@@ -177,7 +170,7 @@ License
-------
The MIT License (MIT)

Copyright (c) 2016-2020 Richard Hull
Copyright (c) 2016-2021 Richard Hull

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
23 changes: 12 additions & 11 deletions bme280/__init__.py
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@
Raspberry Pi BME280 Driver.
"""

__version__ = "0.2.3"
__version__ = "0.2.4"

import datetime
import time
@@ -65,14 +65,14 @@ class compensated_readings(object):
"""
Compensation formulas translated from Appendix A (8.1) of BME280 datasheet:
* Temperature in °C, double precision. Output value of "51.23"
equals 51.23 °C
* Temperature in °C, double precision. Output value of "51.23"
equals 51.23 °C
* Pressure in hPa as double. Output value of "963.862" equals
963.862 hPa
* Pressure in hPa as double. Output value of "963.862" equals
963.862 hPa
* Humidity in %rH as as double. Output value of "46.332" represents
46.332 %rH
* Humidity in %rH as as double. Output value of "46.332" represents
46.332 %rH
"""
def __init__(self, raw_readings, compensation_params):
self._comp = compensation_params
@@ -197,10 +197,11 @@ def sample(bus, address=DEFAULT_PORT, compensation_params=None, sampling=oversam
Primes the sensor for reading (defaut: x1 oversampling), pauses for a set
amount of time so that the reading stabilizes, and then returns a
compensated reading object with the following attributes:
* timestamp (Python's datetime object) when reading was taken.
* temperature, in degrees Celcius.
* humidity, in % relative humidity.
* pressure, in hPa.
* timestamp (Python's ``datetime`` object) when reading was taken
* temperature (in degrees Celcius)
* humidity (in % relative humidity)
* pressure (in hPa)
"""
if compensation_params is None:
compensation_params = __cache_calibration_params(bus, address)
8 changes: 4 additions & 4 deletions doc/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# bme280 documentation build configuration file, created by
@@ -159,7 +159,7 @@
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
# html_static_path = ['_static']

# Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied
@@ -344,5 +344,5 @@
# texinfo_no_detailmenu = False


# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {'https://docs.python.org/2/': None}
# Configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {'https://docs.python.org/3/': None}
2 changes: 2 additions & 0 deletions doc/index.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
.. toctree::
:maxdepth: 2

modules

.. include:: ../README.rst

Indices and tables
17 changes: 10 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
@@ -20,7 +20,6 @@ def _read_version():
needs_pytest = {'pytest', 'test', 'ptr'}.intersection(sys.argv)
pytest_runner = ['pytest-runner'] if needs_pytest else []
test_deps = [
'mock;python_version<"3.3"',
'pytest>=3.1',
'pytest-cov'
]
@@ -42,7 +41,11 @@ def _read_version():
install_requires=["pytz", "smbus2"],
setup_requires=pytest_runner,
tests_require=test_deps,
python_requires=">=3.6, <4",
extras_require={
'docs': [
'sphinx>=1.5.1'
],
'qa': [
'rstcheck',
'flake8'
@@ -51,16 +54,16 @@ def _read_version():
},
classifiers=[
"License :: OSI Approved :: MIT License",
"Development Status :: 4 - Beta",
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Education",
"Intended Audience :: Developers",
"Topic :: Education",
"Topic :: System :: Hardware",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6"
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10"
]
)
9 changes: 2 additions & 7 deletions tests/test_bme280.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2018 Richard Hull
# Copyright (c) 2018-2021 Richard Hull
# See LICENSE.rst for details.


try:
from unittest.mock import Mock, MagicMock
except ImportError:
from mock import Mock, MagicMock # noqa: F401

from unittest.mock import Mock, MagicMock
from datetime import datetime
import bme280
import pytz
2 changes: 1 addition & 1 deletion tests/test_const.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2018 Richard Hull
# Copyright (c) 2018-2021 Richard Hull
# See LICENSE.rst for details.

import bme280.const as c
9 changes: 2 additions & 7 deletions tests/test_reader.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2018 Richard Hull
# Copyright (c) 2018-2021 Richard Hull
# See LICENSE.rst for details.


try:
from unittest.mock import Mock, MagicMock
except ImportError:
from mock import Mock, MagicMock # noqa: F401

from unittest.mock import Mock, MagicMock
from bme280.reader import reader

smbus = Mock(unsafe=True)
12 changes: 10 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Copyright (c) 2018 Richard Hull
# Copyright (c) 2018-2021 Richard Hull
# See LICENSE.rst for details.

[tox]
envlist = py{27,34,35,36,37},qa
envlist = py{36,37,38,39,310,311},qa,doc
skip_missing_interpreters = True

[testenv]
@@ -17,3 +17,11 @@ commands =
flake8
rstcheck README.rst CHANGES.rst CONTRIBUTING.rst
deps = .[qa]

[testenv:doc]
commands =
make linkcheck
sphinx-build -W -b html -d {envtmpdir}/doctrees . {envtmpdir}/html
changedir = doc
allowlist_externals = make
deps = .[docs]