<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p>Hallo Andreas,</p>
<p>habe ich in Zeile 10 importiert:</p>
<p><i>#!/usr/bin/python</i><i><br>
</i><i><br>
</i><i>mysqlHost = '127.0.0.1'</i><i><br>
</i><i>mysqlPort = '3306'</i><i><br>
</i><i>mysqlLogin = 'root'</i><i><br>
</i><i>mysqlPass = 'raspberry'</i><i><br>
</i><i>mysqlDatabase = "volkszaehler"</i><i><br>
</i><i><br>
</i><i>import RPi.GPIO as GPIO</i><i><br>
</i><b><i>import sys, time, os, re</i></b><i><br>
</i><i>import MySQLdb</i><i><br>
</i><i><br>
</i><i>GPIO.setmode(GPIO.BOARD)</i><i><br>
</i><i>GPIO.setup(29, GPIO.IN)</i><i><br>
</i><i><br>
</i><i>while True:</i><i><br>
</i><i> input = GPIO.input(29)</i><i><br>
</i><i> print("PUMP-STATUS: " + str(input))</i><i><br>
</i><i><br>
</i><i> db = MySQLdb.connect(host=mysqlHost,
port=int(mysqlPort), user=mysqlLogin, passwd=mysqlPass)</i><i><br>
</i><i> cursor = db.cursor()</i><i><br>
</i><i> cursor.execute("INSERT INTO data(channel_id(34))
(timestamp, value) VALUES (%s,%s);", (Timestamp, str(input))</i><i><br>
</i><i> time.sleep(30.0)</i></p>
<p>Habe das Script jetzt nochmal eingeschrumpft(ohne Übergabe an die
DB):</p>
<p><i>#!/usr/bin/python</i><i><br>
</i><i><br>
</i><i>mysqlHost = '127.0.0.1'</i><i><br>
</i><i>mysqlPort = '3306'</i><i><br>
</i><i>mysqlLogin = 'root'</i><i><br>
</i><i>mysqlPass = 'raspberry'</i><i><br>
</i><i>mysqlDatabase = "volkszaehler"</i><i><br>
</i><i><br>
</i><i>import RPi.GPIO as GPIO</i><i><br>
</i><i>import sys, time, os, re</i><i><br>
</i><i><br>
</i><i>GPIO.setmode(GPIO.BOARD)</i><i><br>
</i><i>GPIO.setup(29, GPIO.IN)</i><i><br>
</i><i><br>
</i><i>while True:</i><i><br>
</i><i> input = GPIO.input(29)</i><i><br>
</i><i> print("PUMP-STATUS: " + str(input))</i><i><br>
</i><i> time.sleep(30.0)</i></p>
<p>Das funktioniert schonmal:<br>
</p>
<p><i>pi@raspberrypi:~ $ sudo /test01.py</i><i><br>
</i><i>PUMP-STATUS: 1</i><i><br>
</i><i>PUMP-STATUS: 0</i><i><br>
</i><i>^CTraceback (most recent call last):</i><i><br>
</i><i> File "/test01.py", line 18, in <module></i><i><br>
</i><i> time.sleep(30.0)</i><i><br>
</i><i>KeyboardInterrupt</i><br>
</p>
<p>Noch eine andere Idee? Beste Grüße<br>
</p>
<div class="moz-cite-prefix">Am 07.10.2016 um 19:36 schrieb Andreas
Goetz:<br>
</div>
<blockquote
cite="mid:0D14958D-EFFA-476B-A17B-92C2BC8EDD3E@gmail.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
Siehe meinen Link- time erstmal importieren?
<div class=""><br class="">
<div>
<blockquote type="cite" class="">
<div class="">On 7 Oct 2016, at 19:35, Torsten <<a
moz-do-not-send="true" href="mailto:t.wisgalla@gmx.de"
class="">t.wisgalla@gmx.de</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<meta content="text/html; charset=utf-8"
http-equiv="Content-Type" class="">
<div bgcolor="#FFFFFF" text="#000000" class="">
<p class="">Hallo Christian,</p>
<p class="">leider noch keine Verbesserung:</p>
<p class=""><i class=""><b class="">pi@raspberrypi:~ $
sudo /test01.py</b></i><i class=""><b class=""><br
class="">
</b></i><i class=""><b class=""> File "/test01.py",
line 23</b></i><i class=""><b class=""><br
class="">
</b></i><i class=""><b class=""> time.sleep(30.0)</b></i><i
class=""><b class=""><br class="">
</b></i><i class=""><b class=""> ^</b></i><i
class=""><b class=""><br class="">
</b></i><i class=""><b class="">SyntaxError: invalid
syntax</b></i></p>
<p class="">Die von Dir erwähnte Script-Zeilen sehen
momentan so aus:</p>
<p class=""> <i class=""><b class="">db =
MySQLdb.connect(host=mysqlHost,
port=int(mysqlPort), user=mysqlLogin,
passwd=mysqlPass)</b></i><i class=""><b class=""><br
class="">
</b></i><i class=""><b class=""> cursor =
db.cursor()</b></i><i class=""><b class=""><br
class="">
</b></i><i class=""><b class="">
cursor.execute("INSERT INTO data(channel_id(34))
(timestamp, value) VALUES (%s,%s);", (Timestamp,
str(input))</b></i><i class=""><b class=""><br
class="">
</b></i><i class=""><b class="">
time.sleep(30.0)</b></i></p>
<p class="">Vielleicht noch eine Idee - Grüße und Danke!<br
class="">
</p>
<br class="">
<div class="moz-cite-prefix">Am 07.10.2016 um 08:33
schrieb Christian Schnellrieder:<br class="">
</div>
<blockquote
cite="mid:CAFse7xQXv8GpDbS64gs0pAkHtwOfRD5dsY_Qx_nxVP15iCrg6A@mail.gmail.com"
type="cite" class="">
<div dir="ltr" class="">Hallo.
<div class=""><br class="">
</div>
<div class="">time.sleep einfach rein rücken.</div>
<div class=""><br class="">
</div>
<div class=""><b class="gmail_msg"
style="color:rgb(33,33,33);font-family:"helvetica
neue",helvetica,arial,sans-serif"><i
class="gmail_msg"> cursr.execute("INSERT INTO
data(channel_id(34)) (timestamp, value) VALUES
(%s,%s);", (Timestamp, str(input))</i></b><b
class="gmail_msg"
style="color:rgb(33,33,33);font-family:"helvetica
neue",helvetica,arial,sans-serif"><i
class="gmail_msg"><br class="gmail_msg">
</i></b><b class="gmail_msg"
style="color:rgb(33,33,33);font-family:"helvetica
neue",helvetica,arial,sans-serif"><i
class="gmail_msg"> time.sleep(30.0)</i></b> <br
class="">
</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">und nicht<br class="">
</div>
<div class=""><br class="">
</div>
<div class=""><b class="gmail_msg"
style="color:rgb(33,33,33);font-family:"helvetica
neue",helvetica,arial,sans-serif"><i
class="gmail_msg"> cursr.execute("INSERT
INTO data(channel_id(34)) (timestamp, value)
VALUES (%s,%s);", (Timestamp, str(input))</i></b><b
class="gmail_msg"
style="color:rgb(33,33,33);font-family:"helvetica
neue",helvetica,arial,sans-serif"><i
class="gmail_msg"><br class="gmail_msg">
</i></b><b class="gmail_msg"
style="color:rgb(33,33,33);font-family:"helvetica
neue",helvetica,arial,sans-serif"><i
class="gmail_msg"> time.sleep(30.0)</i></b> </div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">Grüße<br class="">
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
</div>
<br class="">
<div class="gmail_quote">
<div dir="ltr" class="">Andreas Götz <<a
moz-do-not-send="true"
href="mailto:cpuidle@gmail.com" class="">cpuidle@gmail.com</a>>
schrieb am Fr., 7. Okt. 2016 um 07:38 Uhr:<br
class="">
</div>
<blockquote class="gmail_quote" style="margin:0 0
0 .8ex;border-left:1px #ccc
solid;padding-left:1ex">
<div dir="auto" class="gmail_msg">
<div class="gmail_msg">Google ist Dein Freund-
hat nix mit VZ zu tun:</div>
<div
id="m_-4407505707927402449AppleMailSignature"
class="gmail_msg"><br class="gmail_msg">
</div>
<div
id="m_-4407505707927402449AppleMailSignature"
class="gmail_msg"><a moz-do-not-send="true"
href="http://stackoverflow.com/questions/510348/how-can-i-make-a-time-delay-in-python"
class="gmail_msg" target="_blank">http://stackoverflow.com/questions/510348/how-can-i-make-a-time-delay-in-python</a><br
class="gmail_msg">
<br class="gmail_msg">
Viele Grüße,
<div class="gmail_msg">Andreas</div>
</div>
</div>
<div dir="auto" class="gmail_msg">
<div class="gmail_msg"><br class="gmail_msg">
Am 07.10.2016 um 01:37 schrieb Torsten <<a
moz-do-not-send="true"
href="mailto:t.wisgalla@gmx.de"
class="gmail_msg" target="_blank">t.wisgalla@gmx.de</a>>:<br
class="gmail_msg">
<br class="gmail_msg">
</div>
<blockquote type="cite" class="gmail_msg">
<div class="gmail_msg">
<p class="gmail_msg">Hallo zusammen,</p>
<p class="gmail_msg">habe nun nach
längerem Studium dieses kleine
Python-Script geschrieben, welcher bis
zur print-Ausgabe des PUMP-STATUS(alle
30sec) auch funktioniert:<br
class="gmail_msg">
</p>
<p class="gmail_msg"><b class="gmail_msg"><i
class="gmail_msg">#!/usr/bin/python</i></b><b
class="gmail_msg"><i class="gmail_msg"><br
class="gmail_msg">
</i></b><b class="gmail_msg"><i
class="gmail_msg"><br
class="gmail_msg">
</i></b><b class="gmail_msg"><i
class="gmail_msg">mysqlHost =
'127.0.0.1'</i></b><b
class="gmail_msg"><i class="gmail_msg"><br
class="gmail_msg">
</i></b><b class="gmail_msg"><i
class="gmail_msg">mysqlPort = '3306'</i></b><b
class="gmail_msg"><i class="gmail_msg"><br
class="gmail_msg">
</i></b><b class="gmail_msg"><i
class="gmail_msg">mysqlLogin =
'root'</i></b><b class="gmail_msg"><i
class="gmail_msg"><br
class="gmail_msg">
</i></b><b class="gmail_msg"><i
class="gmail_msg">mysqlPass =
'raspberry'</i></b><b
class="gmail_msg"><i class="gmail_msg"><br
class="gmail_msg">
</i></b><b class="gmail_msg"><i
class="gmail_msg">mysqlDatabase =
"volkszaehler"</i></b><b
class="gmail_msg"><i class="gmail_msg"><br
class="gmail_msg">
</i></b><b class="gmail_msg"><i
class="gmail_msg"><br
class="gmail_msg">
</i></b><b class="gmail_msg"><i
class="gmail_msg">import RPi.GPIO as
GPIO</i></b><b class="gmail_msg"><i
class="gmail_msg"><br
class="gmail_msg">
</i></b><b class="gmail_msg"><i
class="gmail_msg">import sys, time,
os, re</i></b><b class="gmail_msg"><i
class="gmail_msg"><br
class="gmail_msg">
</i></b><b class="gmail_msg"><i
class="gmail_msg">import MySQLdb</i></b><b
class="gmail_msg"><i class="gmail_msg"><br
class="gmail_msg">
</i></b><b class="gmail_msg"><i
class="gmail_msg"><br
class="gmail_msg">
</i></b><b class="gmail_msg"><i
class="gmail_msg">GPIO.setmode(GPIO.BOARD)</i></b><b
class="gmail_msg"><i class="gmail_msg"><br
class="gmail_msg">
</i></b><b class="gmail_msg"><i
class="gmail_msg">GPIO.setup(29, <a
moz-do-not-send="true"
href="http://gpio.in/"
class="gmail_msg" target="_blank">GPIO.IN</a>)</i></b><b
class="gmail_msg"><i class="gmail_msg"><br
class="gmail_msg">
</i></b><b class="gmail_msg"><i
class="gmail_msg"><br
class="gmail_msg">
</i></b><b class="gmail_msg"><i
class="gmail_msg">while True:</i></b><b
class="gmail_msg"><i class="gmail_msg"><br
class="gmail_msg">
</i></b><b class="gmail_msg"><i
class="gmail_msg"> input =
GPIO.input(29)</i></b><b
class="gmail_msg"><i class="gmail_msg"><br
class="gmail_msg">
</i></b><b class="gmail_msg"><i
class="gmail_msg">
print("PUMP-STATUS: " + str(input))</i></b><b
class="gmail_msg"><i class="gmail_msg"><br
class="gmail_msg">
</i></b><b class="gmail_msg"><i
class="gmail_msg"><br
class="gmail_msg">
</i></b><b class="gmail_msg"><i
class="gmail_msg"> db =
MySQLdb.connect(host=mysqlHost,
port=int(mysqlPort),
user=mysqlLogin, passwd=mysqlPass)</i></b><b
class="gmail_msg"><i class="gmail_msg"><br
class="gmail_msg">
</i></b><b class="gmail_msg"><i
class="gmail_msg"> cursor =
db.cursor()</i></b><b
class="gmail_msg"><i class="gmail_msg"><br
class="gmail_msg">
</i></b><b class="gmail_msg"><i
class="gmail_msg">
cursor.execute("INSERT INTO
data(channel_id(34)) (timestamp,
value) VALUES (%s,%s);", (Timestamp,
str(input))</i></b><b
class="gmail_msg"><i class="gmail_msg"><br
class="gmail_msg">
</i></b><b class="gmail_msg"><i
class="gmail_msg"> time.sleep(30.0)</i></b></p>
<p class="gmail_msg">Problem ist jetzt die
Übertragung des Status in die Datenbank.
Wenn ich das Script jetzt starte kommt
folgendes:</p>
<b class="gmail_msg"><i class="gmail_msg">pi@raspberrypi:~
$ sudo /test01.py</i></b><b
class="gmail_msg"><i class="gmail_msg"><br
class="gmail_msg">
</i></b><b class="gmail_msg"><i
class="gmail_msg"> File "/test01.py",
line 23</i></b><b class="gmail_msg"><i
class="gmail_msg"><br
class="gmail_msg">
</i></b><b class="gmail_msg"><i
class="gmail_msg"> time.sleep(30.0)</i></b><b
class="gmail_msg"><i class="gmail_msg"><br
class="gmail_msg">
</i></b><b class="gmail_msg"><i
class="gmail_msg"> ^</i></b><b
class="gmail_msg"><i class="gmail_msg"><br
class="gmail_msg">
</i></b><b class="gmail_msg"><i
class="gmail_msg">SyntaxError: invalid
syntax</i></b> <br class="gmail_msg">
<br class="gmail_msg">
Können die Profis helfen? Wollte es eben
gerne selbst versuchen - jetzt wird die
Luft aber immer dünner.<br
class="gmail_msg">
<br class="gmail_msg">
MfG und besten Dank - Torsten<br
class="gmail_msg">
<p class="gmail_msg"><br class="gmail_msg">
</p>
<br class="gmail_msg">
<div class=" gmail_msg
m_-4407505707927402449moz-cite-prefix
">Am 09.09.2016 um 23:16 schrieb Torsten
Wisgalla:<br class="gmail_msg">
</div>
<blockquote type="cite" class="gmail_msg">
<div class=" gmail_msg
m_-4407505707927402449mail_android_message
" style="line-height:1;padding:0.5em">Hi
Christian, die Pumpe(GPIO) war auch
nach 18:47 noch an! Und die erneute
Anzeige, dass sie wieder an ist(18:48)
ist nur dadurch zu Stande gekommen,
dass ich den GPIO einmal ganz kurz
aus- und wieder angeschaltet habe. Zu
beachten ist ebenfalls, das Intervall:
60, eingestellt ist - also der Graph
zeitlich verzögert dargestellt wird.<br
class="gmail_msg">
Dazu bitte meine vorletzte Mail lesen!<br
class="gmail_msg">
MfG - Torsten <br class="gmail_msg">
-- <br class="gmail_msg">
Diese Nachricht wurde von meinem
Android Mobiltelefon mit GMX Mail
gesendet.</div>
<div class=" gmail_msg
m_-4407505707927402449mail_android_quote
" style="line-height:1;padding:0.3em">Am
09.09.16, 11:58, Christian
Schnellrieder <<a
moz-do-not-send="true"
href="http://schnellrieder.cs/"
class="gmail_msg" target="_blank">schnellrieder.cs</a>@<a
moz-do-not-send="true"
href="http://gmail.com/"
class="gmail_msg" target="_blank">gmail.com</a>>
schrieb:
<blockquote class="gmail_quote
gmail_msg" style="margin:0.8ex 0pt
0pt 0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">
<div class="gmail_msg"> Aber das
sagt die Grafik aus...
<div class="gmail_msg"> Zwischen
18:46 und 18:47 war die Pumpe
an. Ab 18:48 an... dauer noch
unbekannt bis zum nächsten
Wechsel. </div>
<div class="gmail_msg"> <br
class="gmail_msg">
</div>
<div class="gmail_msg"> <br
class="gmail_msg">
</div>
<div class="gmail_msg"> Grüße </div>
</div>
<br class="gmail_msg">
<div class="gmail_quote gmail_msg">
<div class="gmail_msg"> Torsten
Wisgalla <<a
moz-do-not-send="true"
href="mailto:t.wisgalla@gmx.de"
class="gmail_msg"
target="_blank">t.wisgalla@gmx.de</a>>
schrieb am Fr., 9. Sep. 2016 um
11:46 Uhr:<br class="gmail_msg">
</div>
<blockquote class="gmail_quote
gmail_msg" style="margin:0 0 0
0.8ex;border-left:1.0px
rgb(204,204,204)
solid;padding-left:1.0ex">
<div class="gmail_msg">
<div class="gmail_msg">
<div
style="line-height:1;padding:0.5em"
class="gmail_msg"> Das
nach Ende des Rechtecks
der GPIO immer noch an
war. Der Graph würde nur
auf 1 bleiben, wenn der
GPIO ständig gelpulst
würde.<br
class="gmail_msg">
Haben wir, denke ich
geklärt - vz kann momentan
über GPIO nur Impulse -
keine Dauersignale.<br
class="gmail_msg">
Gruß Torsten<br
class="gmail_msg">
--<br class="gmail_msg">
Diese Nachricht wurde von
meinem Android
Mobiltelefon mit GMX Mail
gesendet. </div>
<div
style="line-height:1;padding:0.3em"
class="gmail_msg"> </div>
</div>
</div>
<div class="gmail_msg">
<div class="gmail_msg">
<div
style="line-height:1;padding:0.3em"
class="gmail_msg"> Am
09.09.16, 09:22, Christian
Schnellrieder <<a
moz-do-not-send="true"
href="http://schnellrieder.cs/"
class="gmail_msg"
target="_blank">schnellrieder.cs</a>@<a
moz-do-not-send="true"
href="http://gmail.com/"
class="gmail_msg"
target="_blank">gmail.com</a>>
schrieb: </div>
</div>
</div>
<div class="gmail_msg">
<div class="gmail_msg">
<div
style="line-height:1;padding:0.3em"
class="gmail_msg">
<blockquote class="
gmail_msg gmail_quote
" style="margin:0.8ex
0.0pt 0.0pt
0.8ex;border-left:1.0px
solid
rgb(204,204,204);padding-left:1.0ex">
<div class="gmail_msg">
Hallo Torsten.
<div class="gmail_msg">
<br
class="gmail_msg">
</div>
<div class="gmail_msg">
Eine Frage zu der
Grafik: </div>
<div class="gmail_msg">
Was genau stimmt da
aus deiner Sicht nun
nicht? </div>
<div class="gmail_msg">
<br
class="gmail_msg">
</div>
<div class="gmail_msg">
<br
class="gmail_msg">
</div>
<div class="gmail_msg">
Grüße<br
class="gmail_msg">
<div
class="gmail_msg">
<br
class="gmail_msg">
</div>
<div
class="gmail_msg">
<img
moz-do-not-send="true"
alt="pasted1"
src="http://attachment/Y2lkOjE1NzBkZDI0N2QzZDBjYWQyMjAy"
style="max-width:100.0%" class="gmail_msg">
<div
class="gmail_msg">
<br
class="gmail_msg">
</div>
<div class="
gmail_msg
gmail_quote
">
<blockquote
class="
gmail_msg
gmail_quote
"
style="margin:0
0 0
0.8ex;border-left:1.0px
rgb(204,204,204) solid;padding-left:1.0ex">
<div
class="gmail_msg">
<br
class="gmail_msg">
</div>
</blockquote>
</div>
</div>
</div>
</div>
<div class="gmail_msg">
--<br
class="gmail_msg">
</div>
<div class="gmail_msg">
<p class="gmail_msg">
Von meinem
Smartphone versendet
</p>
</div>
</blockquote>
</div>
</div>
</div>
</blockquote>
</div>
<div class="gmail_msg"> --<br
class="gmail_msg">
</div>
<div class="gmail_msg">
<p class="gmail_msg"> Von meinem
Smartphone versendet </p>
</div>
</blockquote>
</div>
</blockquote>
<br class="gmail_msg">
</div>
</blockquote>
</div>
</blockquote>
</div>
</div>
<div dir="ltr" class="">-- <br class="">
</div>
<div data-smartmail="gmail_signature" class="">
<p dir="ltr" class="">Von meinem Smartphone
versendet</p>
</div>
</blockquote>
<br class="">
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</blockquote>
<br>
</body>
</html>