poe-status-monitor.py

Xerxes Pi 2026 Carrier Board for Raspberry Pi CM4/CM5 Modules · File : poe-status-monitor.py · Language : python · Use case : Surveiller l'état de l'alimentation PoE et la température du CPU via les GPIO et les interfaces système.

Python script to monitor power source (PoE vs USB) and CPU temperature on the Xerxes Pi.

Uses RPi.GPIO library. Check the Xerxes Pi KiCad schematic to confirm the GPIO used for PoE status. Run with sudo python3 script.py. Temperature is read via /sys/class/thermal.

poe-status-monitor.py

#!/usr/bin/env python3
import RPi.GPIO as GPIO
import time
import subprocess
import os

# Pin GPIO dédié au signal de statut PoE (selon schéma Xerxes Pi)
POE_STATUS_PIN = 17

GPIO.setmode(GPIO.BCM)
GPIO.setup(POE_STATUS_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP)

def get_cpu_temp():
    temp_file = "/sys/class/thermal/thermal_zone0/temp"
    if os.path.exists(temp_file):
        with open(temp_file, "r") as f:
            return float(f.read()) / 1000.0
    return 0.0

def check_poe():
    # Sur la Xerxes Pi, un niveau bas indique souvent une source PoE active ou une erreur selon le pontage
    # Ceci est un exemple générique : vérifier le schéma KiCad pour la logique exacte
    status = GPIO.input(POE_STATUS_PIN)
    return "PoE Actif" if status == GPIO.LOW else "USB/Non-PoE"

try:
    while True:
        temp = get_cpu_temp()
        power_src = check_poe()
        print(f"[{time.strftime('%H:%M:%S')}] Temp: {temp:.1f}°C | Source: {power_src}")
        time.sleep(5)
except KeyboardInterrupt:
    GPIO.cleanup()
    print("\nArrêt du moniteur.")

← Back to the board