Guten Tag,
ich habe folgendes Problem benötige Hilfe aus dem Forum.
Ich habe einen 1wire Temperatursensor angeschlossen und kann den Status ohne Probleme mit: cd /sys/bus/w1/devices/28-0000065fa6c1 und cat w1_slave
anzeigen lassen. Ich sehe die Temperatur.
Dann wollte ich die Daten in eine RRDatenbank schreiben, aber bevor dies geschehen kann soll über das Skript der Sensor abgefragt werden.
Ich habe die entsprechende Stelle markiert:
Python
#!/usr/bin/python
# -*- coding: utf-8 -*-
import re, os, rrdtool, time
# function: read and parse sensor data file
def read_sensor(path):
value = "U"
try:
f = open(path, "r")
line = f.readline()
if re.match(r"([0-9a-f]{2} ){9}: crc=[0-9a-f]{2} YES", line):
line = f.readline()
m = re.match(r"([0-9a-f]{2} ){9}t=([+-]?[0-9]+)", line)
if m:
value = str(float(m.group(2)) / 1000.0)
f.close()
except (IOError), e:
print time.strftime("%x %X"), "Error reading", path, ": ", e
return value
# define pathes to 1-wire sensor data
[b]pathes = ("/sys/bus/w1/devices/28-0000065fa6c1/w1_slave")[/b]
# read sensor data
data = 'N'
for path in pathes:
data += ':'
data += read_sensor(path)
time.sleep(1)
# insert data into round-robin-database
rrdtool.update(
"%s/temperature.rrd" % (os.path.dirname(os.path.abspath(__file__))),
data)
Display More
Bei pathes = ("/sys/bus/w1/devices/28-0000065fa6c1/w1_slave") gibt er mir bei der Ausführung des Skript folgendes zurück:
Code
pi@ostworld ~ $ ./gettemp.py
06/03/15 23:15:38 Error reading / : [Errno 21] Is a directory: '/'
06/03/15 23:15:39 Error reading s : [Errno 2] No such file or directory: 's'
06/03/15 23:15:40 Error reading y : [Errno 2] No such file or directory: 'y'
06/03/15 23:15:41 Error reading s : [Errno 2] No such file or directory: 's'
06/03/15 23:15:42 Error reading / : [Errno 21] Is a directory: '/'
06/03/15 23:15:43 Error reading b : [Errno 2] No such file or directory: 'b'
06/03/15 23:15:44 Error reading u : [Errno 2] No such file or directory: 'u'
06/03/15 23:15:45 Error reading s : [Errno 2] No such file or directory: 's'
06/03/15 23:15:46 Error reading / : [Errno 21] Is a directory: '/'
06/03/15 23:15:47 Error reading w : [Errno 2] No such file or directory: 'w'
06/03/15 23:15:48 Error reading 1 : [Errno 2] No such file or directory: '1'
06/03/15 23:15:49 Error reading / : [Errno 21] Is a directory: '/'
06/03/15 23:15:50 Error reading d : [Errno 2] No such file or directory: 'd'
06/03/15 23:15:51 Error reading e : [Errno 2] No such file or directory: 'e'
06/03/15 23:15:52 Error reading v : [Errno 2] No such file or directory: 'v'
06/03/15 23:15:53 Error reading i : [Errno 2] No such file or directory: 'i'
06/03/15 23:15:54 Error reading c : [Errno 2] No such file or directory: 'c'
06/03/15 23:15:55 Error reading e : [Errno 2] No such file or directory: 'e'
06/03/15 23:15:56 Error reading s : [Errno 2] No such file or directory: 's'
06/03/15 23:15:57 Error reading / : [Errno 21] Is a directory: '/'
06/03/15 23:15:58 Error reading 2 : [Errno 2] No such file or directory: '2'
06/03/15 23:15:59 Error reading 8 : [Errno 2] No such file or directory: '8'
06/03/15 23:16:00 Error reading - : [Errno 2] No such file or directory: '-'
06/03/15 23:16:01 Error reading 0 : [Errno 2] No such file or directory: '0'
06/03/15 23:16:02 Error reading 0 : [Errno 2] No such file or directory: '0'
06/03/15 23:16:03 Error reading 0 : [Errno 2] No such file or directory: '0'
06/03/15 23:16:04 Error reading 0 : [Errno 2] No such file or directory: '0'
06/03/15 23:16:05 Error reading 0 : [Errno 2] No such file or directory: '0'
06/03/15 23:16:06 Error reading 6 : [Errno 2] No such file or directory: '6'
06/03/15 23:16:07 Error reading 5 : [Errno 2] No such file or directory: '5'
06/03/15 23:16:08 Error reading f : [Errno 2] No such file or directory: 'f'
06/03/15 23:16:09 Error reading a : [Errno 2] No such file or directory: 'a'
06/03/15 23:16:10 Error reading 6 : [Errno 2] No such file or directory: '6'
06/03/15 23:16:11 Error reading c : [Errno 2] No such file or directory: 'c'
06/03/15 23:16:12 Error reading 1 : [Errno 2] No such file or directory: '1'
06/03/15 23:16:13 Error reading / : [Errno 21] Is a directory: '/'
06/03/15 23:16:14 Error reading w : [Errno 2] No such file or directory: 'w'
06/03/15 23:16:15 Error reading 1 : [Errno 2] No such file or directory: '1'
06/03/15 23:16:16 Error reading _ : [Errno 2] No such file or directory: '_'
06/03/15 23:16:17 Error reading s : [Errno 2] No such file or directory: 's'
06/03/15 23:16:18 Error reading l : [Errno 2] No such file or directory: 'l'
06/03/15 23:16:19 Error reading a : [Errno 2] No such file or directory: 'a'
06/03/15 23:16:20 Error reading v : [Errno 2] No such file or directory: 'v'
06/03/15 23:16:21 Error reading e : [Errno 2] No such file or directory: 'e'
Traceback (most recent call last):
File "./gettemp.py", line 35, in <module>
data)
rrdtool.error: /home/pi/temperature.rrd: found extra data on update argument: U:U:U:U:U:U:U:U:U:U:U:U:U:U:U:U:U:U:U:U:U:U:U:U:U:U:U:U:U:U:U:U:U:U:U:U:U:U:U:U:U:U:U
Display More
Wie kann es sein, dass ich in dem Pfad mit cat den 1wire abfragen kann und im Skript die Fehlermeldung kommt der Pfad bzw. die Datei existiert nicht?
Gruß