{"id":1049,"date":"2015-11-16T11:42:56","date_gmt":"2015-11-16T10:42:56","guid":{"rendered":"http:\/\/blog.fh-kaernten.at\/ingmarsretro\/?p=1049"},"modified":"2019-04-10T09:48:40","modified_gmt":"2019-04-10T08:48:40","slug":"raspberry-als-datenlogger-teil2-die-sensoren-und-python","status":"publish","type":"post","link":"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/2015\/11\/16\/raspberry-als-datenlogger-teil2-die-sensoren-und-python\/","title":{"rendered":"Raspberry als Datenlogger Teil2&#8230;Die Sensoren und Python"},"content":{"rendered":"<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_1049\" class=\"pvc_stats all  \" data-element-id=\"1049\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n<div id=\"attachment_1028\" style=\"width: 310px\" class=\"wp-caption alignleft\"><a href=\"http:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2015\/11\/DSC_4789.jpg\"><img fetchpriority=\"high\" decoding=\"async\" aria-describedby=\"caption-attachment-1028\" class=\"wp-image-1028 size-medium\" src=\"http:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2015\/11\/DSC_4789-300x169.jpg\" alt=\"DSC_4789\" width=\"300\" height=\"169\" srcset=\"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2015\/11\/DSC_4789-300x169.jpg 300w, https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2015\/11\/DSC_4789-1024x576.jpg 1024w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-1028\" class=\"wp-caption-text\">Raspberry PI samt Powerbank im Geh\u00e4use<\/p><\/div>\n<p style=\"text-align: justify\">In Teil1 dieses Projektes haben wir dem Raspberry ein Betriebssystem verpasst und das ein wenig f\u00fcr die Anwendung aufbereitet. Wir wollen ja an den PI mehrere Sensoren anschlie\u00dfen und diese dann zyklisch auslesen und die Daten in einer Datei auf einem USB-Stick speichern. Die Aufzeichnung soll so lange laufen, bis ein Taster gedr\u00fcckt wird, der den Prozess beendet. Die einzige Anzeige des PI sind zwei Leuchtdioden, die, sowie auch der Taster, an die GPIOs des PI angeschlossen sind. Darum haben wir folgende Punkte bereits erledigt:<\/p>\n<ul>\n<li>Die PI Platine gemeinsam mit einer USB Powerbank in ein Geh\u00e4use eingebaut<\/li>\n<li>Anschl\u00fcsse wie Ethernet, USB, HDMI durch Ausschnitte im Geh\u00e4use nach au\u00dfen gef\u00fchrt<\/li>\n<li>Zwei Leuchtdioden und einen Taster ins Geh\u00e4use eingebaut und auf die GPIOs geschaltet<\/li>\n<li>Den I\u00b2C Bus des PI auf eine Buchse im Geh\u00e4use gef\u00fchrt<\/li>\n<li>Eine MicroSD Karte mit einem Raspi-Wheezy Image bespielt<\/li>\n<li>Einen USB-Stick mit FAT32 formatiert<\/li>\n<li>Das Betriebssystem soweit konfiguriert, dass das Filesystem f\u00fcr den Stick, alle Module f\u00fcr den I\u00b2C, sowie Python geladen werden.<\/li>\n<\/ul>\n<div id=\"attachment_1029\" style=\"width: 310px\" class=\"wp-caption alignright\"><a href=\"http:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2015\/11\/DSC_4790.jpg\"><img decoding=\"async\" aria-describedby=\"caption-attachment-1029\" class=\"wp-image-1029 size-medium\" src=\"http:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2015\/11\/DSC_4790-300x169.jpg\" alt=\"DSC_4790\" width=\"300\" height=\"169\" srcset=\"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2015\/11\/DSC_4790-300x169.jpg 300w, https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2015\/11\/DSC_4790-1024x576.jpg 1024w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-1029\" class=\"wp-caption-text\">Raspberry PI im Plastikgeh\u00e4use<\/p><\/div>\n<p style=\"text-align: justify\">Der Pi sieht fertig zusammengebaut nun so aus (siehe Bild rechts). Nun k\u00f6nnen die Sensoren angeschlossen werden. In diesem Fall handelt es sich um Luftfeuchtigkeits-\/Temperatursensoren mit der Bezeichnung HYT939 des Herstellers Hygrochip. Hier ein Auszug der technischen Daten aus dem Datenblatt des Herstellers:<\/p>\n<blockquote><p><b>Ausf\u00fchrung: <\/b>Feuchtesensor im TO39 Geh\u00e4use, druckfest, mit Edelstahl-Sinterfilter<b><br \/>\nGenauigkeit:<\/b> Feuchte \u00b11,8% rF, Temperatur \u00b10,2 \u00b0C<br \/>\n<b>Genauigkeit 0&#8230;10% rF (0 &#8230; 50\u00b0C):<\/b> \u00b1(0,1% rF + 17% a<sub>w<\/sub>)<br \/>\n<b>Messbereich<\/b>: Feuchte 0 &#8230; 100% r.F. (max. dp = +80 \u00b0C), Temperatur &#8211; 40 &#8230; +125 \u00b0C<br \/>\n<b>Abmessungen:<\/b> 5,2 x 9 mm<br \/>\n<b>Anschl\u00fcsse:<\/b> TO 39 Footprint<br \/>\n<b>Aufl\u00f6sung Feuchte:<\/b> 0,02% rF<br \/>\n<b>Hysterese bei 50% rF:<\/b> &lt; \u00b11% rF<br \/>\n<b>Linearit\u00e4tsfehler<\/b>: &lt; \u00b11% rF<br \/>\n<b>Ansprechzeit t63:<\/b> &lt; 10 sec (Mit Edelstahl-Sinterfilter)<br \/>\n<b>Aufl\u00f6sung Temperatur: <\/b>0,015 \u00b0C<br \/>\n<b>Digitale Schnittstelle:<\/b> I<sup>2<\/sup>C, Adresse 0x28 oder Alternativadresse<br \/>\n<b>Betriebsspannung:<\/b> 2,7 \u2026 5,5 V<br \/>\n<b>Stromaufnahme (typ):<\/b> &lt; 1\u00b5A in Bereitschaft &lt; 22\u00b5A bei 1Hz Messrate 850 \u00b5A maximal<\/p><\/blockquote>\n<div id=\"attachment_1030\" style=\"width: 310px\" class=\"wp-caption alignleft\"><a href=\"http:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2015\/11\/DSC_4792.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1030\" class=\"wp-image-1030 size-medium\" src=\"http:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2015\/11\/DSC_4792-300x169.jpg\" alt=\"DSC_4792\" width=\"300\" height=\"169\" srcset=\"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2015\/11\/DSC_4792-300x169.jpg 300w, https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2015\/11\/DSC_4792-1024x576.jpg 1024w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-1030\" class=\"wp-caption-text\">HYT939 Sensor<\/p><\/div>\n<p style=\"text-align: justify\">Eine kleine Platine dient als &#8222;Sensorboard&#8220;. Hier besteht die M\u00f6glichkeit, vier HYT\u00b4s anzustecken. Nat\u00fcrlich m\u00fcssen auch die Adressen der Sensoren unterschliedlich sein. Der HYT939 ist per default auf hex 0x28 eingestellt. Will man diese Deviceadresse \u00e4ndern, so muss der der HYT in den Command-Mode versetzt werden, um dann die Konfigurationsdaten empfangen und in sein EEprom schreiben zu k\u00f6nnen. Dazu mu\u00df der Sensor innerhalb der ersten 10ms nach seinem PowerUp in den Command-Mode gebootet werden. Das l\u00e4sst sich am einfachsten mit einem ArduinoUno bewerkstelligen&#8230; Dabei wird der Powerpin des HYT \u00fcber einen Digital Out Pin des Arduino versorgt. So ist es m\u00f6glich, das Timing genau einzuhalten und den Command Mode zu erreichen.<\/p>\n<p style=\"text-align: justify\">Nachdem der Sensor nun an den Raspberry angeschlossen ist, fehlt nur mehr ein Programm, um ihn oder auch mehrere anzusteuern und auszulesen. Hier verwende ich den Python Interpreter. Damit lassen sich auf einfache Weise die Daten auslesen und auch auf Datentr\u00e4gern speichern. Das &#8222;Programm&#8220; besteht aus zwei Teilen:<\/p>\n<ul>\n<li>Hauptscript: beinhaltet nur eine Endlosschleife, die die LEDs steuert, den Taster abfragt, die Sensorfunktion aufruft, deren ausgelesene Werte \u00fcbergibt, aufbereitet und auf den Stick speichert.<\/li>\n<li>Funktion Sensor auslesen: addressiert den I\u00b2C Bus, liest die Sensordaten aus, rechnet sie in lesbare Werte um und \u00fcbergibt den Output an die Funktion<\/li>\n<\/ul>\n<pre><code><em># \/usr\/bin\/python<\/em>\r\n<em># License: GPL 2.0<\/em>\r\n<em># edited by Ingmar B. Aug.2015<\/em>\r\n\r\n<em>import os<\/em>\r\n<em>from time import *<\/em>\r\n<em>import time<\/em>\r\n<em>import threading<\/em>\r\n<em>import hyt939o <\/em>\r\n<em>import RPi.GPIO as GPIO<\/em>\r\n\r\n<em># Setup LED Ports (pin12 = LED rot, pin18 = LED gruen)<\/em>\r\n<em>GPIO.setwarnings(False)<\/em>\r\n<em>GPIO.setmode(GPIO.BOARD)<\/em>\r\n<em>GPIO.setup(12, GPIO.OUT)<\/em>\r\n<em>GPIO.setup(18, GPIO.OUT)<\/em>\r\n<em>GPIO.setup(16, GPIO.IN)<\/em>\r\n\r\n<em># LED Gruen einschalten sobald das Script gestartet ist<\/em>\r\n<em>GPIO.output(18, GPIO.HIGH)<\/em>\r\n\r\n<em>#gpsd = None #seting the global variable<\/em>\r\n<em>address = [0x2a, 0x29] <\/em>\r\n<em>#hyt939 = [0, 0]<\/em>\r\n<em>hum = [0, 0]<\/em>\r\n<em>temphyt = [0, 0]<\/em>\r\n<em>loopon = True &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;#set variable for loop<\/em>\r\n<em>i=1 &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;#counter for address selection<\/em>\r\n<em>os.system('clear') &nbsp;&nbsp; &nbsp;#clear the terminal (optional)<\/em>\r\n<em>&nbsp;<\/em>\r\n<em>while loopon:<\/em>\r\n<em>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # bei beginn des auslesens aller daten die rote Led einschalten<\/em>\r\n<em>&nbsp;&nbsp; &nbsp;GPIO.output(12, GPIO.HIGH)<\/em>\r\n<em>&nbsp;&nbsp; &nbsp;if GPIO.input(16)== GPIO.HIGH:<\/em>\r\n<em>&nbsp;&nbsp;&nbsp; &nbsp; loopon = False<\/em>\r\n<em>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; os.system('clear')<\/em>\r\n<em>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;<\/em>\r\n<em>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # Variablen fuer Sensor HYT 939 uebergeben <\/em>\r\n<em>&nbsp;&nbsp; &nbsp;for i in range(2):<\/em>\r\n<em>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<\/em>\r\n<em>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;hyt939=hyt939o.ReadMeasurement(address[i])&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<\/em>\r\n<em>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;time.sleep(0.1)<\/em>\r\n<em>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;hum[i]=hyt939[0]<\/em>\r\n<em>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;temphyt[i]=hyt939[1]<\/em>\r\n<em>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;<\/em>\r\n<em>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;print '--------------------------------------- '<\/em>\r\n<em>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;print 'SENSORS reading Sensor Nr.:' , i<\/em>\r\n<em>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;print<\/em>\r\n<em>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;print 'humidity&nbsp;&nbsp;&nbsp; hyt939&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' , hum[i]<\/em>\r\n<em>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;print 'temperature hyt939&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' , temphyt[i]<\/em>\r\n<em>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;print '--------------------------------------- '<\/em>\r\n<em>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;print<\/em>\r\n<em>&nbsp;&nbsp; &nbsp;print 'data to write:' , str(hum[0]), str(temphyt[0]), str(hum[1]), str(temphyt[1])<\/em>\r\n<em>&nbsp;&nbsp; &nbsp;print (\"date :\" + time.strftime(\"%x\"))&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;<\/em>\r\n<em>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print (\"time :\" + time.strftime(\"%X\"))<\/em>\r\n<em>&nbsp;&nbsp; &nbsp;print<\/em>\r\n<em>&nbsp;&nbsp; &nbsp;date = time.strftime(\"%x\")<\/em>\r\n<em>&nbsp;&nbsp; &nbsp;zeit = time.strftime(\"%X\")<\/em>\r\n<em>&nbsp;&nbsp; &nbsp;<\/em>\r\n<em>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ## write all data to usbstick<\/em>\r\n<em>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;<\/em>\r\n<em>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fileout = open(\"\/media\/usbstick\/wetterfrosch.txt\", \"a\")<\/em>\r\n\r\n<em>&nbsp;&nbsp; &nbsp;time.sleep(0.1)<\/em>\r\n\r\n<em>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fileout.write(date+\";\"+zeit+\";\"+str(hum[0])+\";\"+str(temphyt[0])+\";\"+str(hum[1])+\";\"+str(temphyt[1])+\"\\n\") <\/em>\r\n<em>&nbsp;&nbsp; &nbsp;<\/em>\r\n<em>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; time.sleep(0.1)<\/em>\r\n<em>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fileout.close()<\/em>\r\n<em>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; time.sleep(0.1)<\/em>\r\n\r\n<em>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # nach schreiben bzw auslesen der daten rote LED wieder abschalten<\/em>\r\n<em>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GPIO.output(12, GPIO.LOW)<\/em>\r\n<em>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; time.sleep(0.8) #set to whatever<\/em>\r\n\r\n<em>GPIO.output(18, GPIO.LOW) # gruene Led ausschalten<\/em>\r\n\r\n<\/code><em><code>print \"Ende\"<\/code> <\/em><\/pre>\n<p>Das folgende Listing liest den Sensor aus:<\/p>\n<p><em><code># Reading mesaurements from HYT 939 humidity and temperature sensor<\/code><\/em><br \/>\n<em><code> # First Version by Caerandir May 2014 modified by i.bihlo 2015<\/code><\/em><\/p>\n<p><em><code>import smbus, time<\/code><\/em><br \/>\n<em><code> bus = smbus.SMBus(1)&nbsp;&nbsp;&nbsp; # Raspberry Rev. 2<\/code><\/em><br \/>\n<em><code> address = 0x28&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # Fixed default address of HYT 939<\/code><\/em><\/p>\n<p><em><code># Initialize sensor to acquire measurements<\/code><\/em><br \/>\n<em><code> def MeasurementRequest():<\/code><\/em><br \/>\n<em><code> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; void = bus.write_quick(address)<\/code><\/em><br \/>\n<em><code> &nbsp;&nbsp; &nbsp;time.sleep(0.1)<\/code><\/em><\/p>\n<p><em><code># Read Humidiy and Temperature to 14 bit accuracy<\/code><\/em><br \/>\n<em><code> def ReadMeasurement():<\/code><\/em><br \/>\n<em><code> &nbsp;&nbsp; &nbsp;void= bus.write_quick(address)<\/code><\/em><\/p>\n<p><em><code>&nbsp;&nbsp; &nbsp;time.sleep(0.1)&nbsp;&nbsp; &nbsp;<\/code><\/em><br \/>\n<em><code> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # Acquire 4 byte from sensor<\/code><\/em><br \/>\n<em><code> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #time.sleep(0.1)<\/code><\/em><br \/>\n<em><code> &nbsp;&nbsp; &nbsp;Readout = bus.read_i2c_block_data(address,0,4)<\/code><\/em><\/p>\n<p><em><code>&nbsp;&nbsp; &nbsp;# Calculiere die relLF in % aus den vier Bytes in \"Readout\"<\/code><\/em><br \/>\n<em><code> &nbsp;&nbsp; &nbsp;RelHum = Readout[0]&lt;&lt;8 | Readout[1]<\/code><\/em><br \/>\n<em><code> &nbsp;&nbsp; &nbsp;RelHum = RelHum &amp; 0x3FFF<\/code><\/em><br \/>\n<em><code> &nbsp;&nbsp; &nbsp;RelativeHumidity = 100*RelHum\/(2**14)<\/code><\/em><\/p>\n<p><em><code>&nbsp;&nbsp; &nbsp;# Calculiere die Temperatur vom Sensor <\/code><\/em><br \/>\n<em><code> &nbsp;&nbsp; &nbsp;Readout[3] = Readout[3] &amp; 0x3F<\/code><\/em><br \/>\n<em><code> &nbsp;&nbsp; &nbsp;temp = Readout[2]&lt;&lt;6 | Readout[3]<\/code><\/em><br \/>\n<em><code> &nbsp;&nbsp; &nbsp;Temperature = 165.0*temp\/(2**14)-40<\/code><\/em><br \/>\n<em><code> &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<\/code><\/em><br \/>\n<em><code> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print \"Hrel: \", RelativeHumidity, \" %\"<\/code><\/em><br \/>\n<em><code> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print \"T: \", Temperature, \" C\"<\/code><\/em><\/p>\n<p><em><code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return RelativeHumidity, Temperature<\/code><\/em><\/p>\n<p><em><code>MeasurementRequest()<\/code><\/em><br \/>\n<em><code> time.sleep(0.2)<\/code><\/em><\/p>\n<p><em><code>ReadMeasurement()<\/code><\/em><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify\">Eine Versuchsmessung \u00fcber einen Tag und eine Nacht mit drei Sensoren hat folgendes Ergebnis geliefert. Hier sind die Temperaturwerte der Sensoren dargestellt. (Die Daten vom USB-Stick wurden mit Matlab importiert und daraus ein Plot erstellt.)<\/p>\n<p><a href=\"http:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2015\/11\/temperature_3sensoren.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-1091\" src=\"http:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2015\/11\/temperature_3sensoren-1024x685.jpg\" alt=\"temperature_3sensoren\" width=\"800\" height=\"535\" srcset=\"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2015\/11\/temperature_3sensoren-1024x685.jpg 1024w, https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2015\/11\/temperature_3sensoren-300x201.jpg 300w, https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2015\/11\/temperature_3sensoren.jpg 1213w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_1049\" class=\"pvc_stats all  \" data-element-id=\"1049\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n<p>In Teil1 dieses Projektes haben wir dem Raspberry ein Betriebssystem verpasst und das ein wenig f\u00fcr die Anwendung aufbereitet. Wir wollen ja an den PI mehrere Sensoren anschlie\u00dfen und diese dann zyklisch auslesen und die Daten in einer Datei auf einem USB-Stick speichern. Die Aufzeichnung soll so lange laufen, bis ein Taster gedr\u00fcckt wird, der&hellip; <br \/> <a class=\"read-more\" href=\"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/2015\/11\/16\/raspberry-als-datenlogger-teil2-die-sensoren-und-python\/\">Weiterlesen<\/a><\/p>\n","protected":false},"author":86,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"ngg_post_thumbnail":0,"footnotes":""},"categories":[57,1186],"tags":[337,338,342,346,336,339,343,344,340,341,345],"class_list":["post-1049","post","type-post","status-publish","format-standard","hentry","category-elektronikbastler","category-raspberrypi","tag-feuchtesensor-hyt","tag-feuchtesensor-i2c","tag-feuchtesensoren-mit-pi","tag-hyt-sensoren-mit-python-auslesen","tag-hyt939","tag-i2c-bus-raspberry","tag-pi2","tag-python","tag-raspberry-datenlogger","tag-raspberry-pi","tag-raspberry-python"],"a3_pvc":{"activated":true,"total_views":711,"today_views":0},"_links":{"self":[{"href":"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-json\/wp\/v2\/posts\/1049","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-json\/wp\/v2\/users\/86"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-json\/wp\/v2\/comments?post=1049"}],"version-history":[{"count":0,"href":"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-json\/wp\/v2\/posts\/1049\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-json\/wp\/v2\/media?parent=1049"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-json\/wp\/v2\/categories?post=1049"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-json\/wp\/v2\/tags?post=1049"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}