First throw
This commit is contained in:
commit
2c50e3fe78
5 changed files with 222 additions and 0 deletions
124
.gitignore
vendored
Normal file
124
.gitignore
vendored
Normal file
|
@ -0,0 +1,124 @@
|
||||||
|
###SublimeText###
|
||||||
|
|
||||||
|
# cache files for sublime text
|
||||||
|
*.tmlanguage.cache
|
||||||
|
*.tmPreferences.cache
|
||||||
|
*.stTheme.cache
|
||||||
|
|
||||||
|
# workspace files are user-specific
|
||||||
|
*.sublime-workspace
|
||||||
|
|
||||||
|
# project files should be checked into the repository, unless a significant
|
||||||
|
# proportion of contributors will probably not be using SublimeText
|
||||||
|
# *.sublime-project
|
||||||
|
|
||||||
|
# sftp configuration file
|
||||||
|
sftp-config.json
|
||||||
|
|
||||||
|
|
||||||
|
###Python###
|
||||||
|
|
||||||
|
# Byte-compiled / optimized / DLL files
|
||||||
|
__pycache__/
|
||||||
|
*.py[cod]
|
||||||
|
*$py.class
|
||||||
|
|
||||||
|
# C extensions
|
||||||
|
*.so
|
||||||
|
|
||||||
|
# Distribution / packaging
|
||||||
|
.Python
|
||||||
|
build/
|
||||||
|
develop-eggs/
|
||||||
|
dist/
|
||||||
|
downloads/
|
||||||
|
eggs/
|
||||||
|
.eggs/
|
||||||
|
lib/
|
||||||
|
lib64/
|
||||||
|
parts/
|
||||||
|
sdist/
|
||||||
|
var/
|
||||||
|
wheels/
|
||||||
|
*.egg-info/
|
||||||
|
.installed.cfg
|
||||||
|
*.egg
|
||||||
|
MANIFEST
|
||||||
|
|
||||||
|
# PyInstaller
|
||||||
|
# Usually these files are written by a python script from a template
|
||||||
|
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||||
|
*.manifest
|
||||||
|
*.spec
|
||||||
|
|
||||||
|
# Installer logs
|
||||||
|
pip-log.txt
|
||||||
|
pip-delete-this-directory.txt
|
||||||
|
|
||||||
|
# Unit test / coverage reports
|
||||||
|
htmlcov/
|
||||||
|
.tox/
|
||||||
|
.coverage
|
||||||
|
.coverage.*
|
||||||
|
.cache
|
||||||
|
nosetests.xml
|
||||||
|
coverage.xml
|
||||||
|
*.cover
|
||||||
|
.hypothesis/
|
||||||
|
|
||||||
|
# Translations
|
||||||
|
*.mo
|
||||||
|
*.pot
|
||||||
|
|
||||||
|
# Django stuff:
|
||||||
|
*.log
|
||||||
|
.static_storage/
|
||||||
|
.media/
|
||||||
|
local_settings.py
|
||||||
|
|
||||||
|
# Flask stuff:
|
||||||
|
instance/
|
||||||
|
.webassets-cache
|
||||||
|
|
||||||
|
# Scrapy stuff:
|
||||||
|
.scrapy
|
||||||
|
|
||||||
|
# Sphinx documentation
|
||||||
|
docs/_build/
|
||||||
|
|
||||||
|
# PyBuilder
|
||||||
|
target/
|
||||||
|
|
||||||
|
# Jupyter Notebook
|
||||||
|
.ipynb_checkpoints
|
||||||
|
|
||||||
|
# pyenv
|
||||||
|
.python-version
|
||||||
|
|
||||||
|
# celery beat schedule file
|
||||||
|
celerybeat-schedule
|
||||||
|
|
||||||
|
# SageMath parsed files
|
||||||
|
*.sage.py
|
||||||
|
|
||||||
|
# Environments
|
||||||
|
.env
|
||||||
|
.venv
|
||||||
|
env/
|
||||||
|
venv/
|
||||||
|
ENV/
|
||||||
|
env.bak/
|
||||||
|
venv.bak/
|
||||||
|
|
||||||
|
# Spyder project settings
|
||||||
|
.spyderproject
|
||||||
|
.spyproject
|
||||||
|
|
||||||
|
# Rope project settings
|
||||||
|
.ropeproject
|
||||||
|
|
||||||
|
# mkdocs documentation
|
||||||
|
/site
|
||||||
|
|
||||||
|
# mypy
|
||||||
|
.mypy_cache/
|
21
LICENSE
Normal file
21
LICENSE
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2019 Nis Wechselberg
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
0
README.md
Normal file
0
README.md
Normal file
69
RadiationInfluxDaemon.py
Normal file
69
RadiationInfluxDaemon.py
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
# Python Radiation Logger
|
||||||
|
# Copyright (c) 2019 Nis Wechselberg <enbewe@enbewe.de>
|
||||||
|
#
|
||||||
|
# This work is licensed under MIT license. You should have
|
||||||
|
# received a copy of the MIT license legalcode along with this
|
||||||
|
# work. If not, see <https://opensource.org/licenses/MIT>.
|
||||||
|
|
||||||
|
# pylint: disable=C0103
|
||||||
|
|
||||||
|
"""
|
||||||
|
Python Radiation Logger
|
||||||
|
|
||||||
|
Small daemon script that parses the data from the MightyOhm Geiger-Mueller Counter.
|
||||||
|
The data is fed directly to an InfluxDB.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import time
|
||||||
|
import os
|
||||||
|
|
||||||
|
import serial
|
||||||
|
|
||||||
|
# InfluxDB Client to allow easy submission to time series database
|
||||||
|
from influxdb import InfluxDBClient
|
||||||
|
|
||||||
|
# Configure argument parsing
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument("dev", help="Device node of the sensor (i.e. /dev/ttyS0)")
|
||||||
|
parser.add_argument("dbHost", help="Hostname/IP of the InfluxDB machine")
|
||||||
|
parser.add_argument("dbName", help="Name of the database to write to")
|
||||||
|
|
||||||
|
parser.add_argument("-i", "--interval", help="Time between two measurements (sec)",
|
||||||
|
type=int, default=180)
|
||||||
|
parser.add_argument("-n", "--node", help="Node tag to mark the measurement", default="")
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
# Make sure the device exists and is readable
|
||||||
|
if os.path.exists(args.dev):
|
||||||
|
|
||||||
|
ser = serial.Serial(args.dev, 9600)
|
||||||
|
while True:
|
||||||
|
ser.flushInput()
|
||||||
|
ser.readline()
|
||||||
|
data = ser.readline()
|
||||||
|
splitdata = data.decode("UTF-8").split(",")
|
||||||
|
|
||||||
|
# Prepare data for database
|
||||||
|
influxData = [
|
||||||
|
{
|
||||||
|
"measurement": "feinstaub",
|
||||||
|
"tags": {
|
||||||
|
"node": args.node
|
||||||
|
},
|
||||||
|
"fields": {
|
||||||
|
"radiation_cps": splitdata[1],
|
||||||
|
"radiation_cpm": splitdata[3],
|
||||||
|
"radiation_dose": splitdata[5]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
# Send data to InfluxDB
|
||||||
|
influx = InfluxDBClient(host=args.dbHost, database=args.dbName)
|
||||||
|
influx.write_points(influxData)
|
||||||
|
time.sleep(args.interval)
|
||||||
|
else:
|
||||||
|
print("Device not found")
|
8
RadiationInfluxDaemon.sublime-project
Normal file
8
RadiationInfluxDaemon.sublime-project
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"folders":
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"path": "."
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
Loading…
Reference in a new issue