Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
129 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
sudo modprobe w1-gpio | ||
sudo modprobe w1-therm |
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,39 @@ | ||
#!/usr/bin/env python | ||
|
||
import time | ||
|
||
sensorids = ["28-00000534e8db", "28-00000534e8db"] | ||
avgtemperatures = [] | ||
for sensor in range(len(sensorids)): | ||
temperatures = [] | ||
for polltime in range(0,5): | ||
tfile = open("/sys/bus/w1/devices/"+ sensorids[sensor] +"/w1_slave") | ||
# Read all of the text in the file. | ||
text = tfile.read() | ||
# Close the file now that the text has been read. | ||
tfile.close() | ||
# Split the text with new lines (\n) and select the second line. | ||
secondline = text.split("\n")[1] | ||
# Split the line into words, referring to the spaces, and select the 10th word (counting from 0). | ||
temperaturedata = secondline.split(" ")[9] | ||
# The first two characters are "t=", so get rid of those and convert the temperature from a string to a number. | ||
temperature = float(temperaturedata[2:]) | ||
# Put the decimal point in the right place and display it. | ||
temperatures.append(temperature / 1000) | ||
time.sleep(1) | ||
temperatures = sorted(temperatures) | ||
#del temperatures[6] | ||
#del temperatures[0] | ||
avgtemperatures.append(sum(temperatures) / float(len(temperatures))) | ||
import os | ||
|
||
os.system('sudo modprobe w1-gpio') | ||
os.system('sudo modprobe w1-therm') | ||
possSensors = os.listdir('/sys/bus/w1/devices') | ||
#print possSensors | ||
dsSensorId = "28" | ||
for loop in possSensors: | ||
if loop[:2] == "28": | ||
dsSensorId = loop | ||
|
||
temperatures = [] | ||
|
||
for polltime in range(0,5): | ||
tfile = open("/sys/bus/w1/devices/"+ dsSensorId +"/w1_slave") | ||
# Read all of the text in the file. | ||
text = tfile.read() | ||
# Close the file now that the text has been read. | ||
tfile.close() | ||
# Split the text with new lines (\n) and select the second line. | ||
secondline = text.split("\n")[1] | ||
# Split the line into words, referring to the spaces, and select the 10th word (counting from 0). | ||
temperaturedata = secondline.split(" ")[9] | ||
# The first two characters are "t=", so get rid of those and convert the temperature from a string to a number. | ||
temperature = float(temperaturedata[2:]) / 1000.0 | ||
# Put the decimal point in the right place and display it. | ||
|
||
print avgtemperatures | ||
temperatures.append(temperature ) | ||
print temperature | ||
# time.sleep(1) | ||
temperatures = sorted(temperatures) | ||
#del temperatures[6] | ||
#del temperatures[0] | ||
avgtemperature =(sum(temperatures) / float(len(temperatures))) | ||
|
||
print "average" , avgtemperature |