journal_systeme.py
The LattePanda is a PC: psutil yields temperature, load and disk like any server. A home-made CSV journal watches the machine itself — the first reflex before loading it with compute.
Hardware required
A LattePanda 3 Delta (x86 Intel N5105, Windows 10/11 or Ubuntu) with its Arduino-compatible co-processor (ATmega32U4) wired to the two 50-pin headers. None: internal sensors of the N5105/m3-7Y30.
Wiring
No wiring. On Windows, adapt the CSV path; x86 sensors appear via coretemp/lm-sensors.
How it works
psutil reads kernel counters (cpu_percent samples for 1 s); shutil measures free disk. The per-line flush protects against power cuts. Host side: pip install pinpong then python3. MCU side: the ATmega32U4 shows up as a COM port — program it with the Arduino IDE (« Arduino Leonardo » board).
Going further
A desktop alert (plyer) past 80 °C, or export to Grafana with the official node exporter.
journal_systeme.py
#!/usr/bin/env python3
# Journal systeme de la LattePanda (x86) : temperature, charge, disque.
# sudo apt install psutil (pip) ; lm-sensors pour les sondes x86.
import psutil, time, datetime, shutil, subprocess
def temperature():
try:
t = psutil.sensors_temperatures()
for nom, fils in t.items():
if fils:
return round(fils[0].current, 1), nom
except Exception:
pass
return None, "aucune sonde"
chemin = "/var/log/panda-systeme.csv"
entete = "horodatage,cpu_pct,temp_c,sonde,ram_pct,disque_gb"
with open(chemin, "a") as f:
if f.tell() == 0:
f.write(entete + "\n")
print("Journal tous les 10 s (Ctrl-C pour finir)")
while True:
temp, sonde = temperature()
ligne = [datetime.datetime.now().isoformat(timespec="seconds"),
round(psutil.cpu_percent(interval=1), 1),
temp, sonde,
round(psutil.virtual_memory().percent, 1),
round(shutil.disk_usage("/").free / 1e9, 1)]
f.write(",".join(str(x) for x in ligne) + "\n")
f.flush()
print(ligne)
time.sleep(9)