Skip to content

Commit bcf2c73

Browse files
author
Paul Beech
committed
Initial commit
0 parents  commit bcf2c73

50 files changed

Lines changed: 2866 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto

.gitignore

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
build/
2+
_build/
3+
*.o
4+
*.so
5+
*.a
6+
*.py[cod]
7+
*.egg-info
8+
dist/
9+
__pycache__
10+
.DS_Store
11+
*.deb
12+
*.dsc
13+
*.build
14+
*.changes
15+
*.orig.*
16+
packaging/*tar.xz
17+
library/debian/
18+
.coverage
19+
.pytest_cache
20+
.tox
21+
.vscode/

.stickler.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
linters:
3+
flake8:
4+
python: 3
5+
max-line-length: 160

.travis.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
language: python
2+
sudo: false
3+
cache: pip
4+
5+
git:
6+
submodules: true
7+
8+
matrix:
9+
include:
10+
- python: "2.7"
11+
env: TOXENV=py27
12+
- python: "3.5"
13+
env: TOXENV=py35
14+
15+
install:
16+
- pip install --ignore-installed --upgrade setuptools pip tox coveralls
17+
18+
script:
19+
- cd library
20+
- tox -vv
21+
22+
after_success: if [ "$TOXENV" == "py35" ]; then coveralls; fi
23+
24+
notifications:
25+
email: false

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 Paul Beech
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
LIBRARY_VERSION=$(shell grep version library/setup.cfg | awk -F" = " '{print $$2}')
2+
LIBRARY_NAME=$(shell grep name library/setup.cfg | awk -F" = " '{print $$2}')
3+
4+
.PHONY: usage install uninstall
5+
usage:
6+
@echo "Library: ${LIBRARY_NAME}"
7+
@echo "Version: ${LIBRARY_VERSION}\n"
8+
@echo "Usage: make <target>, where target is one of:\n"
9+
@echo "install: install the library locally from source"
10+
@echo "uninstall: uninstall the local library"
11+
@echo "check: peform basic integrity checks on the codebase"
12+
@echo "python-readme: generate library/README.rst from README.md"
13+
@echo "python-wheels: build python .whl files for distribution"
14+
@echo "python-sdist: build python source distribution"
15+
@echo "python-clean: clean python build and dist directories"
16+
@echo "python-dist: build all python distribution files"
17+
@echo "python-testdeploy: build all and deploy to test PyPi"
18+
@echo "tag: tag the repository with the current version"
19+
20+
install:
21+
./install.sh
22+
23+
uninstall:
24+
./uninstall.sh
25+
26+
check:
27+
@echo "Checking for trailing whitespace"
28+
@! grep -IUrn --color "[[:blank:]]$$" --exclude-dir=sphinx --exclude-dir=.tox --exclude-dir=.git --exclude=PKG-INFO
29+
@echo "Checking for DOS line-endings"
30+
@! grep -IUrn --color "" --exclude-dir=sphinx --exclude-dir=.tox --exclude-dir=.git --exclude=Makefile
31+
@echo "Checking library/CHANGELOG.txt"
32+
@cat library/CHANGELOG.txt | grep ^${LIBRARY_VERSION}
33+
@echo "Checking library/${LIBRARY_NAME}/__init__.py"
34+
@cat library/${LIBRARY_NAME}/__init__.py | grep "^__version__ = '${LIBRARY_VERSION}'"
35+
36+
tag:
37+
git tag -a "v${LIBRARY_VERSION}" -m "Version ${LIBRARY_VERSION}"
38+
39+
python-readme: library/README.rst
40+
41+
python-license: library/LICENSE.txt
42+
43+
library/README.rst: README.md library/CHANGELOG.txt
44+
pandoc --from=markdown --to=rst -o library/README.rst README.md
45+
echo "" >> library/README.rst
46+
cat library/CHANGELOG.txt >> library/README.rst
47+
48+
library/LICENSE.txt: LICENSE
49+
cp LICENSE library/LICENSE.txt
50+
51+
python-wheels: python-readme python-license
52+
cd library; python3 setup.py bdist_wheel
53+
cd library; python setup.py bdist_wheel
54+
55+
python-sdist: python-readme python-license
56+
cd library; python setup.py sdist
57+
58+
python-clean:
59+
-rm -r library/dist
60+
-rm -r library/build
61+
-rm -r library/*.egg-info
62+
63+
python-dist: python-clean python-wheels python-sdist
64+
ls library/dist
65+
66+
python-testdeploy: python-dist
67+
twine upload --repository-url https://test.pypi.org/legacy/ library/dist/*
68+
69+
python-deploy: check python-dist
70+
twine upload library/dist/*

README.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Enviro+
2+
3+
Designed for environmental monitoring, Enviro+ lets you measure air quality (pollutant gases and particulates), temperature, pressure, humidity, light, and noise level. Learn more - https://shop.pimoroni.com/products/enviro-plus
4+
5+
[![Build Status](https://travis-ci.com/pimoroni/enviroplus-python.svg?branch=master)](https://travis-ci.com/pimoroni/enviroplus-python)
6+
[![Coverage Status](https://coveralls.io/repos/github/pimoroni/enviroplus-python/badge.svg?branch=master)](https://coveralls.io/github/pimoroni/enviroplus-python?branch=master)
7+
[![PyPi Package](https://img.shields.io/pypi/v/enviroplus.svg)](https://pypi.python.org/pypi/enviroplus)
8+
[![Python Versions](https://img.shields.io/pypi/pyversions/enviroplus.svg)](https://pypi.python.org/pypi/enviroplus)
9+
10+
# Installing
11+
12+
You're best using the "One-line" install method if you want all of the UART serial configuration for the PMS5003 particulate matter sensor to run automatically.
13+
14+
## One-line (Installs from GitHub)
15+
16+
```
17+
curl -sSL https://get.pimoroni.com/enviroplus | bash
18+
```
19+
20+
**Note** report issues with one-line installer here: https://github.com/pimoroni/get
21+
22+
## Or... Install and configure dependencies from GitHub:
23+
24+
* `git clone https://github.com/pimoroni/enviroplus-python`
25+
* `cd enviroplus-python`
26+
* `sudo ./install.sh`
27+
28+
**Note** Raspbian Lite users may first need to install git: `sudo apt install git`
29+
30+
## Or... Install from PyPi and configure manually:
31+
32+
* Run `sudo pip install enviroplus`
33+
34+
**Note** this wont perform any of the required configuration changes on your Pi, you may additionally need to:
35+
36+
* Enable i2c: `raspi-config nonint do_i2c 0`
37+
* Enable SPI: `raspi-config nonint do_spi 0`
38+
39+
And if you're using a PMS5003 sensor you will need to:
40+
41+
* Enable serial: `raspi-config nonint set_config_var enable_uart 1 /boot/config.txt`
42+
* Disable serial terminal: `sudo raspi-config nonint do_serial 1`
43+
* Add `dtoverlay=pi3-miniuart-bt` to your `/boot/config.txt`
44+
45+
And install additional dependencies:
46+
47+
```
48+
sudo apt install python-numpy python-smbus python-pil python-setuptools
49+
```
50+
51+
## Help & Support
52+
53+
* GPIO Pinout - https://pinout.xyz/pinout/enviro_plus
54+
* Support forums - http://forums.pimoroni.com/c/support
55+
* Discord - https://discord.gg/hr93ByC

examples/adc.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env python3
2+
3+
import time
4+
from enviroplus import gas
5+
import logging
6+
7+
logging.basicConfig(
8+
format='%(asctime)s.%(msecs)03d %(levelname)-8s %(message)s',
9+
level=logging.INFO,
10+
datefmt='%Y-%m-%d %H:%M:%S')
11+
12+
logging.info("""adc.py - Print readings from the MICS6814 Gas sensor.
13+
14+
Press Ctrl+C to exit!
15+
16+
""")
17+
18+
gas.enable_adc()
19+
gas.set_adc_gain(4.096)
20+
21+
try:
22+
while True:
23+
readings = gas.read_all()
24+
logging.info(readings)
25+
time.sleep(1.0)
26+
except KeyboardInterrupt:
27+
pass

0 commit comments

Comments
 (0)