Firmware ESP32 che monitora la temperatura della GPU Tesla P40 e regola proattivamente la velocità delle ventole in base al carico CUDA, riducendo rumore e prevenendo thermal throttling.
Il controller legge la temperatura da sensori DS18B20 montati sulla heatsink e dalla GPU via IPMI, calcola la velocità ventola ottimale con un algoritmo PID adattivo, e comanda un MOSFET IRFZ44N per regolare la tensione della ventola 24V.
┌─────────────────────────────────────────────────────────┐
│ ESP32 (ESPHome) │
│ │
│ ┌──────────────┐ ┌──────────────┐ ┌───────────────┐ │
│ │ Sensori Temp │ │ IPMI Client │ │ Curva Ventola│ │
│ │ (DS18B20/ │ │ (NVIDIA │ │ Calcolatore │ │
│ │ LM75) │ │ SMI) │ │ PID/Fuzzy) │ │
│ └──────┬───────┘ └──────┬───────┘ └───────┬───────┘ │
│ │ │ │ │
│ └────────┬────────┘───────────────────┘ │
│ │ │
│ ┌────────▼────────┐ │
│ │ MOSFET Driver │ │
│ │ (PWM → 24V/20V)│ │
│ └────────┬────────┘ │
└──────────────────┼──────────────────────────────────────┘
│
┌──────────┴──────────┐
│ │
┌────▼────┐ ┌────▼────┐
│ Ventola │ │ P40 │
│ 24V │ │ GPU │
│ 2000mA │ │ (IPMI) │
└─────────┘ └─────────┘
| Componente | Specifica | Quantità |
|---|---|---|
| MCU | ESP32-WROOM-32 | 1 |
| Sensori temperatura | DS18B20 (waterproof) | 2 |
| Driver MOSFET | IRFZ44N (logic-level) | 1 |
| Alimentazione ventola | 24V → 5V buck converter | 1 |
| Resistenza pull-up | 4.7kΩ (DS18B20) | 1 |
| Connettore | Molex 4-pin / SATA power | 1 |
| Modulo | Funzione | Pin ESP32 |
|---|---|---|
ds18b20_sensor |
Lettura temperatura GPU/VRAM | GPIO4 (1-Wire) |
ipmi_client |
Comunicazione IPMI via rete | UDP 623 (BMC) |
pwm_output |
Controllo MOSFET ventola | GPIO13 (25kHz) |
web_server |
Dashboard monitoraggio | WiFi → :80 |
ota |
Aggiornamento over-the-air | — |
api |
REST API per host PC | WiFi → :6053 |
- Lettura temperatura: DS18B20 sulla heatsink P40 + VRAM + lettura IPMI GPU temperature
- Lettura carico: NVIDIA SMI via IPMI (power draw, temperature)
- Calcolo ventola: PID adattivo — velocità ventola in funzione di:
- Temperatura P40 (peso principale)
- Power draw GPU (peso secondario, predittivo)
- Trend temperatura (derivate, anti-overshoot)
- Output: PWM 0-100% → MOSFET → regolazione tensione ventola 24V
Temp (°C) PWM (%) Tensione Note
─────────────────────────────────────────
30-40 0-20 4.8-9.6V Standby — silenzioso
40-55 20-50 9.6-14.4V Carico leggero
55-70 50-80 14.4-19.2V Carico medio
70-85 80-100 19.2-24.0V Carico pesante
85+ 100 24.0V Throttling prevention
# Installa ESPHome (se non presente)
pip3 install esphome
# Crea la cartella secrets
mkdir -p ~/.esphome
cat > ~/.esphome/secrets.yaml <<EOF
wifi_ssid: "LA_TUA_WIFI"
wifi_password: "LA_TUA_PASSWORD"
ota_password: "OTA_PASSWORD"
web_admin_user: "admin"
web_admin_pass: "WEB_PASSWORD"
api_password: "API_PASSWORD"
ipmi_bmc_ip: "INDIRIZZO_BMC"
EOFGli indirizzi I2C/1-Wire dei DS18B20 vanno sostituiti con quelli reali. Per trovarli:
# Dopo il primo flash, controlla i log seriali
# oppure usa un scanner 1-Wire
esphome run controller.yaml --device /dev/ttyUSB0Sostituisci in controller.yaml:
address: 0x1A0000000000FF2A # → indirizzo reale DS18B20 heatsink
address: 0x1A0000000000EE3B # → indirizzo reale DS18B20 VRAM# Build e flash via USB
esphome run firmware/esphome/controller.yaml --device /dev/ttyUSB0
# Build e flash OTA (dopo prima connessione WiFi)
esphome run firmware/esphome/controller.yaml
# Build solo (senza flash)
esphome compile firmware/esphome/controller.yaml- Dashboard web:
http://<IP-ESP32>(utente/password da secrets.yaml) - API REST:
http://<IP-ESP32>:6053POST /api/set_fan_speedcon{"speed": 50}(0-100%)GET /api/status→ JSON con tutti i valori
- ESPHome dashboard:
http://<IP-ESP32>(stessa interfaccia web)
Il controller regola automaticamente la ventola in base alla temperatura. Non richiede intervento.
Dalla dashboard web o via API:
# Imposta ventola al 60%
curl -X POST http://<IP-ESP32>:6053 -d '{"service": "set_fan_speed", "speed": 60}'Log seriali ogni 30 secondi:
Temp: heatsink=62.3 VRAM=68.1 GPU=65.4 → Fan=45%
esphome upload firmware/esphome/controller.yaml- Heatsink: 35°C → GPU: 38°C
- Ventola: 10% (silenziosa, ~5V)
- Heatsink: 58°C → GPU: 62°C
- Ventola: 55% (~14V)
- Heatsink: 72°C → GPU: 78°C
- Ventola: 85% (~20V)
- Heatsink: 86°C → GPU: 88°C
- Ventola: 100% (24V full)
controller-termico-proattivo-esp32/
├── README.md # Questo file
├── PROGRESS.md # Storico sviluppo
├── firmware/
│ └── esphome/
│ └── controller.yaml # Configurazione principale ESPHome
├── docs/
│ ├── wiring.md # Schema cablaggi
│ └── calibration.md # Procedura calibrazione
├── hardware/
│ ├── bill-of-materials.md # Lista componenti e costi
│ └── enclosure.md # Design case stampabile
└── schema/
└── wiring-diagram.png # Schema cablaggi
| Layer | Tecnologia |
|---|---|
| Firmware | ESPHome (YAML) + C++ custom |
| Protocollo GPU | IPMI / NVIDIA SMI |
| Sensori | 1-Wire (DS18B20) |
| Controllo | PWM → MOSFET |
| Interfaccia | Web UI ESPHome + API REST |
| Alimentazione | 24V (PSU PC) → 5V (ESP32) |
- ESP32 con ESPHome installato
- GPU NVIDIA con supporto IPMI (P40 sì, via BMC o IPMI tool)
- Ventola 24V compatibile con regolazione tensione (2000mA @ 24V)
- Alimentazione 24V disponibile (connettore Molex/SATA PSU)
La Tesla P40 non ha ventole integrate — viene raffreddata da ventole del case. Il controller regola la tensione delle ventole esistenti (o ne aggiunge una dedicata) per ottimizzare il raffreddamento in base al carico reale della GPU.
Temperatura operativa: 0-89°C (throttle a 89°C). Temperatura target con controller: 64-75°C sotto carico.
COMPLETATO — 2026-06-06
Fase 1/4 completata: struttura directory, README.md con architettura completa, firmware ESPHome base con sensori DS18B20, IPMI client, PWM control, web server, API REST, LED status, heartbeat.