Raspberry Pi Transparent Case + Heat Sink (3pcs) Documentation
The Raspberry Pi Transparent Case + Heat Sink (3pcs) is a protective encasement designed specifically for Raspberry Pi single-board computers. This case provides a clear transparent shell that showcases the Raspberry Pi's internal components while maintaining excellent airflow and heat dissipation. The included heat sink ensures efficient heat management, ensuring optimal performance and longevity of the Raspberry Pi.
Material: High-quality transparent plastic
Dimensions: 92mm x 60mm x 21mm (L x W x H)
Weight: 50g (approx.)
Compatible with: Raspberry Pi 3, 3+, 4, and later models
Heat Sink Material: Aluminum alloy
Heat Sink Dimensions: 12mm x 12mm x 6mm (L x W x H)
Thermal Interface Material (TIM): Pre-applied thermal tape
### Example 1: Basic Python Script for Temperature Monitoring
This example demonstrates how to use the Raspberry Pi Transparent Case + Heat Sink to monitor the temperature of the Raspberry Pi using Python.
Raspberry Pi 4 or later model
Raspbian OS (or compatible)
Python 3.x or later
Code
```python
import os
import time
# Import the necessary libraries
import subprocess
while True:
# Get the temperature reading from the system
temp = subprocess.check_output(["vcgencmd", "measure_temp"])
temp = temp.decode("utf-8").strip()
# Print the temperature reading
print("Current Temperature: " + temp)
# Wait for 1 second before taking the next reading
time.sleep(1)
```
This script uses the `vcgencmd` command to retrieve the current temperature of the Raspberry Pi and prints it to the console. The script runs indefinitely, updating the temperature reading every second.
### Example 2: Node.js Script for Real-Time Temperature Monitoring with Web Interface
This example demonstrates how to use the Raspberry Pi Transparent Case + Heat Sink to monitor the temperature of the Raspberry Pi in real-time using Node.js and a web interface.
Raspberry Pi 4 or later model
Raspbian OS (or compatible)
Node.js 14.x or later
Express.js framework
Socket.IO library
Code
```javascript
const express = require('express');
const app = express();
const http = require('http').createServer(app);
const io = require('socket.io')(http);
const shell = require('shelljs');
app.get('/', (req, res) => {
res.sendFile(__dirname + '/index.html');
});
io.on('connection', (socket) => {
console.log('Client connected');
// Get the initial temperature reading
const temp = shell.exec('vcgencmd measure_temp | cut -c 6-7').stdout.trim();
socket.emit('temperature', temp);
// Update the temperature reading in real-time
setInterval(() => {
const temp = shell.exec('vcgencmd measure_temp | cut -c 6-7').stdout.trim();
socket.emit('temperature', temp);
}, 1000);
});
http.listen(3000, () => {
console.log('Server started on port 3000');
});
```
index.html
```html
<!DOCTYPE html>
<html>
<head>
<title>Real-Time Temperature Monitoring</title>
<script src="/socket.io/socket.io.js"></script>
<script>
let socket = io();
socket.on('temperature', (temp) => {
document.getElementById('temperature').innerHTML = `Current Temperature: ${temp}C`;
});
</script>
</head>
<body>
<h1>Real-Time Temperature Monitoring</h1>
<p id="temperature"></p>
</body>
</html>
```
This example sets up a Node.js server with a web interface that displays the current temperature of the Raspberry Pi in real-time. The temperature reading is updated every second using Socket.IO.
Note: These examples assume that the Raspberry Pi has been properly configured and is connected to the internet. Additionally, the provided code is for illustrative purposes only and may require modifications to fit specific use cases.