Page 1 of 1

/mnt/1wire

Posted: Wednesday 11 July 2018 23:43
by Pieter
Ds18b20 - Tempsensor.png
Ds18b20 - Tempsensor.png (31.95 KiB) Viewed 771 times
I really do not understand this. How do I address this?

Re: /mnt/1wire

Posted: Thursday 12 July 2018 0:05
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

Re: /mnt/1wire

Posted: Thursday 12 July 2018 20:17
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.