Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
python-mqtt-gpio
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Alexander Wellbrock
python-mqtt-gpio
Commits
76c127bb
Unverified
Commit
76c127bb
authored
Oct 17, 2020
by
Ellis Percival
Committed by
GitHub
Oct 17, 2020
Browse files
Options
Downloads
Plain Diff
Merge pull request #122 from RoelGo/aht20
Added support for the AHT20 sensor
parents
2f333a95
404353c8
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
pi_mqtt_gpio/modules/aht20.py
+39
-0
39 additions, 0 deletions
pi_mqtt_gpio/modules/aht20.py
with
39 additions
and
0 deletions
pi_mqtt_gpio/modules/aht20.py
0 → 100644
+
39
−
0
View file @
76c127bb
from
pi_mqtt_gpio.modules
import
GenericSensor
REQUIREMENTS
=
(
"
adafruit-circuitpython-ahtx0
"
,)
SENSOR_SCHEMA
=
{
"
type
"
:
dict
(
type
=
"
string
"
,
required
=
False
,
empty
=
False
,
default
=
"
temperature
"
,
allowed
=
[
"
temperature
"
,
"
humidity
"
],
)
}
class
Sensor
(
GenericSensor
):
"""
Implementation of Sensor class for aht20.
"""
def
__init__
(
self
,
config
):
import
board
import
busio
import
adafruit_ahtx0
i2c
=
busio
.
I2C
(
board
.
SCL
,
board
.
SDA
)
self
.
sensor
=
adafruit_ahtx0
.
AHTx0
(
i2c
)
def
setup_sensor
(
self
,
config
):
return
True
# nothing to do here
def
get_value
(
self
,
config
):
"""
get the temperature value from the sensor
"""
temperature
=
self
.
sensor
.
temperature
humidity
=
self
.
sensor
.
relative_humidity
if
config
[
"
type
"
]
==
"
temperature
"
and
temperature
is
not
None
:
return
temperature
if
config
[
"
type
"
]
==
"
humidity
"
and
humidity
is
not
None
:
return
humidity
return
None
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment