Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
sensor-class
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jonathan Weth
sensor-class
Commits
3490c8d3
Commit
3490c8d3
authored
4 years ago
by
Jonathan Weth
Browse files
Options
Downloads
Patches
Plain Diff
Include iAM in temp.py and support piconfig.jonathanweth.de
parent
59d2743b
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
iam-lib/airsensor/airsensor.c
+2
-2
2 additions, 2 deletions
iam-lib/airsensor/airsensor.c
temp.py
+45
-7
45 additions, 7 deletions
temp.py
with
47 additions
and
9 deletions
iam-lib/airsensor/airsensor.c
+
2
−
2
View file @
3490c8d3
...
...
@@ -138,7 +138,7 @@ int main(int argc, char *argv[])
usb_find_busses
();
usb_find_devices
();
dev
=
find_device
(
vendor
,
product
);
sleep
(
1
);
//
sleep(1);
if
(
dev
==
NULL
)
if
(
debug
==
1
)
...
...
@@ -269,7 +269,7 @@ int main(int argc, char *argv[])
exit
(
0
);
// Wait for next request for data
sleep
(
10
);
sleep
(
3
);
}
...
...
This diff is collapsed.
Click to expand it.
temp.py
+
45
−
7
View file @
3490c8d3
...
...
@@ -8,19 +8,28 @@ import requests
from
gpiozero
import
Button
from
influxdb
import
InfluxDBClient
from
RPLCD.i2c
import
CharLCD
from
iam
import
AirSensor
import
threading
# Init LCD
lcd
=
CharLCD
(
'
PCF8574
'
,
0x27
)
lcd
.
write_string
(
"
Starting ...
"
)
# Init InfluxDB
client
=
InfluxDBClient
(
'
influx.jonathanweth.de
'
,
80
,
'
root
'
,
'
root
'
,
'
room_sensors
'
)
client
.
create_database
(
'
room_sensors
'
)
# Set Influx tags
tags
=
{
"
room
"
:
"
012
"
,
"
scenario
"
:
"
ventilate-20
"
}
class
iAMThread
(
threading
.
Thread
):
def
__init__
(
self
):
threading
.
Thread
.
__init__
(
self
)
self
.
running
=
True
self
.
value
=
None
def
run
(
self
):
while
self
.
running
:
self
.
value
=
AirSensor
.
get_value
()
def
temp_it
():
while
True
:
...
...
@@ -67,20 +76,31 @@ def temp_it():
if
__name__
==
"
__main__
"
:
# Read config
print
(
"
Read config ...
"
)
lcd
.
clear
()
lcd
.
write_string
(
"
Read config ...
"
)
r
=
requests
.
get
(
"
https://piconfig.jonathanweth.de/config.json
"
,
verify
=
False
)
# Set Influx tags
tags
=
r
.
json
()
print
(
tags
)
windows
=
[
20
,
26
]
buttons
=
{}
iam_thread
=
iAMThread
()
iam_thread
.
start
()
for
window
in
windows
:
print
(
f
"
Window
{
window
}
"
)
buttons
[
window
]
=
Button
(
window
)
for
temps
,
temp_count
in
temp_it
():
json_body
=
[]
# Clear LCD
lcd
.
clear
()
lcd
.
cursor_pos
=
(
0
,
0
)
json_body
=
[]
########
# TEMP #
...
...
@@ -147,6 +167,24 @@ if __name__ == "__main__":
# Log window data
print
(
str
(
window_data
))
# Air sensor
print
(
"
Read iAM ...
"
)
iam_value
=
iam_thread
.
value
print
(
f
"
iAM:
{
iam_value
}
"
)
if
iam_value
:
json_body
.
append
({
"
measurement
"
:
"
iam
"
,
"
tags
"
:
tags
,
"
fields
"
:
{
"
value
"
:
iam_value
}
})
lcd
.
write_string
(
f
"
{
iam_value
}
"
)
print
(
"
\n
"
)
# Wait for next data
# time.sleep(7.675)
client
.
write_points
(
json_body
)
...
...
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
register
or
sign in
to comment