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';
// Check for Raspberry Pi model selection or default to RPi
$selectedRPi = isset($_GET['rpi']) ? $_GET['rpi'] : 'RPi';
// Define styles for light and dark themes
if ($theme === 'light') {
$bgColor = 'ffffff';
$textColor = '000000';
$linkColor = '0000ff';
} else {
$bgColor = '000000';
$textColor = 'ffffff';
$linkColor = '00ff00';
}
// Define Raspberry Pi models for the dropdown
$rpiModels = ['RPi', 'RPi0', 'RPi0W', 'RPi3', 'RPi4', 'RPi5'];
?>
<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" style="margin-bottom: 10px;">
<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>
<!-- Raspberry Pi model selection form -->
<form method="get">
<label for="rpi">Choose a Raspberry Pi:</label>
<select name="rpi" id="rpi" onchange="this.form.submit()">
<?php foreach ($rpiModels as $model): ?>
<option value="<?php echo $model; ?>" <?php echo $selectedRPi === $model ? 'selected' : ''; ?>>
<?php echo $model; ?>
</option>
<?php endforeach; ?>
</select>
<input type="hidden" name="theme" value="<?php echo $theme; ?>">
</form>
<?php
echo '<font color="'.$bgColor.'"><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>' . $selectedRPi . ' ' . $temp . '</title>';
echo '</head>';
echo $selectedRPi . ' ' . $temp . ' ' . $speed . 'GHz';
?>
</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