forked from bccBalloon/HiBalloon
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemp.py
More file actions
26 lines (22 loc) · 853 Bytes
/
temp.py
File metadata and controls
26 lines (22 loc) · 853 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#Written for the 135-102DAG-J01 Thermistor
import Adafruit_BBIO.ADC as ADC
import time
import math as mt
ADC.setup()
#See June 4 comment on http://ealmberg.blogspot.com/2015/06/4-june-15.html
Bvalue = 3348 #Beta
Ro = 1000 #Resistance at 25 C - room temperature
To = 298.15 #Room temperature Kelvin
while 1 :
adcValue = ADC.read("P9_37")
R = Ro/((1/adcValue) - 1) #Get measured resistance
T = 1.0/To + (1.0/Bvalue)*mt.log(R/Ro) #Formula from above blogspot address
print str(1.0/T) + ' K'
t_c = 1.0/T - 273.15 #Convert to celsius
print str(t_c) + ' ' + u"\u00B0" +'C'
t_f = t_c*(9/5.0) + 32.0 #Convert to Fahrenheit
print str(t_f) + ' ' + unichr(176) + 'F'
print str(adcValue) +', ' + str(1/adcValue) + ', ' + str(1/adcValue - 1) + ', ' + str(R)
#print unichr(176)
#print u"\u00B0"
time.sleep(1)