cd sentinel_ai
kill $(lsof -ti :5001) 2>/dev/null; pkill -f "python.*main.py" 2>/dev/null
source venv/bin/activate
brew services start ollama
python main.pySSH into the Pi and run:
python3 sentinel_client.py --hub http://<HUB_IP>:5001 --device raspberry-pi-ECE510Or start it permanently via systemd (auto-restarts on crash/reboot):
systemctl --user start sentinel-clientThe Pi streams CPU, memory, disk, network, and ESP32 IoT sensor data (soil moisture, pump voltage, relay state) to the hub every 5 seconds.
- Go to dashboard → Distributed Devices & IoT Nodes tab
- Click raspberry-pi-ECE510 in the sidebar
- Scroll up to the 🌱 IoT Sensors — ESP32 card
Readings update every 2 seconds:
- Soil Moisture % — color-coded: green (wet), yellow (moderate), red (dry)
- Pump Voltage — supply voltage from the external 5V PSU
- Relay / Pump — ON or OFF
- Soil ADC Raw — raw 12-bit ADC reading
- Moisture progress bar
In the IoT Sensors card at the bottom:
| Button | Action |
|---|---|
| ▶ ON | Forces pump relay ON for 5 minutes |
| ■ OFF | Forces pump relay OFF for 5 minutes |
After the 5-minute override, the ESP32 returns to autonomous mode: soil < 40% → pump ON, soil ≥ 40% → pump OFF.
# Trigger CPU spike on hub machine
curl -X POST http://localhost:5001/api/simulate/start/cpu_spike
# Trigger on Pi
curl -X POST http://localhost:5001/api/devices/raspberry-pi-ECE510/queue_command \
-H "Content-Type: application/json" -d '{"action":"stress_cpu"}'
# Watch the pipeline fire:
# Anomaly → AI Diagnosis → Recovery actions
# Check: http://localhost:5001 → Activity LogWithin 30–60 seconds you'll see:
- Anomaly detected — CPU/memory spike flagged
- AI Diagnosis — Groq LLM identifies root cause
- Recovery — algorithmic fix applied (renice, throttle, kill, purge)
curl -X POST http://localhost:5001/api/simulate/start/power_sagSimulates a -0.75V voltage drop on the hub's simulated power metrics. The anomaly detector fires a critical power anomaly within one detection cycle.
curl -X POST http://localhost:5001/api/simulate/stop
pkill -f "python.*main.py"