MMM-PiTemp works in conjunction with MagicMirror2 and tells you the temperature of your raspberry pi's CPU. It runs every 60 seconds and is color-coded based on the temperature. If the temperature is ever greater than 85 degrees then the pi shuts down. Please know that this is a work in progress.
- Change the the directory to MagicMirror/modules:
$ cd MagicMirror/modules - Clone this repo:
$ git clone https://github.com/ckoutavas/MMM-PiTemp - List the contents of MagicMirror/modules to make sure that MMM-PiTemp was cloned:
$ ls - Change the directory to MagicMirror/config:
$ cd ~/MagicMirror/config - Modify your config.js file and add the MMM-PiTemp module:
$ sudo nano config.js
The basic config should look like this
{
module: "MMM-PiTemp",
position: "top_right",
config: {}
},
If everything runs as expected you can customize the config param based on the table below.
| Param | Default Value | Type | Definition |
|---|---|---|---|
| tempUnit | "C" | str | This param is used to assign the units for degrees. It can be "C" for celsius or "F" for fahrenheit |
| freq | 60000 | int | This is how frequently you want to run the temp.py file (in ms), which gets the temperature of the cpu |
| high | 80 | int | This param is used to assign the color to a range: If cpu_temp is greater than high then highColor |
| low | 70 | int | This param is used to assign the color to a range: If cpu_temp is less than low then lowColor |
| highColor | "red" | str | This param is used to assign the color for the high param: If cpu_temp is greater than high then highColor |
| lowColor | "green" | str | This param is used to assign the color for the low param: If cpu_temp is less than low then lowColor |
| otherColor | "yellow" | str | This param is used to assign the color for the else condition: If cpu_temp is less than high AND cpu_temp is greater than low then otherColor |
| label | <i class='fab fa-raspberry-pi'> | str | This param is used to assign the label to the temperature. |
You can updated your ~/MagicMirror/css/custom.css file to add custom styling by using the #pi_temp id
#pi_temp {
font-size: 40px;
}
Make sure python3 is installed on your raspberry pi and that you have the following packages installed: os and gpiozero. You can install the packages using pip3 in the terminal: pip3 install gpiozero. os should be installed by defalut.
If you want to change the temperature at which the pi shuts down then modify the if statement in the temp.py file
if cpu_temp < 85: # change to whatever temp you want
print(cpu_temp)
# if temp is greater than 85 shut down the pi
else:
os.system("sudo shutdown -r now")


