Minimal FastAPI + Tailwind web UI that shows live CPU temperature and Raspberry Pi 5 Active Cooler fan speed (RPM + % of 8000 max). The backend only reads when the browser polls /api/stats, so no commands or sysfs reads occur when nobody is connected.
- Raspberry Pi OS with
vcgencmdavailable (usually/usr/bin/vcgencmd) - Docker and Docker Compose
docker compose build
docker compose up -dThen open http://<raspberry-pi-ip>:9000/ in your browser.
docker-compose.ymlbind-mounts:/usr/bin/vcgencmd:/usr/bin/vcgencmd:rofor temperature./sys:/sys:roso the app can find/sys/devices/platform/cooling_fan/hwmon*/fan1_inputfor fan RPM.
- Devices:
- Raspberry Pi 5:
/dev/vcio; older Pis:/dev/vchiq. Set thedevices:entry to whichever exists.
- Raspberry Pi 5:
- Adjust the vcgencmd path if
which vcgencmddiffers on your Pi. - If permission issues arise, you can try uncommenting
privileged: true(not recommended unless necessary).
main.py— FastAPI app with/(HTML) and/api/stats(JSON: temp + fan rpm/%).templates/index.html— Tailwind CDN UI with 1s polling, starts/stops on focus/blur; shows temp, fan rpm, fan percent, diagnostics.requirements.txt— Python deps (fastapi, uvicorn, jinja2).Dockerfile,docker-compose.yml— Container build/run setup for Pi.
python -m venv .venv
source .venv/bin/activate # on Windows: .venv\\Scripts\\activate
pip install -r requirements.txt
uvicorn main:app --host 0.0.0.0 --port 9000Visit http://localhost:9000/.
