summaryrefslogtreecommitdiffstats
path: root/collectors/python.d.plugin/am2320
diff options
context:
space:
mode:
Diffstat (limited to 'collectors/python.d.plugin/am2320')
-rw-r--r--collectors/python.d.plugin/am2320/Makefile.inc8
-rw-r--r--collectors/python.d.plugin/am2320/README.md37
-rw-r--r--collectors/python.d.plugin/am2320/am2320.chart.py69
-rw-r--r--collectors/python.d.plugin/am2320/am2320.conf68
4 files changed, 182 insertions, 0 deletions
diff --git a/collectors/python.d.plugin/am2320/Makefile.inc b/collectors/python.d.plugin/am2320/Makefile.inc
new file mode 100644
index 000000000..48e5a8892
--- /dev/null
+++ b/collectors/python.d.plugin/am2320/Makefile.inc
@@ -0,0 +1,8 @@
+# SPDX-License-Identifier: GPL-3.0-or-later
+
+# install these files
+dist_python_DATA += am2320/am2320.chart.py
+dist_pythonconfig_DATA += am2320/am2320.conf
+
+# do not install these files, but include them in the distribution
+dist_noinst_DATA += am2320/README.md am2320/Makefile.inc
diff --git a/collectors/python.d.plugin/am2320/README.md b/collectors/python.d.plugin/am2320/README.md
new file mode 100644
index 000000000..709575221
--- /dev/null
+++ b/collectors/python.d.plugin/am2320/README.md
@@ -0,0 +1,37 @@
+# AM2320
+This module will display a graph of the temperture and humity from a AM2320 sensor.
+
+**Requirements:**
+ - Adafruit Circuit Python AM2320 library
+ - Adafruit AM2320 I2C sensor
+ - Python 3 (Adafruit libraries are not Python 2.x compatible)
+
+
+It produces the following charts:
+1. **Temperature**
+2. **Humidity**
+
+## configuration
+
+Raspbery Pi Instructions:
+
+Hardware install:
+Connect the am2320 to the Raspbery Pi I2C pins
+
+Raspberry Pi 3B/4 Pins:
+
+- Board 3.3V (pin 1) to sensor VIN (pin 1)
+- Board SDA (pin 3) to sensor SDA (pin 2)
+- Board GND (pin 6) to sensor GND (pin 3)
+- Board SCL (pin 5) to sensor SCL (pin 4)
+
+You may also need to add two I2C pullup resistors if your board does not already have them. The Raspberry Pi does have internal pullup resistors but it doesnt hurt to add them anyway. You can use 2.2K - 10K but we will just use 10K. The resistors go from VDD to SCL and SDA each.
+
+Software install:
+- `sudo pip3 install adafruit-circuitpython-am2320`
+- edit `/etc/netdata/netdata.conf`
+- find `[plugin:python.d]`
+- add `command options = -ppython3`
+- save the file.
+- restart the netdata service.
+- check the dashboard.
diff --git a/collectors/python.d.plugin/am2320/am2320.chart.py b/collectors/python.d.plugin/am2320/am2320.chart.py
new file mode 100644
index 000000000..c15e16eee
--- /dev/null
+++ b/collectors/python.d.plugin/am2320/am2320.chart.py
@@ -0,0 +1,69 @@
+# _*_ coding: utf-8 _*_
+# Description: AM2320 netdata module
+# Author: tommybuck
+# SPDX-License-Identifier: GPL-3.0-or-Later
+
+try:
+ import board
+ import busio
+ import adafruit_am2320
+ HAS_AM2320 = True
+except ImportError:
+ HAS_AM2320 = False
+
+
+from bases.FrameworkServices.SimpleService import SimpleService
+
+
+ORDER = [
+ 'temperature',
+ 'humidity',
+]
+
+CHARTS = {
+ 'temperature': {
+ 'options': [None, 'Temperature', 'celsius', 'temperature', 'am2320.temperature', 'line'],
+ 'lines': [
+ ['temperature']
+ ]
+ },
+ 'humidity': {
+ 'options': [None, 'Relative Humidity', 'percentage', 'humidity', 'am2320.humidity', 'line'],
+ 'lines': [
+ ['humidity']
+ ]
+ }
+}
+
+
+class Service(SimpleService):
+ def __init__(self, configuration=None, name=None):
+ SimpleService.__init__(self, configuration=configuration, name=name)
+ self.order = ORDER
+ self.definitions = CHARTS
+ self.am = None
+
+ def check(self):
+ if not HAS_AM2320:
+ self.error("Could not find the adafruit-circuitpython-am2320 package.")
+ return False
+
+ try:
+ i2c = busio.I2C(board.SCL, board.SDA)
+ self.am = adafruit_am2320.AM2320(i2c)
+ except ValueError as error:
+ self.error("error on creating I2C shared bus : {0}".format(error))
+ return False
+
+ return True
+
+ def get_data(self):
+ try:
+ return {
+ 'temperature': self.am.temperature,
+ 'humidity': self.am.relative_humidity,
+ }
+
+ except (OSError, RuntimeError) as error:
+ self.error(error)
+ return None
diff --git a/collectors/python.d.plugin/am2320/am2320.conf b/collectors/python.d.plugin/am2320/am2320.conf
new file mode 100644
index 000000000..982f5cd0a
--- /dev/null
+++ b/collectors/python.d.plugin/am2320/am2320.conf
@@ -0,0 +1,68 @@
+# netdata python.d.plugin configuration for am2320 temperture/humity sensor
+#
+# This file is in YaML format. Generally the format is:
+#
+# name: value
+#
+# There are 2 sections:
+# - global variables
+# - one or more JOBS
+#
+# JOBS allow you to collect values from multiple sources.
+# Each source will have its own set of charts.
+#
+# JOB parameters have to be indented (using spaces only, example below).
+
+# ----------------------------------------------------------------------
+# Global Variables
+# These variables set the defaults for all JOBs, however each JOB
+# may define its own, overriding the defaults.
+
+# update_every sets the default data collection frequency.
+# If unset, the python.d.plugin default is used.
+# update_every: 1
+
+# priority controls the order of charts at the netdata dashboard.
+# Lower numbers move the charts towards the top of the page.
+# If unset, the default for python.d.plugin is used.
+# priority: 60000
+
+# penalty indicates whether to apply penalty to update_every in case of failures.
+# Penalty will increase every 5 failed updates in a row. Maximum penalty is 10 minutes.
+# penalty: yes
+
+# autodetection_retry sets the job re-check interval in seconds.
+# The job is not deleted if check fails.
+# Attempts to start the job are made once every autodetection_retry.
+# This feature is disabled by default.
+# autodetection_retry: 0
+
+# ----------------------------------------------------------------------
+# JOBS (data collection sources)
+#
+# The default JOBS share the same *name*. JOBS with the same name
+# are mutually exclusive. Only one of them will be allowed running at
+# any time. This allows autodetection to try several alternatives and
+# pick the one that works.
+#
+# Any number of jobs is supported.
+#
+# All python.d.plugin JOBS (for all its modules) support a set of
+# predefined parameters. These are:
+#
+# job_name:
+# name: myname # the JOB's name as it will appear at the
+# # dashboard (by default is the job_name)
+# # JOBs sharing a name are mutually exclusive
+# update_every: 1 # the JOB's data collection frequency
+# priority: 60000 # the JOB's order on the dashboard
+# penalty: yes # the JOB's penalty
+# autodetection_retry: 0 # the JOB's re-check interval in seconds
+#
+# Additionally to the above, example also supports the following:
+#
+# - none
+#
+# ----------------------------------------------------------------------
+# AUTO-DETECTION JOBS
+# only one of them will run (they have the same name)