]>
git.frykholm.com Git - heatpump.git/blob - heatpump.py
b003c9f7a64b8642b956fdde79ece7bc58bd1a70
1 import piplates
.DAQCplate
as DAQC
3 from decimal
import Decimal
5 #thermistor reading function
6 def compressor(state
=None):
8 return DAQC
.getDOUTbyte(0)
14 def temp_get(volts
,supply_voltage
=5):
15 divider_resistor
=10000
16 ohms
= Decimal(divider_resistor
*supply_voltage
/volts
-divider_resistor
) #calculate the ohms of the thermisttor
18 a
= Decimal(1.298022762e-3)
19 b
= Decimal(2.365068126e-4)
20 c
= Decimal(0.9305914923e-7)
21 #Steinhart Hart Equation
22 # T = 1/(a + b[ln(ohm)] + c[ln(ohm)]^3)
23 temp
= 1/(a
+ b
*ohms
.ln() + c
*ohms
.ln()**3)
24 tempc
= temp
- Decimal(273.15) #K to C
28 vv_retur
=temp_get(DAQC
.getADC(0,0),DAQC
.getADC(0,8))
29 vv_top
=temp_get(DAQC
.getADC(0,2),DAQC
.getADC(0,8))
30 hetgas
=temp_get(DAQC
.getADC(0,1),DAQC
.getADC(0,8))
31 print("VV retur:",vv_retur
)
32 print("VV top:",vv_top
)
33 print("Hetgas:",hetgas
)
34 print("Kompressor:",compressor())
37 print("Returtemp under 35. Startar kompressor")
40 print("Returtemp över 45. Stänger av kompressor")
41 # import pdb;pdb.set_trace()