Archived
1
0
Fork 0

viele Änderungen:

* Hardware: Display
* Software hinzugefügt
* Listings hinzugefügt
* Biblatex: Datum korrigiert
* TEST: Weniger Worttrennungen
This commit is contained in:
Findus23 2014-11-15 11:21:33 +01:00
parent 698ac90689
commit aca25c8073
7 changed files with 222 additions and 19 deletions

132
code/main.sh Executable file
View file

@ -0,0 +1,132 @@
#!/bin/bash
zufall=0
PFAD="/var/www/" #Pfad zum Web-Verzeichnis
r=0 # Backup-Zahl auf Null setzen
IFS="; " #Spezial-Variable, enthält Trennzeichen zum Trennen von Luftdruck und -temperatur
re='^[0-9]+$' # Regulärer Ausdruck, ob Variable eine Zahl ist
pushbullet_api_key=$(cat /home/pi/Temperaturmessung/Fremddateien/pushbullet_settings.txt | head -n 1)
pushbullet_device=$(cat /home/pi/Temperaturmessung/Fremddateien/pushbullet_settings.txt | tail -n 1)
gpio mode 13 out # gelb
gpio mode 12 out # rot
gpio mode 3 out #grün
gpio write 13 0 # nur grün einschalten
gpio write 12 0
gpio write 3 1
if [ $1 ] # if- und case- Abfrage für Startparameter
then
case "$1" in
"-d")rm /home/pi/Temperaturmessung/dygraph.csv
;;
"-h") echo -e "-d csv-Datei leeren \nfür weitere Informationen siehe http://winkler.kremszeile.at/ oder https://github.com/Findus23/Umweltdatenmessung"
exit 1
;;
*) echo "unbekannter Parameter - Für Hilfe -h"
exit
;;
esac
fi
while true
do
uhrzeit=$(date +%Y/%m/%d\ %H:%M:%S) # z.B.: 2014/10/05 11:00:00 (für csv-Datei)
uhrzeit_display=$(date +%d.%m\ %H:%M:%S) # z.B.: 05.10 11:00:00 (für Display)
uhrzeit_lang=$(date +%d.%m.%y\ %H:%M:%S) # z.B.: 05.10.2014 11:00:00 (für Webinterface)
#zufall=$(($zufall + $((RANDOM % 10)) - 5)) # a um eine zufällige Zahl zwischen -5 und 5 ändern
##a=a+[Zufallszahl von 0-32767] modulo 10 (um eine Zahl von 0-10 zu bekommen) -5 (-> -5 bis 5)
#zufall=$a
rasp=$(/opt/vc/bin/vcgencmd measure_temp | cut -c 6,7,8,9) #Betriebstemberatur messen
temp1=$(echo "scale=3; $(grep 't=' /sys/bus/w1/devices/w1_bus_master1/10-000802b53835/w1_slave | awk -F 't=' '{print $2}') / 1000" | bc -l) #Innentemperatur
while [ "$temp1" == "-1.250" ] || [ "$temp1" == "85.000" ] || [ "$temp1" == "85.000" ]
do
gpio write 13 1
echo "----Temp1: $temp1"
temp1=$(echo "scale=3; $(grep 't=' /sys/bus/w1/devices/w1_bus_master1/10-00080277abe1/w1_slave | awk -F 't=' '{print $2}') / 1000" | bc -l)
gpio write 13 0
done
temp2=$(echo "scale=3; $(grep 't=' /sys/bus/w1/devices/w1_bus_master1/10-00080277a5db/w1_slave | awk -F 't=' '{print $2}') / 1000" | bc -l) #Gerätesensor 1
while [ "$temp2" == "-1.250" ] || [ "$temp2" == "85.000" ] || [ "$temp2" == "85.000" ]
do
gpio write 13 1
echo "----Temp2: $temp2"
temp2=$(echo "scale=3; $(grep 't=' /sys/bus/w1/devices/w1_bus_master1/10-00080277a5db/w1_slave | awk -F 't=' '{print $2}') / 1000" | bc -l)
gpio write 13 0
done
temp3=$(echo "scale=3; $(grep 't=' /sys/bus/w1/devices/w1_bus_master1/10-000802b4635f/w1_slave | awk -F 't=' '{print $2}') / 1000" | bc -l) #Außensensor
while [ "$temp3" == "-1.250" ] || [ "$temp3" == "85.000" ] || [ "$temp3" == "85.000" ]
do
gpio write 13 1
echo "----Temp3: $temp3"
temp3=$(echo "scale=3; $(grep 't=' /sys/bus/w1/devices/w1_bus_master1/10-000802b4635f/w1_slave | awk -F 't=' '{print $2}') / 1000" | bc -l)
gpio write 13 0
done
temp4=$(echo "scale=3; $(grep 't=' /sys/bus/w1/devices/w1_bus_master1/10-00080277a5db/w1_slave | awk -F 't=' '{print $2}') / 1000" | bc -l) #Gerätesensor 2
while [ "$temp3" == "-1.250" ] || [ "$temp4" == "85.000" ] || [ "$temp4" == "85.000" ]
do
gpio write 13 1
echo "----Temp4: $temp4"
temp4=$(echo "scale=3; $(grep 't=' /sys/bus/w1/devices/w1_bus_master1/10-00080277a5db/w1_slave | awk -F 't=' '{print $2}') / 1000" | bc -l)
gpio write 13 0
done
luft_roh=$(sudo python /home/pi/Temperaturmessung/Fremddateien/AdafruitDHT.py 2302 17) # Rohdaten des Luftfeuchtigkeits-Sensors
set -- $luft_roh #Zerlegen mithilfe von IFS (siehe ganz oben)
luft_temp=$1
luft_feucht=$2
while [ -z "$luft_roh" ] || [ "$(echo $luft_temp '>' 40 | bc -l)" -eq 1 ] || [ "$(echo $luft_temp '<' -20 | bc -l)" -eq 1 ]
do
gpio write 13 1
echo "----Luft: $luft_roh"
luft_roh=$(sudo python /home/pi/Temperaturmessung/Fremddateien/AdafruitDHT.py 2302 17) # Rohdaten des Luftfeuchtigkeits-Sensors
set -- $luft_roh
luft_temp=$1
luft_feucht=$2
gpio write 13 0
done
druck_roh=$(sudo python /home/pi/Temperaturmessung/Fremddateien/Adafruit_BMP085_auswertung.py) # Rohdaten des Luftdruck-Sensors
set -- $druck_roh
temp_druck=$1
druck=$2
qualitat=$(sudo /home/pi/Temperaturmessung/Fremddateien/airsensor -v -o)
if [ "$qualitat" = "0" ] || ! [[ $qualitat =~ $re ]]
then
qualitat=""
fi
ausgabe=${uhrzeit}\,${temp1}\,${temp2}\,${temp3}\,${temp4}\,${luft_temp}\,${luft_feucht}\,${druck}\,${temp_druck}\,${rasp},${qualitat}
echo $ausgabe >>/home/pi/Temperaturmessung/dygraph.csv
echo "$uhrzeit ${temp1},${temp2},${temp3},${temp4},${luft_temp},${luft_feucht},${druck},${temp_druck},${rasp},${qualitat}" #Ausgabe des aktuellen Wertes im Terminal
temp1_r=$(echo $temp1 |rev | cut -c 3- |rev)
temp2_r=$(echo $temp2 |rev | cut -c 3- |rev)
temp3_r=$(echo $temp3 |rev | cut -c 3- |rev)
temp4_r=$(echo $temp4 |rev | cut -c 3- |rev)
luft_temp_r=$(echo $luft_temp |rev | cut -c 3- |rev)
luft_feucht_r=$(echo $luft_feucht |rev | cut -c 3- |rev)
temp_druck_r=$(echo $temp_druck |rev | cut -c 2- |rev)
druck_r=$(echo $druck |rev | cut -c 2- |rev)
echo "$uhrzeit_display
$temp1_r
$temp2_r
$temp3_r
$temp4_r
$luft_temp_r
$luft_feucht_r
$temp_druck_r
$druck_r
$rasp
$qualitat" >/home/pi/Temperaturmessung/text.txt.temp #zuerst in temporäre Datei schreiben und dann verschieben, um kurzzeitig leere Datei zu vermeiden
echo "$uhrzeit_lang,${temp1_r},${temp2_r},${temp3_r},${temp4_r},${luft_temp_r},${luft_feucht_r},${temp_druck_r},${druck_r},${rasp},${qualitat}" >/home/pi/Temperaturmessung/text_ws.txt # Daten für Webseite
/home/pi/Temperaturmessung/diverses/wunderground.py $temp1 $temp2 $temp3 $temp4 $luft_temp $luft_feucht $temp_druck $druck $rasp $qualitat >> /home/pi/wunderground.log &
sudo cp /home/pi/Temperaturmessung/text_ws.txt ${PFAD}text_ws.txt
mv /home/pi/Temperaturmessung/text.txt.temp /home/pi/Temperaturmessung/text.txt
sudo cp /home/pi/Temperaturmessung/dygraph.csv ${PFAD}dygraph.csv
sleep 8 # kurz warten
r=$(($r +1)) # Anzahl der Durchläufe zählen
if [ "$r" == "1000" ] # und alle 1000 Durchgänge Sicherung anfertigen
then
cp /home/pi/Temperaturmessung/dygraph.csv /home/pi/Temperaturmessung/dygraph.csv.bak
python /home/pi/Temperaturmessung/Fremddateien/send.py "l.winkler23@me.com" "Backup" "" "/home/pi/Temperaturmessung/dygraph.csv" &
/home/pi/Temperaturmessung/Fremddateien/pushbullet_cmd.py $pushbullet_api_key note $pushbullet_device "Backup erfolgreich" "$uhrzeit_display"
echo "Backup"
r=0
fi
done

