Skip to content

Instantly share code, notes, and snippets.

@anoochit
Created September 28, 2014 15:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anoochit/55ae951cc63d5e5da99b to your computer and use it in GitHub Desktop.
Save anoochit/55ae951cc63d5e5da99b to your computer and use it in GitHub Desktop.
example file for ds18b20 python module
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from time import sleep
from ds18b20 import DS18B20
def main():
sensor = DS18B20()
while True:
temperatures = sensor.get_temperatures([DS18B20.DEGREES_C, DS18B20.DEGREES_F, DS18B20.KELVIN])
print("Kelvin: %f" % temperatures[2])
print("Degrees Celsius: %f" % temperatures[0])
print("Degrees Fahrenheit: %f" % temperatures[1])
print("=====================================")
sleep(1)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment