Python get CPU temperature and display it on image
Task: Get CPU temperature and display it on my clock's screen
Implementation:
# CPU temperature
cpu = CPUTemperature()
degree_sign = u"\N{DEGREE SIGN}"
text = str(int(cpu.temperature)) + degree_sign + "C"
font = ImageFont.truetype('./freefont/FreeMonoBold.ttf', 22)
img_txt = Image.new('L', font.getsize(text), 255)
draw_txt = ImageDraw.Draw(img_txt)
draw_txt.text((0, 0), text, font = font, fill = 0)
image_width = font.getsize(text)
t = img_txt.rotate(90, expand=1)
image.paste(t, (155, 260-image_width[0]))
Result you can see on this post image (fourth line, left corner).
Done.
Hi!
Good, Thanks.
One more thing – It will be good to add set priority of cron job in crontab file:
…
* * * * * root nice -n 19 /home/pi/bin/clock/run.sh
…