BIN
figures/display.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 170 KiB

BIN
figures/erstes_display.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 797 KiB

View file

@ -109,4 +109,23 @@ Da der \textit{VOLTCRAFT CO-20} jedoch nicht mehr erhältlich ist, verwende ich
Der Sensor wird über USB an den Raspberry Pi angeschlossen. Um die Daten unter Linux auszulesen, wird \enquote{usb-sensors-linux} verwendet.\footcite{usb-sensors-linux}
\section{Display}
\begin{figure}[h]
\centering
\includegraphics[width=0.9\textwidth]{figures/erstes_display.jpg}
\caption{Erstes Display (eigenes Werk)}
\label{fig:erstes_display}
\end{figure}
Damit nicht immer ein Computer benötigt wird, um die aktuellen Messwerte zu erfahren, gibt es ein Display, welches die aktuellen Messwerte anzeigt. Ursprünglich habe ich ein (?)
\todo{Modell vom ersten Display herausfinden}
von Conrad verwendet.
\begin{figure}[h]
\centering
\includegraphics[width=0.9\textwidth]{figures/display.jpg}
\caption{eingebautes Display (eigenes Werk)}
\label{fig:display}
\end{figure}
\section{Anschluss}

BIN
main.pdf

Binary file not shown.

View file

@ -166,6 +166,56 @@
%% ========================================================================
%% ... it's OK to put here your own usepackage commands ...
\usepackage{listings}
\definecolor{mygreen}{rgb}{0,0.6,0}
\definecolor{mygray}{rgb}{0.5,0.5,0.5}
\definecolor{mymauve}{rgb}{0.58,0,0.82}
\lstdefinestyle{mystyle}{
numberbychapter=false,
backgroundcolor=\color{white},
% basicstyle=\footnotesize,
breakatwhitespace=false,
breaklines=true,
captionpos=b,
commentstyle=\color{mygreen},
frame=shadowbox,
keepspaces=true,
keywordstyle=\color{blue},
numbers=left,
numbersep=5pt,
numberstyle=\color{mygray},
rulecolor=\color{black},
rulesepcolor=\color{gray},
showspaces=false,
showstringspaces=true,
showtabs=true,
stepnumber=1,
stringstyle=\color{mymauve},
tabsize=2,
}
\lstset{literate=
{á}{{\'a}}1 {é}{{\'e}}1 {í}{{\'i}}1 {ó}{{\'o}}1 {ú}{{\'u}}1
{Á}{{\'A}}1 {É}{{\'E}}1 {Í}{{\'I}}1 {Ó}{{\'O}}1 {Ú}{{\'U}}1
{à}{{\`a}}1 {è}{{\`e}}1 {ì}{{\`i}}1 {ò}{{\`o}}1 {ù}{{\`u}}1
{À}{{\`A}}1 {È}{{\'E}}1 {Ì}{{\`I}}1 {Ò}{{\`O}}1 {Ù}{{\`U}}1
{ä}{{\"a}}1 {ë}{{\"e}}1 {ï}{{\"i}}1 {ö}{{\"o}}1 {ü}{{\"u}}1
{Ä}{{\"A}}1 {Ë}{{\"E}}1 {Ï}{{\"I}}1 {Ö}{{\"O}}1 {Ü}{{\"U}}1
{â}{{\^a}}1 {ê}{{\^e}}1 {î}{{\^i}}1 {ô}{{\^o}}1 {û}{{\^u}}1
{Â}{{\^A}}1 {Ê}{{\^E}}1 {Î}{{\^I}}1 {Ô}{{\^O}}1 {Û}{{\^U}}1
{œ}{{\oe}}1 {Œ}{{\OE}}1 {æ}{{\ae}}1 {Æ}{{\AE}}1 {ß}{{\ss}}1
{ç}{{\c c}}1 {Ç}{{\c C}}1 {ø}{{\o}}1 {å}{{\r a}}1 {Å}{{\r A}}1
{}{{\EUR}}1 {£}{{\pounds}}1 {}{}0,
style=mystyle,
}
\renewcommand{\lstlistingname}{Programmcode}
\renewcommand{\lstlistlistingname}{Programmcode}
\newcommand{\code}[4]{
\lstinputlisting[language=#2,firstline=#3,lastline=#4,caption=#1 (Zeile #3 bis #4),firstnumber=#3]{code/#1}
}
\newcommand{\codeline}[3]{
\lstinputlisting[language=#2,firstline=#3,lastline=#3,caption=#1 (Zeile #3),firstnumber=#3]{code/#1}
}
\usepackage{siunitx}
\usepackage{wrapfig} % Bildumlauf
\usepackage[toc,nopostdot]{glossaries}
@ -173,6 +223,9 @@
\input{glossar.tex}
\makeglossaries
\hyphenpenalty=3000 %test von weniger Trennungen
\tolerance=1000
%% ========================================================================
%%%% MISC self-defined commands and settings
@ -240,7 +293,7 @@
\include{einleitung}
\include{hardware}
\include{software}
\appendix %% closes main document, appendix follows until end; only available in book-classes
\addpart*{Anhang} %% adding Appendix to tableofcontents
@ -250,7 +303,8 @@
\printbibliography[nottype=online,nottype=book,heading=subbibliography,title={sonstige Literatur}]
\listoffigures
\listoftables
%\listoftables
\lstlistoflistings
\glsaddall
\setglossarystyle{altlisthypergroup} % alternativ listhypergroup (in der selben Zeile)
\printglossary[title=Glossar]

View file

@ -7,7 +7,7 @@
Author = {{Adafruit User KEVIN TOWNSEND}},
Url = {https://learn.adafruit.com/using-the-bmp085-with-raspberry-pi?view=all},
Year = {2013},
Urldate = {2014-25-10},
Urldate = {2014-10-25},
Owner = {lukas},
Timestamp = {2014.10.25}
@ -18,7 +18,7 @@
Author = {{Adafruit User LADY ADA}},
Url = {https://learn.adafruit.com/dht-humidity-sensing-on-raspberry-pi-with-gdocs-logging?view=all},
Year = {2013},
Urldate = {2014-25-10},
Urldate = {2014-10-25},
Owner = {lukas},
Timestamp = {2014.10.25}
@ -29,7 +29,7 @@
Author = {{Aosong Electronics Co.,Ltd}},
Url = {https://www.sparkfun.com/datasheets/Sensors/Temperature/DHT22.pdf},
Year = {2011},
Urldate = {2014-08-11},
Urldate = {2014-11-08},
Owner = {lukas},
Timestamp = {2014.11.08}
@ -40,7 +40,7 @@
Author = {Philipp Bohk},
Url = {https://commons.wikimedia.org/wiki/File%3aLambdaPlaques.jpg},
Year = {2012},
Urldate = {2014-04-07},
Urldate = {2014-07-04},
File = {:home/lukas/VWA/figures/raspberry.jpg:JPG image}
}
@ -48,10 +48,9 @@
@Online{BMP085,
Title = {BMP085 Digital pressure Sensor - Data Sheet},
Author = {{Bosch Sensortec}},
Date = {2009-15-10},
Date = {2009-10-15},
Url = {https://www.sparkfun.com/datasheets/Components/General/BST-BMP085-DS000-05.pdf},
Year = {2009},
Urldate = {2014-25-10},
Urldate = {2014-10-25},
Owner = {lukas},
Timestamp = {2014.10.17}
@ -62,7 +61,7 @@
Author = {elinux},
Url = {http://elinux.org/index.php?title=RPi_Hardware&oldid=341192#Power},
Year = {2014},
Urldate = {2014-04-07}
Urldate = {2014-07-04}
}
@Online{1-wire,
@ -70,7 +69,7 @@
Author = {FHEMWiki},
Url = {http://www.fhemwiki.de/w/index.php?title=Kategorie:1-Wire&oldid=5092#1-Wire},
Year = {2014},
Urldate = {2014-18-10},
Urldate = {2014-10-18},
Owner = {lukas},
Timestamp = {2014.10.18}
@ -92,7 +91,7 @@
Author = {Maxim Integrated Products, Inc.},
Url = {http://datasheets.maximintegrated.com/en/ds/DS18B20.pdf},
Year = {2008},
Urldate = {2014-17-10},
Urldate = {2014-10-17},
Timestamp = {2014.10.17}
}
@ -103,16 +102,15 @@
Url = {http://www.raspberrypi.org/about/},
Year = {2012},
Organization = {{Raspberry Pi Foundation}},
Urldate = {2014-04-07}
Urldate = {2014-07-04}
}
@Online{usb-sensors-linux,
Title = {Install AirSensor on Linux},
Author = {usb-sensors-linux},
Date = {2013-29-04},
Date = {2013-04-29},
Url = {https://code.google.com/p/usb-sensors-linux/wiki/Install_AirSensor_Linux},
Year = {2013},
Urldate = {2014-08-11},
Urldate = {2014-11-08},
Owner = {lukas},
Timestamp = {2014.11.08}
@ -123,7 +121,7 @@
Author = {Velux},
Url = {http://www.velux.de/privatkunden/produkte/integra_system/produkte/produktempfehlung/raumluftfuehler},
Year = {2014},
Urldate = {2014-08-11},
Urldate = {2014-11-08},
Owner = {lukas},
Timestamp = {2014.11.08}
@ -134,7 +132,7 @@
Author = {Wikipedia},
Url = {http://de.wikipedia.org/w/index.php?title=Bus_(Datenverarbeitung)&oldid=134938136},
Year = {2014},
Urldate = {2014-04-07},
Urldate = {2014-07-04},
Owner = {lukas},
Timestamp = {2014.10.25}
@ -145,7 +143,7 @@
Author = {Wikipedia},
Url = {http://de.wikipedia.org/w/index.php?title=Raspberry_Pi&oldid=134104012#Idee},
Year = {2014},
Urldate = {2014-04-07}
Urldate = {2014-07-04}
}
@Online{VOC,