Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Displat CPU temp on Pimoroni Four letter PHAT
#!/usr/bin/env python
import time
import fourletterphat
from subprocess import Popen, PIPE
Four Letter pHAT:
This example will display your Pi's CPU
temperature in degrees celsius.
Press Ctrl+C to exit.
while True:
# Get temp forom vcgencmd in the format: "temp=XY.Z'C"
# and reduce to the format "XYZC" for display
temperature = Popen(["vcgencmd", "measure_temp"], stdout=PIPE)
temperature ='utf-8')
# Rempve "temp=" and the "." and "'" chars
temperature = temperature[5:].replace(".", "").replace("'", "").strip()
fourletterphat.set_decimal(1, 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment