My SO is Raspbian in Raspberry Pi 2. Im working with nano 2.2.6 I am new to Python. I want to program the temperature sensor D18B20. I got a fantastic guide:
Raspberry Pi Temperature Sensor . When I list devices using:
ls -l /sys/bus/w1/devices/
I would like to get the name of the directory associated with the thermometer as 28 *. I know the name, but I need to make a program to get the name. I worked with this code. But I can not get the full name of the directory.
import os
name = os.path.basename ("sys/bus/w1/devices/28*")
print (name)
Thanks so much for your time and patience. Best regards.
Edited version 0.1b
import glob, os.path
import time
paths = glob.glob("/sys/bus/w1/devices/28-*")
path_names= [os.path.basename(path) for path in paths]
l = list (path_names)
name = l[0]
path_names = "".join(name)
print name
while 1:
tempfile = open ("/sys/bus/w1/devices/name/w1_slave")
source
share