Skip to content

Commit d4db415

Browse files
authored
Project metadata, refactoring, and adjustments to the README (#2)
## About This patch intends to bring in a first iteration on matters enumerated within GH-1. It does not change anything on the program's behaviour, it only adjusts its layout, improves documentation, and adds a project metadata file which will make it possible to install the program as a package using `pip install`. ## Details - Chore: Add project metadata and boilerplate - Refactoring: Improve modularization and invocation semantics - Improve README: Layout and wording
2 parents aee99c2 + 0048c04 commit d4db415

File tree

6 files changed

+426
-154
lines changed

6 files changed

+426
-154
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.idea
2+
.venv*
3+
.coverage
4+
coverage.xml
5+
*.egg-info

CHANGES.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Changes for temp-matrix
2+
3+
## Unreleased
4+
5+
## v0.0.1 - 2024-04-14
6+
- Make it work, and add documentation.

README.md

Lines changed: 49 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,77 @@
1+
# temp-matrix
2+
Temperature sensor matrix using Raspberry Pi, DS18B20, MQTT, Kotori DAQ,
3+
and Grafana. For bee hive monitoring.
4+
15
| View from outside | View from inside (sensor tip details) |
26
|:----:|:----:|
37
| ![Außen](https://community.hiveeyes.org/uploads/default/optimized/2X/f/f59f0149306b811f793627ec956c3e43c3758e51_2_334x500.jpeg) | ![Innen](https://community.hiveeyes.org/uploads/default/optimized/2X/1/10f98dd272bd95940b311e22ef756114bd4efa04_2_333x500.jpeg) |
48

5-
# temp-matrix
6-
temperature matrix based on raspberry pi, python, 5x6 ds18b20, and grafana
79

8-
for development details see: [https://community.hiveeyes.org/t/laborprotokoll-4x5-temp-matrix-mit-ds18b20/5102/14](https://community.hiveeyes.org/t/laborprotokoll-4x5-temp-matrix-mit-ds18b20/5102/14)
10+
Lab protocol and development details:
11+
https://community.hiveeyes.org/t/laborprotokoll-4x5-temp-matrix-mit-ds18b20/5102
12+
13+
14+
## What's Inside
15+
* README.md - this file
16+
* LICENSE
17+
* temp-matrix_5x6.py - sensor reading and data logging to hiveeyes
18+
* temp-matrix_5x6-grafana_desktop.json - description of [Grafana Dashboard](https://swarm.hiveeyes.org/grafana/d/T49wHSaIk/mois-ex-wtf-test-ds18b20-5x6-temp-matrix-svg-pixmap?orgId=2&from=1712771622514&to=1712807415379)
19+
20+
21+
## Setup
22+
We recommend to install the program into a Python virtualenv.
23+
```shell
24+
python3 -m venv .venv
25+
source .venv/bin/activate
26+
pip install 'ds18b20-datalogger @ git+https://github.com/hiveeyes/temp-matrix.git'
27+
```
928

10-
## files
11-
* README.md - this file
12-
* LICENSE
13-
* temp-matrix_5x6.py - sensor reading and data logging to hiveeyes
14-
* temp-matrix_5x6-grafana_desktop.json - description of [grafana desktop](https://swarm.hiveeyes.org/grafana/d/T49wHSaIk/mois-ex-wtf-test-ds18b20-5x6-temp-matrix-svg-pixmap?orgId=2&from=1712771622514&to=1712807415379)
29+
In this spirit, you keep the installation separate from your system Python, so
30+
you can easily nuke it and start from scratch in case anything goes south.
1531

16-
## sensor wiring
17-
be aware that you might have to ajust your resistors size.
18-
with 30 sensors i had erratic sensor mapping using a 4.7k resistor.
19-
i am getting valid mapping using a 2.2k resistor.
32+
Prerequisites: This program needs the `paho-mqtt` package.
33+
https://pypi.org/project/paho-mqtt/#installation
2034

21-
## sensor mapping
22-
[https://community.hiveeyes.org/t/ds18b20-temperatur-sensoren-am-one-wire-bus-anordnen/1399
23-
](https://community.hiveeyes.org/t/ds18b20-temperatur-sensoren-am-one-wire-bus-anordnen/1399)
2435

25-
## data publishing
26-
paho-mqtt required: [https://pypi.org/project/paho-mqtt/#installation](URL)
36+
## Operations
37+
38+
### Sensor Wiring
39+
Be aware that you might have to adjust your resistors size.
40+
With 30 sensors i had erratic sensor mapping using a 4.7k resistor.
41+
I am getting valid mapping using a 2.2k resistor.
42+
43+
### Sensor Mapping
44+
https://community.hiveeyes.org/t/ds18b20-temperatur-sensoren-am-one-wire-bus-anordnen/1399
45+
46+
### Data Publishing
2747

2848
ssh youruser@yourpi
2949
screen
3050
cd temp-matrix
3151
source paho-mqtt/bin/activate
3252
python temp-matrix_5x6.py`
3353

34-
### mqtt data upload to hiveeyes
35-
[https://community.hiveeyes.org/t/daten-per-mqtt-und-python-ans-backend-auf-swarm-hiveeyes-org-ubertragen/94/6](https://community.hiveeyes.org/t/daten-per-mqtt-und-python-ans-backend-auf-swarm-hiveeyes-org-ubertragen/94/6)
54+
### MQTT data upload to Hiveeyes
55+
https://community.hiveeyes.org/t/daten-per-mqtt-und-python-ans-backend-auf-swarm-hiveeyes-org-ubertragen/94/6
3656

37-
### format your array
38-
[https://community.hiveeyes.org/t/how-to-visualize-2-dimensional-temperature-data-in-grafana/974/9
39-
](https://community.hiveeyes.org/t/how-to-visualize-2-dimensional-temperature-data-in-grafana/974/9)
57+
### Format your array
58+
https://community.hiveeyes.org/t/how-to-visualize-2-dimensional-temperature-data-in-grafana/974/9
4059

4160
matrix = [[temp_ir_1_1, temp_ir_1_2, temp_ir_1_3, temp_ir_1_4, temp_ir_1_5, temp_ir_1_6], \
4261
[temp_ir_2_1, temp_ir_2_2, temp_ir_2_3, temp_ir_2_4, temp_ir_2_5, temp_ir_2_6], \
4362
[temp_ir_3_1, temp_ir_3_2, temp_ir_3_3, temp_ir_3_4, temp_ir_3_5, temp_ir_3_6], \
4463
[temp_ir_4_1, temp_ir_4_2, temp_ir_4_3, temp_ir_4_4, temp_ir_4_5, temp_ir_4_6], \
4564
[temp_ir_5_1, temp_ir_5_2, temp_ir_5_3, temp_ir_5_4, temp_ir_5_5, temp_ir_5_6]]
4665

47-
## data visualizing (grafana)
48-
[https://swarm.hiveeyes.org/grafana/d/Y9PcgE4Sz/mois-ex-wtf-test-ir-sensor-svg-pixmap-copy
49-
](https://swarm.hiveeyes.org/grafana/d/Y9PcgE4Sz/mois-ex-wtf-test-ir-sensor-svg-pixmap-copy)
50-
51-
## bonus: sensors offsets
52-
[https://community.hiveeyes.org/t/temperatursensoren-justieren-kalibrieren/1744/2
53-
](https://community.hiveeyes.org/t/temperatursensoren-justieren-kalibrieren/1744/2)
54-
55-
66+
## Data visualization in Grafana
67+
https://swarm.hiveeyes.org/grafana/d/Y9PcgE4Sz/mois-ex-wtf-test-ir-sensor-svg-pixmap-copy
5668

69+
## Bonus: Sensor offsets
70+
https://community.hiveeyes.org/t/temperatursensoren-justieren-kalibrieren/1744/2
5771

72+
## Contributing
5873

74+
In order to learn how to start hacking on this program, please have a look at the
75+
documentation about how to install a [development sandbox](./docs/sandbox.md).
5976

77+
Contributions of any kind are always welcome and appreciated. Thank you.

docs/sandbox.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Development Sandbox
2+
3+
## Install
4+
```shell
5+
git clone https://github.com/hiveeyes/temp-matrix
6+
python3 -m venv .venv
7+
source .venv/bin/activate
8+
pip install --editable='.[develop,docs,release,test]'
9+
```
10+
11+
## Software tests
12+
Run all linters, and invoke the test suite.
13+
```shell
14+
poe check
15+
```
16+
17+
## Format code
18+
Run all code formatters.
19+
```shell
20+
poe format
21+
```

pyproject.toml

Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
[build-system]
2+
build-backend = "setuptools.build_meta"
3+
requires = [
4+
"setuptools>=42", # At least v42 of setuptools required.
5+
"versioningit",
6+
]
7+
8+
[tool.versioningit.vcs]
9+
method = "git"
10+
default-tag = "0.0.0"
11+
12+
[project]
13+
name = "ds18b20-datalogger"
14+
description = "Temperature sensor matrix using Raspberry Pi, DS18B20, MQTT, Kotori DAQ, and Grafana. For bee hive monitoring."
15+
readme = "README.md"
16+
keywords = [
17+
"beehive monitoring",
18+
"ds18b20",
19+
"temperature matrix",
20+
"sensor network",
21+
"raspberry pi",
22+
"mqtt",
23+
"kotori daq",
24+
"grafana",
25+
]
26+
license = { file = "LICENSE" }
27+
authors = [
28+
{ name = "The Hiveeyes Developers", email = "hello@hiveeyes.org" },
29+
]
30+
requires-python = ">=3.7"
31+
classifiers = [
32+
"Development Status :: 3 - Alpha",
33+
"License :: OSI Approved :: GNU General Public License (GPL)",
34+
"Programming Language :: Python :: 3 :: Only",
35+
"Programming Language :: Python :: 3.7",
36+
"Programming Language :: Python :: 3.8",
37+
"Programming Language :: Python :: 3.9",
38+
"Programming Language :: Python :: 3.10",
39+
"Programming Language :: Python :: 3.11",
40+
"Programming Language :: Python :: 3.12",
41+
"Programming Language :: Python :: Implementation :: CPython",
42+
"Topic :: Education",
43+
"Topic :: File Formats",
44+
"Topic :: Scientific/Engineering",
45+
"Topic :: Text Processing",
46+
]
47+
dynamic = [
48+
"version",
49+
]
50+
dependencies = [
51+
"paho-mqtt<2",
52+
]
53+
[project.optional-dependencies]
54+
develop = [
55+
"black<25",
56+
"mypy<1.10",
57+
"poethepoet<0.26",
58+
"pyproject-fmt<1.8",
59+
"ruff<0.4",
60+
"validate-pyproject<0.17",
61+
]
62+
docs = [
63+
]
64+
release = [
65+
"build<2",
66+
"keyring",
67+
"twine<6",
68+
]
69+
test = [
70+
"pytest<9",
71+
"pytest-cov<6",
72+
]
73+
[project.urls]
74+
changelog = "https://github.com/hiveeyes/temp-matrix/blob/main/CHANGES.md"
75+
documentation = "https://ds18b20-datalogger.readthedocs.io/"
76+
homepage = "https://ds18b20-datalogger.readthedocs.io/"
77+
repository = "https://github.com/hiveeyes/temp-matrix"
78+
79+
[tool.black]
80+
line-length = 120
81+
82+
[tool.coverage.run]
83+
branch = false
84+
omit = [
85+
"tests/*",
86+
]
87+
source = ["ds18b20_datalogger"]
88+
89+
[tool.coverage.report]
90+
fail_under = 0
91+
show_missing = true
92+
93+
[tool.mypy]
94+
packages = ["ds18b20_datalogger"]
95+
exclude = [
96+
]
97+
check_untyped_defs = true
98+
implicit_optional = true
99+
install_types = true
100+
no_implicit_optional = true
101+
non_interactive = true
102+
show_error_codes = true
103+
strict_equality = true
104+
warn_unused_ignores = true
105+
warn_redundant_casts = true
106+
107+
[tool.pytest.ini_options]
108+
addopts = "-rA --verbosity=3 --cov --cov-report=term-missing --cov-report=xml"
109+
minversion = "2.0"
110+
log_level = "DEBUG"
111+
log_cli_level = "DEBUG"
112+
log_format = "%(asctime)-15s [%(name)-36s] %(levelname)-8s: %(message)s"
113+
testpaths = [
114+
"ds18b20_datalogger",
115+
"tests",
116+
]
117+
xfail_strict = true
118+
markers = [
119+
]
120+
121+
[tool.ruff]
122+
line-length = 120
123+
124+
lint.select = [
125+
# Pycodestyle
126+
"E",
127+
"W",
128+
# Pyflakes
129+
"F",
130+
# isort
131+
"I",
132+
# Bandit
133+
"S",
134+
# flake8-quotes
135+
"Q",
136+
# eradicate
137+
"ERA",
138+
# flake8-2020
139+
"YTT",
140+
# print
141+
"T20",
142+
# return
143+
"RET",
144+
# pyupgrade
145+
# "UP",
146+
# flake8-commas
147+
# "COM",
148+
# future-annotations
149+
# "FA",
150+
# flake8-type-checking
151+
"TCH",
152+
# flake8-unused-arguments
153+
# "ARG",
154+
# flake8-use-pathlib
155+
# "PTH"
156+
]
157+
158+
lint.extend-ignore = [
159+
# zip() without an explicit strict= parameter
160+
"B905",
161+
# df is a bad variable name. Be kinder to your future self.
162+
"PD901",
163+
# Unnecessary variable assignment before `return` statement
164+
"RET504",
165+
# Unnecessary `elif` after `return` statement
166+
"RET505",
167+
]
168+
169+
170+
[tool.ruff.lint.per-file-ignores]
171+
"tests/*" = ["S101"] # Allow use of `assert`, and `print`.
172+
173+
[tool.setuptools.packages.find]
174+
namespaces = false
175+
176+
177+
# ===================
178+
# Tasks configuration
179+
# ===================
180+
181+
[tool.poe.tasks]
182+
183+
check = [
184+
"lint",
185+
"test",
186+
]
187+
188+
format = [
189+
{ cmd = "black ." },
190+
# Configure Ruff not to auto-fix (remove!):
191+
# unused imports (F401), unused variables (F841), `print` statements (T201), and commented-out code (ERA001).
192+
{ cmd = "ruff check --fix --ignore=ERA --ignore=F401 --ignore=F841 --ignore=T20 --ignore=ERA001 ." },
193+
{ cmd = "pyproject-fmt --keep-full-version pyproject.toml" },
194+
]
195+
196+
lint = [
197+
{ cmd = "ruff check ." },
198+
{ cmd = "black --check ." },
199+
{ cmd = "validate-pyproject pyproject.toml" },
200+
{ cmd = "mypy" },
201+
]
202+
203+
release = [
204+
{ cmd = "python -m build" },
205+
{ cmd = "twine upload dist/*.tar.gz dist/*.whl" },
206+
]
207+
208+
test = { cmd = "pytest" }

0 commit comments

Comments
 (0)