Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
AirPi
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
julric
AirPi
Commits
b35de1bf
Commit
b35de1bf
authored
Aug 25, 2014
by
julric
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changed all files needed for adding a new sensor (here: TGS2600)
parent
5c775491
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
129 additions
and
31 deletions
+129
-31
lcd/lcd.py
lcd/lcd.py
+45
-16
outputs/rrd.py
outputs/rrd.py
+6
-2
rrd/draw_rrd.sh
rrd/draw_rrd.sh
+2
-2
rrd/draw_rrd_day.sh
rrd/draw_rrd_day.sh
+15
-2
rrd/draw_rrd_hour.sh
rrd/draw_rrd_hour.sh
+15
-2
rrd/draw_rrd_month.sh
rrd/draw_rrd_month.sh
+15
-2
rrd/draw_rrd_week.sh
rrd/draw_rrd_week.sh
+15
-2
rrd/draw_rrd_year.sh
rrd/draw_rrd_year.sh
+15
-2
sensors.cfg
sensors.cfg
+1
-1
No files found.
lcd/lcd.py
View file @
b35de1bf
import
operator
import
datetime
import
time
import
os
os
.
chdir
(
"/srv/airpi/lcd/"
)
from
Adafruit_CharLCDPlate
import
Adafruit_CharLCDPlate
from
subprocess
import
check_output
lcd
=
Adafruit_CharLCDPlate
.
Adafruit_CharLCDPlate
()
...
...
@@ -17,13 +19,14 @@ lcd.backlight(lcd.OFF)
# type: apt-get install rrdtools #
# #
#########################################################
# set some options here and the shortnames, symbols and #
# order of the displayed data in line 45 and further #
# set some options here #
#########################################################
rrd_file_airpi
=
'../data_airpi.rrd'
# path to your rrd-file with airpi weather data
display_time
=
3
# time in seconds, each value should be displayed on lcd
display_color
=
lcd
.
GREEN
# backlight-color of lcd: lcd.RED, lcd.BLUE, lcd.GREEN, lcd.VIOLETT or lcd.ON (lightblue)
display_color
=
lcd
.
ON
# backlight-color of lcd: lcd.RED, lcd.BLUE, lcd.GREEN, lcd.VIOLETT or lcd.ON (lightblue)
show_flukso
=
1
# also show last energy consumption? 1 = yes, 0 = no
rrd_file_flukso
=
'../../flukso/data_wohnung.rrd'
# path to your rrd-file with flukso-data
#########################################################
...
...
@@ -34,9 +37,8 @@ while True:
last
=
check_output
([
"rrdtool"
,
"lastupdate"
,
rrd_file_airpi
])
lastvalues
=
last
.
split
(
)
# array lastvalues consists of every sensor-name, followed by the time and the sensor-values:
# ['tempbmp', 'tempdht', 'press', 'humi', 'light', 'no2', 'co', 'vol', '1403275748:', '24', 'U', '1001', 'U', '546', '98830', '161637', '235']
# (for the rrd, generated as shown in https://git.cccmz.de/julric/airpi/wikis/rrd-support )
# array lastvalues consists of every sensor-name, then the time and the sensor-values:
# ['tempbmp', 'tempdht', 'press', 'humi', 'light', 'no2', 'co', 'vol', 'smoke', '1406917791:', '9969', '28', '30', '993', '40', '1840', '64672', '424615', '3081']
data
=
[]
sensors
=
(
len
(
lastvalues
)
-
1
)
/
2
...
...
@@ -52,13 +54,13 @@ while True:
dataPoints
[
"number"
]
=
1
data
.
append
(
dataPoints
)
elif
'press'
in
value
:
dataPoints
[
"sname"
]
=
"
Pressure:
"
dataPoints
[
"sname"
]
=
"
Druck:
"
dataPoints
[
"value"
]
=
lastvalues
[(
position
+
sensors
+
1
)]
dataPoints
[
"symbol"
]
=
"hPa"
dataPoints
[
"number"
]
=
2
data
.
append
(
dataPoints
)
elif
'humi'
in
value
:
dataPoints
[
"sname"
]
=
"
Humidity:
"
dataPoints
[
"sname"
]
=
"
Feuchte:
"
dataPoints
[
"value"
]
=
lastvalues
[(
position
+
sensors
+
1
)]
dataPoints
[
"symbol"
]
=
"%"
dataPoints
[
"number"
]
=
3
...
...
@@ -82,17 +84,23 @@ while True:
dataPoints
[
"number"
]
=
6
data
.
append
(
dataPoints
)
elif
'light'
in
value
:
dataPoints
[
"sname"
]
=
"Li
g
ht: "
dataPoints
[
"sname"
]
=
"Li
c
ht: "
dataPoints
[
"value"
]
=
lastvalues
[(
position
+
sensors
+
1
)]
dataPoints
[
"symbol"
]
=
"mV"
dataPoints
[
"number"
]
=
7
data
.
append
(
dataPoints
)
elif
'vol'
in
value
:
dataPoints
[
"sname"
]
=
"Vol
ume:
"
dataPoints
[
"sname"
]
=
"Vol
:
"
dataPoints
[
"value"
]
=
lastvalues
[(
position
+
sensors
+
1
)]
dataPoints
[
"symbol"
]
=
"Ohm"
dataPoints
[
"number"
]
=
8
data
.
append
(
dataPoints
)
elif
'smoke'
in
value
:
dataPoints
[
"sname"
]
=
"Luft: "
dataPoints
[
"value"
]
=
lastvalues
[(
position
+
sensors
+
1
)]
dataPoints
[
"symbol"
]
=
"Ohm"
dataPoints
[
"number"
]
=
9
data
.
append
(
dataPoints
)
elif
':'
in
value
:
measurementtime
=
value
[:
-
1
]
else
:
...
...
@@ -104,20 +112,25 @@ while True:
lcd
.
clear
()
lcd
.
backlight
(
display_color
)
lcd
.
message
(
"
AirPi
\
n
"
+
'{:%d.%m.%Y %H:%M}'
.
format
(
datetime
.
datetime
.
fromtimestamp
(
float
(
measurementtime
))))
lcd
.
message
(
"
Wetterstation
\
n
"
+
'{:%d.%m.%Y %H:%M}'
.
format
(
datetime
.
datetime
.
fromtimestamp
(
float
(
measurementtime
))))
# show output on console
# print "
AirPi
\n" + '{:%d.%m.%Y %H:%M}'.format(datetime.datetime.fromtimestamp(float(measurementtime)))
# print "
Wetterstation
\n" + '{:%d.%m.%Y %H:%M}'.format(datetime.datetime.fromtimestamp(float(measurementtime)))
time
.
sleep
(
display_time
)
lcd
.
clear
()
currentDisplay
=
0
for
currentDisplay
in
range
(
0
,
4
,
1
):
for
currentDisplay
in
range
(
0
,
5
,
1
):
data1
=
data
[
currentDisplay
*
2
]
if
data1
[
"value"
]
==
"U"
:
data1
[
"value"
]
=
" "
else
:
str
(
int
(
round
(
float
(
data1
[
"value"
]))))
if
currentDisplay
==
4
:
data2
[
"sname"
]
=
" "
data2
[
"value"
]
=
"U"
data2
[
"symbol"
]
=
" "
else
:
data2
=
data
[
currentDisplay
*
2
+
1
]
if
data2
[
"value"
]
==
"U"
:
data2
[
"value"
]
=
" "
...
...
@@ -132,6 +145,22 @@ while True:
time
.
sleep
(
display_time
)
lcd
.
clear
()
# show current energy consumption
if
show_flukso
==
1
:
lastvalues
=
[]
last
=
check_output
([
"rrdtool"
,
"lastupdate"
,
rrd_file_flukso
])
lastvalues
=
last
.
split
(
)
# array lastvalues consists of every sensor-name, then the time and the sensor-values:
# ['watt', '1403275748', '137']
lcd
.
message
(
"Stromverbrauch:
\
n
"
+
lastvalues
[
2
]
+
" Watt"
)
# show output on console
# print "Stromverbrauch: \n " + lastvalues[2] + " Watt"
time
.
sleep
(
display_time
)
# clear and turn off lcd
lcd
.
clear
()
lcd
.
backlight
(
lcd
.
OFF
)
...
...
outputs/rrd.py
View file @
b35de1bf
...
...
@@ -54,7 +54,11 @@ class rrd(output.Output):
rrd_value
=
rrd_value
+
":"
+
str
(
int
(
round
(
dataPoints
[
array_index
][
"value"
])))
else
:
rrd_value
=
rrd_value
+
":U"
if
[
i
for
i
,
x
in
enumerate
(
dataPoints
)
if
x
[
"name"
]
==
"Smoke_Level"
and
x
[
"sensor"
]
==
"TGS2600"
]:
array_index
=
[
i
for
i
,
x
in
enumerate
(
dataPoints
)
if
x
[
"name"
]
==
"Smoke_Level"
and
x
[
"sensor"
]
==
"TGS2600"
][
0
]
rrd_value
=
rrd_value
+
":"
+
str
(
int
(
round
(
dataPoints
[
array_index
][
"value"
])))
else
:
rrd_value
=
rrd_value
+
":U"
# print rrd_value
ret
=
rrd_update
(
self
.
rrd_file
,
rrd_value
);
...
...
rrd/draw_rrd.sh
View file @
b35de1bf
#! /bin/bash
RRDTOOL
=
"/usr/bin/rrdtool"
RRD_DB
=
"
/srv/airpi
/data_airpi.rrd"
RRD_DB
=
"
..
/data_airpi.rrd"
GRAPH_PATH
=
"
/srv/flukso
/graph"
GRAPH_PATH
=
"
..
/graph"
# hour
$RRDTOOL
graph
$GRAPH_PATH
/airpi-temp-hour.png
-a
PNG
--width
=
800
--height
=
300
\
...
...
rrd/draw_rrd_day.sh
View file @
b35de1bf
#! /bin/bash
RRDTOOL
=
"/usr/bin/rrdtool"
RRD_DB
=
"
/srv/airpi
/data_airpi.rrd"
RRD_DB
=
"
..
/data_airpi.rrd"
GRAPH_PATH
=
"
/srv/flukso
/graph"
GRAPH_PATH
=
"
..
/graph"
$RRDTOOL
graph
$GRAPH_PATH
/airpi-tempbmp-day.png
-a
PNG
--width
=
800
--height
=
300
\
...
...
@@ -127,3 +127,16 @@ VDEF:vol_average=vol,AVERAGE \
VDEF:vol_max
=
vol,MAXIMUM
\
'GPRINT:vol_max:<b>Maximum</b>\: %5.0lf '
\
>
/dev/null
$RRDTOOL
graph
$GRAPH_PATH
/airpi-smoke-day.png
-a
PNG
--width
=
800
--height
=
300
\
--start
-1d
--pango-markup
--vertical-label
'Luftverschmutzung'
\
DEF:smoke
=
$RRD_DB
:smoke:AVERAGE
\
AREA:smoke#acc6fb
\
LINE1:smoke#4f5a72:
"<big>Luftverschmutzung (TGS2600)</big> "
\
VDEF:smoke_min
=
smoke,MINIMUM
\
'GPRINT:smoke_min:<b>Minimum</b>\: %5.0lf '
\
VDEF:smoke_average
=
smoke,AVERAGE
\
'GPRINT:smoke_average:<b>Durchschnitt</b>\: %5.0lf '
\
VDEF:smoke_max
=
smoke,MAXIMUM
\
'GPRINT:smoke_max:<b>Maximum</b>\: %5.0lf '
\
>
/dev/null
rrd/draw_rrd_hour.sh
View file @
b35de1bf
#! /bin/bash
RRDTOOL
=
"/usr/bin/rrdtool"
RRD_DB
=
"
/srv/airpi
/data_airpi.rrd"
RRD_DB
=
"
..
/data_airpi.rrd"
GRAPH_PATH
=
"
/srv/flukso
/graph"
GRAPH_PATH
=
"
..
/graph"
$RRDTOOL
graph
$GRAPH_PATH
/airpi-tempbmp-hour.png
-a
PNG
--width
=
800
--height
=
300
\
...
...
@@ -125,3 +125,16 @@ VDEF:vol_average=vol,AVERAGE \
VDEF:vol_max
=
vol,MAXIMUM
\
'GPRINT:vol_max:<b>Maximum</b>\: %5.0lf '
\
>
/dev/null
$RRDTOOL
graph
$GRAPH_PATH
/airpi-smoke-hour.png
-a
PNG
--width
=
800
--height
=
300
\
--start
-1h
--pango-markup
--vertical-label
'Luftverschmutzung'
\
DEF:smoke
=
$RRD_DB
:smoke:AVERAGE
\
AREA:smoke#acc6fb
\
LINE1:smoke#4f5a72:
"<big>Luftverschmutzung (TGS2600)</big> "
\
VDEF:smoke_min
=
smoke,MINIMUM
\
'GPRINT:smoke_min:<b>Minimum</b>\: %5.0lf '
\
VDEF:smoke_average
=
smoke,AVERAGE
\
'GPRINT:smoke_average:<b>Durchschnitt</b>\: %5.0lf '
\
VDEF:smoke_max
=
smoke,MAXIMUM
\
'GPRINT:smoke_max:<b>Maximum</b>\: %5.0lf '
\
>
/dev/null
rrd/draw_rrd_month.sh
View file @
b35de1bf
#! /bin/bash
RRDTOOL
=
"/usr/bin/rrdtool"
RRD_DB
=
"
/srv/airpi
/data_airpi.rrd"
RRD_DB
=
"
..
/data_airpi.rrd"
GRAPH_PATH
=
"
/srv/flukso
/graph"
GRAPH_PATH
=
"
..
/graph"
$RRDTOOL
graph
$GRAPH_PATH
/airpi-tempbmp-month.png
-a
PNG
--width
=
800
--height
=
300
\
...
...
@@ -127,3 +127,16 @@ VDEF:vol_average=vol,AVERAGE \
VDEF:vol_max
=
vol,MAXIMUM
\
'GPRINT:vol_max:<b>Maximum</b>\: %5.0lf '
\
>
/dev/null
$RRDTOOL
graph
$GRAPH_PATH
/airpi-smoke-month.png
-a
PNG
--width
=
800
--height
=
300
\
--start
-1m
--pango-markup
--vertical-label
'Luftverschmutzung'
\
DEF:smoke
=
$RRD_DB
:smoke:AVERAGE
\
AREA:smoke#acc6fb
\
LINE1:smoke#4f5a72:
"<big>Luftverschmutzung (TGS2600)</big> "
\
VDEF:smoke_min
=
smoke,MINIMUM
\
'GPRINT:smoke_min:<b>Minimum</b>\: %5.0lf '
\
VDEF:smoke_average
=
smoke,AVERAGE
\
'GPRINT:smoke_average:<b>Durchschnitt</b>\: %5.0lf '
\
VDEF:smoke_max
=
smoke,MAXIMUM
\
'GPRINT:smoke_max:<b>Maximum</b>\: %5.0lf '
\
>
/dev/null
rrd/draw_rrd_week.sh
View file @
b35de1bf
#! /bin/bash
RRDTOOL
=
"/usr/bin/rrdtool"
RRD_DB
=
"
/srv/airpi
/data_airpi.rrd"
RRD_DB
=
"
..
/data_airpi.rrd"
GRAPH_PATH
=
"
/srv/flukso
/graph"
GRAPH_PATH
=
"
..
/graph"
$RRDTOOL
graph
$GRAPH_PATH
/airpi-tempbmp-week.png
-a
PNG
--width
=
800
--height
=
300
\
...
...
@@ -127,3 +127,16 @@ VDEF:vol_average=vol,AVERAGE \
VDEF:vol_max
=
vol,MAXIMUM
\
'GPRINT:vol_max:<b>Maximum</b>\: %5.0lf '
\
>
/dev/null
$RRDTOOL
graph
$GRAPH_PATH
/airpi-smoke-week.png
-a
PNG
--width
=
800
--height
=
300
\
--start
-1w
--pango-markup
--vertical-label
'Luftverschmutzung'
\
DEF:smoke
=
$RRD_DB
:smoke:AVERAGE
\
AREA:smoke#acc6fb
\
LINE1:smoke#4f5a72:
"<big>Luftverschmutzung (TGS2600)</big> "
\
VDEF:smoke_min
=
smoke,MINIMUM
\
'GPRINT:smoke_min:<b>Minimum</b>\: %5.0lf '
\
VDEF:smoke_average
=
smoke,AVERAGE
\
'GPRINT:smoke_average:<b>Durchschnitt</b>\: %5.0lf '
\
VDEF:smoke_max
=
smoke,MAXIMUM
\
'GPRINT:smoke_max:<b>Maximum</b>\: %5.0lf '
\
>
/dev/null
rrd/draw_rrd_year.sh
View file @
b35de1bf
#! /bin/bash
RRDTOOL
=
"/usr/bin/rrdtool"
RRD_DB
=
"
/srv/airpi
/data_airpi.rrd"
RRD_DB
=
"
..
/data_airpi.rrd"
GRAPH_PATH
=
"
/srv/flukso
/graph"
GRAPH_PATH
=
"
..
/graph"
$RRDTOOL
graph
$GRAPH_PATH
/airpi-tempbmp-year.png
-a
PNG
--width
=
800
--height
=
300
\
...
...
@@ -127,3 +127,16 @@ VDEF:vol_average=vol,AVERAGE \
VDEF:vol_max
=
vol,MAXIMUM
\
'GPRINT:vol_max:<b>Maximum</b>\: %5.0lf '
\
>
/dev/null
$RRDTOOL
graph
$GRAPH_PATH
/airpi-smoke-year.png
-a
PNG
--width
=
800
--height
=
300
\
--start
-1y
--pango-markup
--vertical-label
'Luftverschmutzung'
\
DEF:smoke
=
$RRD_DB
:smoke:AVERAGE
\
AREA:smoke#acc6fb
\
LINE1:smoke#4f5a72:
"<big>Luftverschmutzung (TGS2600)</big> "
\
VDEF:smoke_min
=
smoke,MINIMUM
\
'GPRINT:smoke_min:<b>Minimum</b>\: %5.0lf '
\
VDEF:smoke_average
=
smoke,AVERAGE
\
'GPRINT:smoke_average:<b>Durchschnitt</b>\: %5.0lf '
\
VDEF:smoke_max
=
smoke,MAXIMUM
\
'GPRINT:smoke_max:<b>Maximum</b>\: %5.0lf '
\
>
/dev/null
sensors.cfg
View file @
b35de1bf
...
...
@@ -38,7 +38,7 @@ sensorName = LDR
[TGS2600]
filename=analogue
enabled=o
ff
enabled=o
n
pullDownResistance=22000
measurement=Smoke_Level
adcPin=1
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment