/mnt/1wire

Moderator: leecollings

Post Reply
User avatar
Pieter
Posts: 8
Joined: Wednesday 25 April 2018 23:10
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.9700
Location: Almere, Nederland

/mnt/1wire

Post by Pieter »

Ds18b20 - Tempsensor.png
Ds18b20 - Tempsensor.png (31.95 KiB) Viewed 768 times
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
User avatar
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

Post by Pieter »

# 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
Regards,
Pieter

English is not my language.
Forgive me if I make a language mistake
gordonb3
Posts: 111
Joined: Saturday 31 March 2018 22:24
Target OS: Linux
Domoticz version: Custom
Location: Delft, NL
Contact:

Re: /mnt/1wire

Post by gordonb3 »

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.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest