Skip to content

Monitor Case Internal Temperature #8

Description

@RichColvin

As the Rosetta case is currently sealed, there is a possibility that it gets too hot inside. There are several ways to monitor this. One is to use Python to read the internal temperature of the Pi. I'll paste in the python that Chat generated for this. This is very simple, but the Pi is quite far from the expected hot spot of a driver, so it's a bit of a lagging indicator.

Another is to use some instrumentation that is not in production units to monitor it during a test.
Finally we could add a temperature sensor on the Pi's hat and place it where we want it.

To have a fair test, we need to measure the difference in load (PSU current?) between a motor that is fully loaded (spindle) compared to one with no load (no belt). A fair test would have to have all motors running with some load.

#!/usr/bin/env python3
import time
import csv
from datetime import datetime
import os

--- Config ---

INTERVAL = 10 # seconds between samples (set N here)
CSV_FILE = "pi_temps.csv"

def get_temp_c():
"""Read CPU temp from sysfs (works on Pi OS)."""
with open("/sys/class/thermal/thermal_zone0/temp", "r") as f:
t = int(f.read().strip())
return t / 1000.0 # value is in millidegrees C

If the file does not exist, create it and add header row

if not os.path.exists(CSV_FILE):
with open(CSV_FILE, "w", newline="") as f:
writer = csv.writer(f)
writer.writerow(["timestamp", "temperature_C"])

print(f"Logging temperature to {CSV_FILE} every {INTERVAL} seconds. Press Ctrl+C to stop.")

try:
while True:
temp_c = get_temp_c()
now = datetime.now().isoformat()
with open(CSV_FILE, "a", newline="") as f:
writer = csv.writer(f)
writer.writerow([now, temp_c])
time.sleep(INTERVAL)
except KeyboardInterrupt:
print("\nStopped logging.")

The tool seems to have interpreted the python as markdown.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions