surveillance-temperature.sh

Arduino Portenta X8 · File : surveillance-temperature.sh · Language : Bash · Use case : Journaliser la température du SoC et alerter en cas de chauffe

The X8 module can heat up when Docker and Wi-Fi work together: this daemon reads the kernel sensor every 10 s, logs to CSV and pushes a syslog alert past the threshold. Install it as a systemd service.

Hardware

An Arduino Portenta X8 (ST STM32MP1 module: quad Cortex-A7 Linux + dual Cortex-M4 real-time core, 8 GB eMMC, 2 GB LPDDR4, on-board Wi-Fi/BT, optional LTE). None: internal thermal sensor of the SoC.

Wiring

Nothing to wire. Cooling: heatsink or vented case under sustained load.

How it works

The kernel exposes temperature in milli-°C in /sys/class/thermal; the script converts, appends to CSV and uses logger for syslog, readable via journalctl.

Running it

Linux side: SSH access (routed USB-C or network) on the Portenta Linux image, bash/Python scripts. Real-time side: Arduino IDE with the « Arduino Mbed OS Portenta X8 Boards » core, application M7 core, flashing via mboot from Linux.

Variants

Trigger frequency throttling (cpufreq) instead of alerting, or report the temperature to the Arduino core for a heat LED.

surveillance-temperature.sh

#!/bin/bash
# Surveillance thermique du SoC via sysfs, avec seuil et journal.

SEUIL="${SEUIL:-75}"
JOURNAL="/tmp/temp-x8.csv"
[ -f "$JOURNAL" ] || echo "horodatage,temp_c" > "$JOURNAL"

ZONE=$(ls /sys/class/thermal/ | grep ^thermal_zone | head -1)
[ -n "$ZONE" ] || { echo "pas de capteur thermique"; exit 1; }

while true; do
  TEMP=$(( $(cat /sys/class/thermal/$ZONE/temp) / 1000 ))
  echo "$(date -Is),$TEMP" >> "$JOURNAL"
  if [ "$TEMP" -ge "$SEUIL" ]; then
    logger "X8: ALERT temperature ${TEMP}C"
    echo "ALERTE : ${TEMP}C (seuil ${SEUIL}C)"
  else
    echo "temp ${TEMP}C ok"
  fi
  sleep 10
done

# Installer en service systemd (exemple service-systemd)
# pour une surveillance permanente.

← Back to the board