---
title: "Build squirrel detector with sprinkler trigger"
description: "Frigate squirrel detection on Raspberry Pi 5 with the Sixfab AI HAT+ (DEEPX DX-M1M): a single-class model and an MQTT sprinkler trigger; no valve wired yet."
url: "https://docs.sixfab.com/projects/ai-hat-plus/build-squirrel-detector-sprinkler-trigger/"
last_updated: "2026-10-12"
---

# Build squirrel detector with sprinkler trigger

Detect squirrels in Frigate with a single-class model on the AI HAT+ NPU and publish an MQTT sprinkler trigger from a listener on the Raspberry Pi 5. No valve is wired.

**Works with:** [AI HAT+](https://docs.sixfab.com/edge-ai/ai-hat-plus/) on Raspberry Pi 5

![Frigate debug view with Bounding Boxes on: a squirrel in a box labeled Squirrel 92%, followed by a second number from Frigate's debug overlay](https://docs.sixfab.com/wp-content/uploads/sixfab-docs/08-squirrel-detector-box-92-percent-in-frigate-debug-view.png)

**Figure 1** Frigate’s debug view with Bounding Boxes on, showing one squirrel detection at `Squirrel: 92%`.

## How it works

A single-class squirrel model runs as a native Frigate detector on the [Sixfab AI HAT+ for Raspberry Pi 5](https://shop.sixfab.com/products/ai-hat-plus-raspberry-pi-5?utm_source=docs.sixfab.com&utm_medium=referral&utm_campaign=ai-projects&utm_content=squirrel-detector-sprinkler-frigate) (DEEPX DX-M1M): Frigate’s DEEPX detector runs it on the NPU, and the rule logic runs on the Raspberry Pi 5 CPU, in a listener that turns each squirrel event into an MQTT sprinkler trigger. The project is part of the [Raspberry Pi 5 AI projects](https://docs.sixfab.com/projects/ai-hat-plus/choose-ai-hat-plus-project/) series.

1. An RTSP feed reaches Frigate as the camera `garden` (use your own camera name).
2. Frigate’s DEEPX NPU detector runs the squirrel `.dxnn` model on the NPU through the DX-RT runtime.
3. Frigate tracks each squirrel as an event ([Frigate’s record](https://docs.frigate.video/integrations/api/) of one tracked object across many frames) with the label `Squirrel`.
4. Frigate publishes the event to the MQTT broker on the topic `frigate/events` (see [Frigate’s MQTT docs](https://docs.frigate.video/integrations/mqtt/)).
5. The listener, a systemd service that runs under your own user account instead of root, receives the event and checks it against its [score and cooldown rules](https://docs.sixfab.com/projects/ai-hat-plus/build-squirrel-detector-sprinkler-trigger/#listener-rules).
6. The listener’s trigger function publishes a JSON trigger to `squirrel_sprinkler/trigger` and logs a line. A relay and valve would connect here.

Read the detections in Frigate’s web interface at `https://[PI_IP]:8971` and each trigger on the `squirrel_sprinkler/trigger` topic; [Verify](https://docs.sixfab.com/projects/ai-hat-plus/build-squirrel-detector-sprinkler-trigger/#verify) shows both.

## Requirements

**Before starting**

**Set up first, in this order**

- **[AI HAT+ quickstart](https://docs.sixfab.com/edge-ai/ai-hat-plus/quickstart/)**: The HAT mounted and the NPU running on the Raspberry Pi 5
- **[Frigate NVR on Raspberry Pi 5 with the DEEPX NPU](https://docs.sixfab.com/projects/ai-hat-plus/set-up-frigate-nvr-ai-hat-plus/)**: Frigate running with the DEEPX detector and DX-RT
- **[Camera feeds and MQTT for Frigate projects](https://docs.sixfab.com/projects/ai-hat-plus/connect-camera-feeds-mqtt-frigate/)**: The MQTT broker and the camera feed
- **[DIY Raspberry Pi bird camera](https://docs.sixfab.com/projects/ai-hat-plus/identify-bird-species-bird-feeder-camera/) (Optional)**: Can share the same Frigate instance

**Hardware**

- **Raspberry Pi 5**: Host for Frigate and the listener. Tested on the 8 GB model
- **Sixfab AI HAT+ (DEEPX DX-M1M)**: Mounted on the Raspberry Pi 5
- **RTSP camera or stream**: `rtsp://<stream-host>:8554/<stream-path>`

**Software**

- **Raspberry Pi OS Trixie**: The tested OS
- **MQTT broker**: Mosquitto on `<broker-host>`, port 1883
- **`git`, `curl`, `sha256sum`, `ffprobe`**: `ffprobe` comes with ffmpeg
- **`mosquitto_sub`**: For Verify
- **`python3` with `venv`**: The installer adds `paho-mqtt`

> [!NOTE]
> **DEEPX support is in Frigate’s dev branch**
>
> DEEPX support was merged into Frigate’s dev branch on September 21, 2026 (PR #24336) and is not in a stable release yet; the latest stable release is v0.18.0 (September 12, 2026). The `ghcr.io/blakeblackshear/frigate:af0ba19-standard-arm64` image, which the Frigate setup page pulls, is built from commit af0ba19 of the dev branch. Sixfab develops and maintains DEEPX support in Frigate ([Frigate’s DEEPX NPU detector docs](https://github.com/blakeblackshear/frigate/blob/dev/docs/docs/configuration/object_detectors.md)).

## Install

Run the install on the Raspberry Pi 5. It adds the squirrel camera and model to your running Frigate and starts the listener. The installer and the listener are in the project folder of [sixfab-dx-frigate](https://github.com/sixfab/sixfab-dx-frigate) on GitHub; the model is a ready-compiled file from the project’s GitHub release.

**Install script**

Clone the repository and run the installer with your camera’s RTSP URL and your broker host:

```bash
git clone https://github.com/sixfab/sixfab-dx-frigate.git
cd sixfab-dx-frigate/apps/squirrel-sprinkler
./install.sh --rtsp-url [RTSP_URL] --broker [BROKER_HOST]
```

- `--rtsp-url` (string): The RTSP stream of your camera, written into the `garden` camera in your Frigate config.
- `--broker` (string): The MQTT broker host the listener connects to.
- `--yes` (flag): Skips the question before Frigate restarts.
- `--container` (string): Only if your Frigate container differs; the installer finds it itself. Defaults to `frigate`.
- `--config-dir` (string): Only if your Frigate config directory differs; the installer finds it itself.

The installer asks for any value you leave out. It downloads the model from the project’s GitHub release, checks its SHA-256 and runs 5 stages:

1. Checks that your RTSP stream is reachable with `ffprobe`, and stops if it is not.
2. Copies the model and label map into `model_cache` under your Frigate config directory.
3. Backs up `config.yaml`, then merges the project’s camera and model into it with your RTSP URL, without touching other cameras or global settings.
4. Installs the listener as a user-level systemd service, which needs no sudo, with its own `venv` under `~/sixfab-apps/squirrel-sprinkler`. The installed copy of `sprinkler.py` carries your broker host in its `BROKER` constant, and the service file points at your home directory.
5. Asks, then restarts the Frigate container.

![Terminal output of the squirrel sprinkler install.sh: stage headers from 1/5, checking the squirrel RTSP feed is reachable, to 5/5, Frigate container restart, then Install complete](https://docs.sixfab.com/wp-content/uploads/sixfab-docs/08-squirrel-sprinkler-install-sh-five-stages-ending-in-install-complete.png)

**Figure 2** The installer prints one header per stage, from `== 1/5: checking the squirrel RTSP feed is reachable ==` to `== 5/5: Frigate container restart ==`, and ends with `Install complete.`

Figure 2 shows a complete run. To let the listener start at boot without a login, run once:

```bash
sudo loginctl enable-linger $USER
```

**Manual install**

The manual route runs the installer’s steps one at a time.

1. **Check that Frigate runs with the DEEPX detector**

   The `docker run` command for Frigate is in [Set up Frigate with the DEEPX NPU](https://docs.sixfab.com/projects/ai-hat-plus/set-up-frigate-nvr-ai-hat-plus/#install). Use the same `[FRIGATE_CONFIG_DIR]` and `[FRIGATE_MEDIA_DIR]` you set there.

2. **Clone repository and open project folder**

   Keep the whole clone: the installer calls the merge script in the shared `toolkit` folder.

   ```bash
   git clone https://github.com/sixfab/sixfab-dx-frigate.git [REPO_DIR]
   cd [REPO_DIR]/apps/squirrel-sprinkler
   ```

3. **Download model and check it**

   Use the repository address without a trailing `.git` in the download URL.

   ```bash
   curl -fL -o model/squirrel-detector-model.dxnn https://github.com/sixfab/sixfab-dx-frigate/releases/download/squirrel-sprinkler-v1.0.0/squirrel-detector-model.dxnn
   ```

   ```bash
   awk '$1 !~ /^#/ && NF {print $3 "  " $2}' models.txt | sha256sum -c -
   ```

   ```text
   model/squirrel-detector-model.dxnn: OK
   ```

4. **Run installer with your values**

   Run it from the project folder; it is safe to re-run. It reads the config directory from the Frigate container’s `/config` mount; set `CONFIG_DIR` or `CONTAINER` only if yours differ.

   ```bash
   RTSP_URL=[RTSP_URL] BROKER=[BROKER_HOST] ./install.sh
   ```

5. **Restart Frigate**

   Answer `y` when the installer asks to restart Frigate, or set `ASSUME_YES=1` to skip the question. To restart Frigate yourself, run `docker restart frigate`.

6. **Enable linger once**

   Linger lets a user-level systemd service start at boot without a login.

   ```bash
   sudo loginctl enable-linger $USER
   ```

## Verify

API checks run inside the container; the browser reaches Frigate only through the authenticated port 8971. List the recent events of the `garden` camera:

```bash
docker exec frigate curl -s 'http://localhost:5000/api/events?camera=garden&limit=10'
```

The response is JSON; detected squirrels appear with the label `Squirrel`. To see the detections, open `https://[PI_IP]:8971` and select the `garden` camera (or your own camera name). Switch on Bounding Boxes in the debug view to watch each detection, as in Figure 1.

Subscribe to the trigger topic:

```bash
mosquitto_sub -h [BROKER_HOST] -t squirrel_sprinkler/trigger -v
```

Each accepted trigger publishes one JSON message with the camera name, the score and a timestamp, at most one per camera every 30 s. This message was captured in the test:

```text
squirrel_sprinkler/trigger {"camera": "garden", "score": 0.89, "timestamp": 1791272738.7976897}
```

The service status is `active (running)` in `systemctl --user status squirrel-sprinkler-automation.service -l`. At start the listener logs `Connected to broker (<broker-host>:1883), listening on frigate/events`, and each trigger logs `SPRINKLER TRIGGER camera=garden score=<score> (simulated for now)`.

## Details

### Model

The [COCO-80](https://docs.sixfab.com/projects/ai-hat-plus/choose-ai-hat-plus-project/#coco-80) label map that the [Boss Detector project](https://docs.sixfab.com/projects/ai-hat-plus/get-person-alert-camera-boss-detector/) uses has 80 lines and no squirrel entry, so a COCO-80 detector cannot report a squirrel. This project’s model, `squirrel-detector-model.dxnn`, is a single-class squirrel detector compiled to `.dxnn`, DEEPX’s model format; its label map holds one line, `Squirrel`.

### Detection settings

The installer merges these camera and model settings into your Frigate `config.yaml` and replaces the RTSP path with your RTSP URL:

```yaml
models:
  - scene: outdoor
    model_type: yolo-generic
    width: 640
    height: 640
    path: /config/model_cache/squirrel-detector-model.dxnn
    labelmap_path: /config/model_cache/squirrel-only-labelmap.txt
    devices:
      - deepx:PCIe:0

cameras:
  garden:
    ffmpeg:
      inputs:
        - path: rtsp://[STREAM_HOST]:8554/[STREAM_PATH]
          roles:
            - detect
            - record
    detect:
      enabled: true
      width: 1280
      height: 720
      scene: outdoor
    objects:
      track:
        - Squirrel
      filters:
        Squirrel:
          min_score: 0.35
          threshold: 0.5
```

The `scene: outdoor` value ties the `garden` camera to this model, so another project’s camera keeps its own model in the same Frigate instance.

### Listener rules

The listener runs as `squirrel-sprinkler-automation.service`. Its rules are defined at the top of `automation/sprinkler.py`:

| Setting | Value |
| --- | --- |
| Topic | `frigate/events` |
| Label filter | `Squirrel` |
| Event type | Only the first `new` event for each event ID |
| Minimum score | 0.6, read from `top_score`, falling back to `score` |
| Cooldown | 30 s per camera |
| Broker | `BROKER` and `PORT` constants (port 1883) |

Relay or valve control goes in the `trigger_sprinkler()` function of `automation/sprinkler.py`. The function only publishes the trigger and logs a line; its comment suggests driving a relay pin with GPIO or sending a request to a relay HAT’s REST or MQTT interface. After editing it, run `./install.sh` again.

## Limitations

- No relay or valve is connected. The listener publishes and logs each trigger. Valve control is not part of this build, and the valve host (the Raspberry Pi 5, another edge computer or a microcontroller) is undecided. The page gives no wiring, voltages or part numbers because no valve has been tested. Once you add a valve, keep the spray away from paths, doors and neighbors’ property, and check your local water-use rules before you automate a sprinkler.
- No motion-activated sprinkler was tested, so the page makes no comparison with one.
- Nothing is measured for the shipped model: no confidence scores across a test set, accuracy, false-positive rates under real lighting, angles and backgrounds, inference time or skipped frames. Figure 1 and the trigger in Verify are single frames (92% and 0.89), not a measurement. Test with your own camera before you rely on it.
- No night, low-light or rain results exist.
- Training a custom model is not covered.
- The listener ignores events with a score below 0.6, while the Frigate filter tracks squirrels from 0.35. Detections between those values may appear in Frigate without a trigger.
- The installer fixes the listener folder at `~/sixfab-apps/squirrel-sprinkler` and overwrites the installed copy on every run, so edits made directly to `~/sixfab-apps/squirrel-sprinkler/sprinkler.py` are lost. Edit `automation/sprinkler.py` in the repository and run `./install.sh` again.
- The listener connects to the broker on port 1883 without credentials or TLS, so any device that can publish to the broker can send it a fake `frigate/events` message.
- Frigate chooses the DX-RT version its DEEPX detector uses. The tested build pins DX-RT v3.4.0, and this project cannot change it.
- Frigate ran in Docker. Home Assistant OS and the Frigate add-on were not tested.

## Privacy

A garden camera can record people. Aim the camera at your own garden, away from neighbors’ windows and public sidewalks. The `garden` camera input carries the `detect` and `record` roles; if recording is enabled in your Frigate config, Frigate stores recordings in `[FRIGATE_MEDIA_DIR]` under its own retention settings.

Detection runs locally on the Raspberry Pi 5. Frigate downloads the DX-RT Python bindings once at first start, and again when a release pins a new version, so the first start needs internet access.

## Troubleshooting

### A squirrel appears in Frigate but nothing arrives on `squirrel_sprinkler/trigger`

The listener sends a trigger only for an event that passes its rules: see [Listener rules](https://docs.sixfab.com/projects/ai-hat-plus/build-squirrel-detector-sprinkler-trigger/#listener-rules). Check that the service is `active (running)`:

```bash
systemctl --user status squirrel-sprinkler-automation.service -l
```

### Frigate reports too many false squirrels

Raise `min_score` and `threshold` for `Squirrel` in [Detection settings](https://docs.sixfab.com/projects/ai-hat-plus/build-squirrel-detector-sprinkler-trigger/#detection-settings); the listener adds its own minimum score of 0.6. If that is not enough, train a custom model.

### The listener does not start after a reboot

Run `sudo loginctl enable-linger $USER` once.

### Detections stop after the DX-RT daemon restarts

Restart the Frigate container with `docker restart frigate`. The Frigate setup page’s [Troubleshooting](https://docs.sixfab.com/projects/ai-hat-plus/set-up-frigate-nvr-ai-hat-plus/#detections-stop-after-the-dx-rt-daemon-restarts) covers this failure.

### The installer stops at “cannot read” the RTSP URL

Stage 1 of the installer probes the RTSP URL you passed. Start your stream or correct the URL, then run the installer again.

### The installer says the Frigate container was not found

Start Frigate first, or pass `--container` with your container name (`CONTAINER` when you run `install.sh` directly).

### None of these fixes works

Ask in the [Sixfab Community forum](https://community.sixfab.com/).

## Next steps

- [Porch Pirate](https://docs.sixfab.com/projects/ai-hat-plus/catch-package-theft-porch-pirate/): Run a custom model in Frigate
- [Sixfab Model Zoo](https://docs.sixfab.com/edge-ai/ai-model-deployment/sixfab-model-zoo/): Pre-compiled .dxnn models for the NPU
- [Compile your own model](https://docs.sixfab.com/edge-ai/ai-model-deployment/custom-models-dxnn-sdk/workflow/): Convert a model to .dxnn
- [DX-COM configuration reference](https://docs.sixfab.com/edge-ai/ai-model-deployment/custom-models-dxnn-sdk/dx-com-configuration/): Compiler settings for .dxnn models
- [Check NPU load](https://docs.sixfab.com/edge-ai/ai-model-deployment/system-monitoring/): Watch the NPU with dxtop

## License and credits

- **Frigate:** [Frigate NVR](https://frigate.video/), the open-source NVR this project runs in.
- **Model:** `squirrel-detector-model.dxnn` is built on Ultralytics YOLOv8m and licensed under AGPL-3.0. It was trained on two Roboflow datasets under CC BY 4.0. Details are in the [squirrel-sprinkler-v1.0.0 release notes](https://github.com/sixfab/sixfab-dx-frigate/releases/tag/squirrel-sprinkler-v1.0.0).
- **Code:** MIT License.
