Fork me on GitHub

Herr Knedel/Raspberry PI: Χωρίς θερμότητα για την CPU PI

Created Fri, 14 Feb 2020 00:00:00 +0000 Modified Sat, 02 Apr 2022 09:02:12 +0000 Schwierigkeitsgrad: Es kann etwas länger dauern

185 Words

Αν θέλετε να απενεργοποιήσετε ένα βατόμουρο σε μια συγκεκριμένη θερμοκρασία, τότε βρίσκεστε στο σωστό μέρος. Έχω ένα σενάριο που ελέγχει τη θερμοκρασία της CPU μέσω του Crontab:

#!/bin/sh
#  This script reads the Broadcom SoC temperature value and shuts down if it
#  exceeds a particular value.
#  80ºC is the maximum allowed for a Raspberry Pi.


# Get the reading from the sensor and strip the non-number parts
SENSOR="`/opt/vc/bin/vcgencmd measure_temp | cut -d "=" -f2 | cut -d "'" -f1`"

# -gt only deals with whole numbers, so round it.
TEMP="`/usr/bin/printf "%.0f\n" ${SENSOR}`"

# How hot will we allow the SoC to get?
MAX="78"

if [ "${TEMP}" -gt "${MAX}" ] ; then

 # This will be mailed to root if called from cron
 echo "${TEMP}ºC is too hot!"

 # Send a message to syslog
 /usr/bin/logger "Shutting down due to SoC temp ${TEMP}."

 # Halt the box
 /sbin/shutdown -h now
else
  echo "${TEMP}ºC ok!"
  exit 0
fi

Το σενάριο χρειάζεται τα ακόλουθα δικαιώματα:

x
+
Terminal

$ chmod 775 /usr/local/bin/checkTemp.sh

Πιθανή καταχώρηση crontab:

*/5 * * * * /usr/bin/sudo -H /usr/local/bin/checkTemp.sh >> /dev/null 2>&1