add formel 18
[owPython.git] / owRead.py
1 #!/usr/bin/python
2 # Copyright (c) 2017, Tobias Mueller tm(at)tm3d.de
3 # All rights reserved.
4 #
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are
7 # met:
8 #
9 # * Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
11 # * Redistributions in binary form must reproduce the above copyright
12 # notice, this list of conditions and the following disclaimer in the
13 # documentation and/or other materials provided with the
14 # distribution.
15 # * All advertising materials mentioning features or use of this
16 # software must display the following acknowledgement: This product
17 # includes software developed by tm3d.de and its contributors.
18 # * Neither the name of tm3d.de nor the names of its contributors may
19 # be used to endorse or promote products derived from this software
20 # without specific prior written permission.
21 #
22 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33
34 execfile("owlib.py")
35
36 devlist=owfind("");
37 dc=len(devlist)
38 if dc==0:
39 print "No 1-Wire Device found"
40 exit(0)
41 i=1
42 #for s in devlist:
43 # print("%i) %s" %(i,s))
44 # i=i+1
45 #n=int(raw_input("No. of Device: "))
46 #n=n-1
47 #if (n>dc-1)or(n<0):
48 # exit(0)
49 #s=devlist[n]
50 devobj=[];
51 for s in devlist:
52 if (s[0:2]=="28"):
53 dev=owDS18B20(s)
54 elif (s[0:2]=="20"):
55 dev=owDS2450(s)
56 elif (s[0:2]=="26"):
57 dev=owDS2438(s)
58 elif (s[0:2]=="1d"):
59 dev=owDS2423(s)
60 else:
61 continue
62 dev.readConfig()
63 dev.convertAll()
64 devobj.append(dev)
65
66 str=""
67 for dev in devobj:
68 print dev.getChips()
69 print dev.getProperties()
70 print dev.getUnits()
71
72 while (1):
73 for dev in devobj:
74 dev.convertAll()
75 print dev.owid,dev.values
76 print
77 time.sleep(3)
78
79
80
81 #P0=Press/((1-h/44330)**5.255)