Created
June 14, 2026 06:44
-
-
Save theking2/6b61bb0caeb470dda06108444d86da0b to your computer and use it in GitHub Desktop.
Decode vcgencmd
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Script: decode_throttled.sh | |
| # Description: Decodes the output of 'vcgencmd get_throttled' on a Raspberry Pi | |
| # Usage: ./decode_throttled.sh | |
| # Run vcgencmd and capture the output | |
| THROTTLED_HEX=$(vcgencmd get_throttled | cut -d'=' -f2) | |
| # Remove '0x' prefix if present | |
| THROTTLED_VAL=$((THROTTLED_HEX)) | |
| echo "=========================================" | |
| echo "Raspberry Pi Throttling Status Decoder" | |
| echo "=========================================" | |
| echo "Raw value: $THROTTLED_HEX (decimal: $THROTTLED_VAL)" | |
| echo "" | |
| # Check if the value is zero (no issues) | |
| if [ $THROTTLED_VAL -eq 0 ]; then | |
| echo "✅ Status: No throttling issues detected" | |
| echo " Your Pi is running normally." | |
| exit 0 | |
| fi | |
| echo "⚠️ Issues detected:" | |
| echo "" | |
| # Function to check a bit and print its meaning | |
| check_bit() { | |
| local bit=$1 | |
| local hex=$2 | |
| local current_msg=$3 | |
| local occurred_msg=$4 | |
| if [ $(($THROTTLED_VAL & $hex)) -ne 0 ]; then | |
| # Check if it's a "current" bit (0-3) or "occurred" bit (16-19) | |
| if [ $bit -le 3 ]; then | |
| echo " 🔴 $current_msg (ACTIVE NOW)" | |
| else | |
| echo " 🟡 $occurred_msg (HAS OCCURRED SINCE BOOT)" | |
| fi | |
| fi | |
| } | |
| # Check each bit according to the table | |
| check_bit 0 0x1 "Undervoltage detected" "Undervoltage has occurred" | |
| check_bit 1 0x2 "Arm frequency capped" "Arm frequency capping has occurred" | |
| check_bit 2 0x4 "Currently throttled" "Throttling has occurred" | |
| check_bit 3 0x8 "Soft temperature limit active" "Soft temperature limit has occurred" | |
| echo "" | |
| echo "=========================================" | |
| echo "Recommendations:" | |
| echo "=========================================" | |
| # Provide specific recommendations based on issues found | |
| if [ $(($THROTTLED_VAL & 0x1)) -ne 0 ] || [ $(($THROTTLED_VAL & 0x10000)) -ne 0 ]; then | |
| echo "🔌 Power Issue:" | |
| echo " - Use official Raspberry Pi 27W (5V/5A) USB-C power supply" | |
| echo " - Check your USB-C cable (use short, thick gauge cable)" | |
| echo " - If using Penta HAT, use dedicated 12V power supply" | |
| echo "" | |
| fi | |
| if [ $(($THROTTLED_VAL & 0x4)) -ne 0 ] || [ $(($THROTTLED_VAL & 0x40000)) -ne 0 ]; then | |
| echo "🌡️ Thermal Issue:" | |
| echo " - Install official Raspberry Pi 5 Active Cooler" | |
| echo " - Ensure adequate case ventilation" | |
| echo " - Check for dust or blocked airflow" | |
| echo "" | |
| fi | |
| if [ $(($THROTTLED_VAL & 0x8)) -ne 0 ] || [ $(($THROTTLED_VAL & 0x80000)) -ne 0 ]; then | |
| echo "🔥 Temperature Warning:" | |
| echo " - CPU temperature exceeded 80°C (soft limit)" | |
| echo " - Improve cooling immediately" | |
| echo " - Reduce CPU load or add active cooling" | |
| echo "" | |
| fi | |
| echo "For real-time monitoring, run: watch -n 1 'vcgencmd get_throttled && vcgencmd measure_temp'" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment