Skip to content

Instantly share code, notes, and snippets.

@VTSTech
Last active December 19, 2024 21:27
Show Gist options
  • Save VTSTech/465ef06994cfea462094c4ae6de3870d to your computer and use it in GitHub Desktop.
Save VTSTech/465ef06994cfea462094c4ae6de3870d to your computer and use it in GitHub Desktop.
Raspberry Pi RPi Temperature Monitor by VTSTech
<html>
<!-- If you get /dev/vcio error then 'sudo usermod -aG video www-data' -->
<!-- Refreshes every 10 seconds -->
<?php
// Check for theme selection in GET or default to dark theme
$theme = isset($_GET['theme']) && $_GET['theme'] === 'light' ? 'light' : 'dark';
// Define styles for light and dark themes
if ($theme === 'light') {
$bgColor = 'ffffff';
$textColor = '000000';
$linkColor = '0000ff';
} else {
$bgColor = '000000';
$textColor = 'ffffff';
$linkColor = '00ff00';
}
?>
<body bgcolor="<?php echo $bgColor; ?>" text="<?php echo $textColor; ?>" link="<?php echo $linkColor; ?>">
<b><br>Raspberry Pi RPi Temperature Monitor</b>
<br>Written by <b><a href='https://www.vts-tech.org/' style="color:<?php echo $linkColor; ?>">VTSTech</a>
(<a href='https://github.com/VTSTech' style="color:<?php echo $linkColor; ?>">GitHub</a></b>)
<!-- Theme selection form -->
<form method="get">
<label for="theme">Choose a theme:</label>
<select name="theme" id="theme" onchange="this.form.submit()">
<option value="dark" <?php echo $theme === 'dark' ? 'selected' : ''; ?>>Dark</option>
<option value="light" <?php echo $theme === 'light' ? 'selected' : ''; ?>>Light</option>
</select>
</form>
<?php
echo '<font color="'.$textColor.'"><pre>';
$output = system("vcgencmd measure_temp");
$temp = substr($output, 5);
$output = system("vcgencmd measure_clock arm");
$speed = substr($output, 13);
$speed = round($speed/1000000000,1);
echo '</pre></font>';
echo '<head>';
echo ' <meta http-equiv="refresh" content="10">';
echo '<title>RPi '.$temp.' '.$speed.'GHz</title>';
echo '</head>';
echo '<font color="'.$textColor.'">RPi '.$temp.' '.$speed.'GHz</font>';
?>
</body>
</html>
@VTSTech
Copy link
Author

VTSTech commented Dec 18, 2024

image

@VTSTech
Copy link
Author

VTSTech commented Dec 18, 2024

image

@VTSTech
Copy link
Author

VTSTech commented Dec 18, 2024

image

@VTSTech
Copy link
Author

VTSTech commented Dec 18, 2024

image

@VTSTech
Copy link
Author

VTSTech commented Dec 19, 2024

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment