forked from netdata/netdata
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add support for am2320 sensor (netdata#7024)
* add support for am2320 sensor add support for am2320 temperature and humidity sensor * Rename readme.md to README.md * updated README.md to include proper sections updated README.md to include proper sections * readme updated and file name corrected readme updated with missing formatting and information. AM2320.chart.py filename corrected. * changed simple service import chnaged simple service import location * updated README.md to remove the reference of moving the script file. * requested changes - Moved header from README.md to am2320.chart.py - Added Alarm for am2320 to health.d - Changed exception to value error in am2320.chart.py * typo changed mae to make in comment * Add title and icon for AM2320 Sensor Add title and icon for AM2320 Sensor * typo corrected changed Save to save * added I2C group to installer Added netdata to the I2C group during install or update. Removed instruction to add netdate to I2C group from README.md * change tab to spaces change tab to spaces
- Loading branch information
1 parent
74f9ccd
commit 3fdf18d
Showing
10 changed files
with
205 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# make sure am2320 is sending stats | ||
|
||
template: am2320_last_collected_secs | ||
on: am2320.temperature | ||
calc: $now - $last_collected_t | ||
units: seconds ago | ||
every: 10s | ||
warn: $this > (($status >= $WARNING) ? ($update_every) : ( 5 * $update_every)) | ||
crit: $this > (($status == $CRITICAL) ? ($update_every) : (60 * $update_every)) | ||
delay: down 5m multiplier 1.5 max 1h | ||
info: number of seconds since the last successful data collection | ||
to: webmaster |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters