Advertisement
Guest User

Untitled

a guest
May 2nd, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. # Open the file that we viewed earlier so that python can see what is in it. Replace the serial number as before.
  2. tfile = open("/sys/bus/w1/devices/10-000802824e58/w1_slave")
  3. # Read all of the text in the file.
  4. text = tfile.read()
  5. # Close the file now that the text has been read.
  6. tfile.close()
  7. # Split the text with new lines (\n) and select the second line.
  8. secondline = text.split("\n")[1]
  9. # Split the line into words, referring to the spaces, and select the 10th word (counting from 0).
  10. temperaturedata = secondline.split(" ")[9]
  11. # The first two characters are "t=", so get rid of those and convert the temperature from a string to a number.
  12. temperature = float(temperaturedata[2:])
  13. # Put the decimal point in the right place and display it.
  14. temperature = temperature / 1000
  15. print temperature
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement