- Ds18b20 - Tempsensor.png (31.95 KiB) Viewed 769 times
/mnt/1wire
Moderator: leecollings
- Pieter
- Posts: 8
- Joined: Wednesday 25 April 2018 23:10
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.9700
- Location: Almere, Nederland
/mnt/1wire
I really do not understand this. How do I address this?
Regards,
Pieter
English is not my language.
Forgive me if I make a language mistake
Pieter
English is not my language.
Forgive me if I make a language mistake
- Pieter
- Posts: 8
- Joined: Wednesday 25 April 2018 23:10
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.9700
- Location: Almere, Nederland
Re: /mnt/1wire
# This works sometimes on my other Raspberry.
import os
import os.path
import glob
import time
os.system('modprobe w1-gpio')
os.system('modprobe w1-therm')
# root/sys/bus/devices/28-0517a23d79ff
# file=w1_slave
base_dir = '/sys/bus/w1/devices/'
# device_folder = glob.glob(base_dir + '28*')[0]
device_folder = glob.glob(base_dir + '28-0517a23d79ff')[0]
device_file = device_folder + '/w1_slave'
#
def read_temp_raw():
f = open(device_file, 'r')
lines = f.readlines()
f.close()
return lines
def read_temp(scale):
lines = read_temp_raw()
while lines[0].strip()[-3:]!='YES':
# time.sleep(0.2)
lines = read_temp_raw()
equals_pos = lines[1].find('t=')
if equals_pos != -1:
temp_string = lines[1][equals_pos+2:]
temp_c = float(temp_string) / 1000.0
temp_f = temp_c * 9.0 / 5.0 + 32.0
if scale == "F":
return "{:.1f}".format(temp_f)
if scale =="C":
return "{:.1f}".format(temp_c)
else:
return temp_c, temp_f
while True:
if os.access(device_file, os.R_OK):
filedata=read_temp("C")
print (filedata.replace('.', ','))
# time.sleep(1)
else:
print("De file:\n\n"+device_file+"\n\nof de directory:\n"+device_folder+"\n\nbestaat ineens niet meer
")
time.sleep(0.5)
# break
import os
import os.path
import glob
import time
os.system('modprobe w1-gpio')
os.system('modprobe w1-therm')
# root/sys/bus/devices/28-0517a23d79ff
# file=w1_slave
base_dir = '/sys/bus/w1/devices/'
# device_folder = glob.glob(base_dir + '28*')[0]
device_folder = glob.glob(base_dir + '28-0517a23d79ff')[0]
device_file = device_folder + '/w1_slave'
#
def read_temp_raw():
f = open(device_file, 'r')
lines = f.readlines()
f.close()
return lines
def read_temp(scale):
lines = read_temp_raw()
while lines[0].strip()[-3:]!='YES':
# time.sleep(0.2)
lines = read_temp_raw()
equals_pos = lines[1].find('t=')
if equals_pos != -1:
temp_string = lines[1][equals_pos+2:]
temp_c = float(temp_string) / 1000.0
temp_f = temp_c * 9.0 / 5.0 + 32.0
if scale == "F":
return "{:.1f}".format(temp_f)
if scale =="C":
return "{:.1f}".format(temp_c)
else:
return temp_c, temp_f
while True:
if os.access(device_file, os.R_OK):
filedata=read_temp("C")
print (filedata.replace('.', ','))
# time.sleep(1)
else:
print("De file:\n\n"+device_file+"\n\nof de directory:\n"+device_folder+"\n\nbestaat ineens niet meer

time.sleep(0.5)
# break
Regards,
Pieter
English is not my language.
Forgive me if I make a language mistake
Pieter
English is not my language.
Forgive me if I make a language mistake
-
- Posts: 111
- Joined: Saturday 31 March 2018 22:24
- Target OS: Linux
- Domoticz version: Custom
- Location: Delft, NL
- Contact:
Re: /mnt/1wire
Not quite getting the purpose and/or question meant with this topic.
I did however see your other post today and you might want to make a note that we're not Microsoft Support calling from Ivory Coast with an Indian accent, so we can't actually look onto your system to figure out ourselves what your problem might be.
I did however see your other post today and you might want to make a note that we're not Microsoft Support calling from Ivory Coast with an Indian accent, so we can't actually look onto your system to figure out ourselves what your problem might be.
Who is online
Users browsing this forum: No registered users and 1 guest