Created
June 9, 2019 15:26
-
-
Save pkramme/4700bf3582d54a92e6d65565a5112ecc to your computer and use it in GitHub Desktop.
Read temp value from DS1820 temp sensor connected to raspberry pi
This file contains hidden or 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
#!/usr/bin/python3 | |
from pathlib import Path | |
import sys | |
devicepath = "/sys/bus/w1/devices/" | |
devicerawtempfile = "w1_slave" | |
with Path(devicepath, sys.argv[1], devicerawtempfile).open() as rawtemp: | |
_, templine = rawtemp.readlines() | |
_, tempinc = templine.rstrip().split("=") | |
print(int(tempinc) / 1000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment