File tree 1 file changed +12
-9
lines changed 1 file changed +12
-9
lines changed Original file line number Diff line number Diff line change 6
6
ow = OneWire .OneWire (board .D2 )
7
7
ds18 = ds18x20 .DS18X20 (ow )
8
8
9
- print ("Resetting!" ,ow .reset ())
9
+ def pretty_address (addr ):
10
+ return '' .join ('{:02x}' .format (x ) for x in addr )
11
+
12
+ print ("Resetting, found anything?" ,ow .reset ())
10
13
11
14
print ("Found the following 1-Wire devices: " , end = "" )
12
15
for dev in ow .scan ():
13
- address = '' .join ('{:02x}' .format (x ) for x in dev )
14
- print (address )
15
-
16
- print ("Found the following DS18x20 devices: " , end = "" )
17
- for dev in ds18 .scan ():
18
- address = '' .join ('{:02x}' .format (x ) for x in dev )
19
- print (address )
16
+ print (pretty_address (dev ))
17
+ print ("" )
20
18
21
19
while True :
20
+ print ("Found the following DS18x20 devices" )
22
21
for dev in ds18 .scan ():
23
- print (ds18 .read_temp (dev ))
22
+ ds18 .convert_temp ()
23
+ time .sleep (1 )
24
+ print (pretty_address (dev ), ":" , ds18 .read_temp (dev ))
25
+ print ("--------------" )
26
+ time .sleep (1 )
You can’t perform that action at this time.
0 commit comments