Skip to content

Instantly share code, notes, and snippets.

@xspager
Created June 23, 2016 22:27
Show Gist options
  • Save xspager/bfc1c67efb4a1ecbc43a52d11c14b420 to your computer and use it in GitHub Desktop.
Save xspager/bfc1c67efb4a1ecbc43a52d11c14b420 to your computer and use it in GitHub Desktop.
Keep showing the temperature of the Zynq chip (tested on the Parallella board)
#!/usr/bin/env python2
# coding: utf-8
# based on https://github.com/parallella/parallella-utils/blob/master/xtemp/xtemp.c
import time
offset = int(open("/sys/bus/iio/devices/iio:device0/in_temp0_offset").read())
scale = float(open("/sys/bus/iio/devices/iio:device0/in_temp0_scale").read())
raw_temp_file = open("/sys/bus/iio/devices/iio:device0/in_temp0_raw")
while(True):
raw_temp = raw_temp_file.read()
raw_temp_file.seek(0)
temp = (int(raw_temp) + offset) * scale / 1000
print(u"{:.2f}°C".format(temp))
time.sleep(10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment