{"id":20533122,"url":"https://github.com/minituff/pet-surfer","last_synced_at":"2026-04-19T06:44:48.870Z","repository":{"id":193159325,"uuid":"435714404","full_name":"Minituff/pet-surfer","owner":"Minituff","description":"A proof-of-concept product that uses AI and Bluetooth LE to keep your pets off the counter-tops.","archived":false,"fork":false,"pushed_at":"2022-05-16T21:34:19.000Z","size":59077,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-16T13:18:15.066Z","etag":null,"topics":["artificial-intelligence","bluetooth-low-energy","nodejs","python","tensorflow"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Minituff.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2021-12-07T02:16:41.000Z","updated_at":"2022-01-03T16:30:27.000Z","dependencies_parsed_at":"2023-09-07T02:49:35.850Z","dependency_job_id":null,"html_url":"https://github.com/Minituff/pet-surfer","commit_stats":null,"previous_names":["minituff/pet-surfer"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Minituff%2Fpet-surfer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Minituff%2Fpet-surfer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Minituff%2Fpet-surfer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Minituff%2Fpet-surfer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Minituff","download_url":"https://codeload.github.com/Minituff/pet-surfer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242138881,"owners_count":20078006,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["artificial-intelligence","bluetooth-low-energy","nodejs","python","tensorflow"],"created_at":"2024-11-16T00:18:50.908Z","updated_at":"2026-04-19T06:44:43.846Z","avatar_url":"https://github.com/Minituff.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Main design\nThis is a \"shark tank\" style product designed to keep your pets from getting on your counter-tops.\nThere currently are very few products that can do this with a clean user experience and high amount of customization.\n\nThis repo serves as a *Proof of Concept* to demonstrate that such a product could exist.\n\nIt would work like this:\n* Use a under cabinet mounted device with a camera facing the counter-tops\n* Use AI to determine if a pet is on the counter\n\t* Hopefully AI can also tell the color of the pet just in case there are multiple dogs\n* Use a collar mounted device which can be shocked/buzzed/noisy if the AI finds they are on the counter\n* Use bleutooth Low Energy beacons to detect presense which also helps with false positives\n\n\u003cbr\u003e\n\n## Demos\n### - **detect.service** 🟡\n\n\u003cimg title=\"detect.service\" src=\"media/detect.gif\" width=\"640\" height=\"360\"/\u003e\n\n### - **noble.service** 🔴\n\u003cimg title=\"noble.service\" src=\"media/noble.gif\" width=\"640\" height=\"480\"/\u003e\n\n\n### - **led-ip.service** 🟢\n\n\u003cimg title=\"led-ip.service\" src=\"media/led-ip-demo.gif\" width=\"400\" height=\"400\"/\u003e\n\n\u003cbr\u003e\n\n## Architecture\nThere are currently 3 linux services which are set to run at boot:\n1. **detect.service**  - Uses the Node.js [noble package](https://github.com/noble/noble) to detect Bluetooth LE beacons. When a beacon is within a certain distance (configurable), turn on the 🔴**RED** light.\n2. **detect.service** - Uses [Tensorflow Lite](https://www.tensorflow.org/lite) to detect the presence of a cat/dog. When a pet is detected for a certain amount of frames (configurable), turn on the 🟡**YELLOW** light. A [Flask](https://flask.palletsprojects.com/) server is also run to view a real-time camera feed plus the AI detection. To see, go here: **http://pi-ip-address:8000**\n3. **led-ip.service** - Runs a python script to *blink* the last octet of the Pi's IP address with the 🟢**GREEN** light.\n\t- This is if you [pre-load the WiFi](https://raspberrypi.stackexchange.com/questions/11631/how-to-setup-multiple-wifi-networks) information on the Raspberry PI and take it to another location, you can quickly identify the IP address to view the PI Cam output. (Not morse code)\n\t- Example IP address: 192.168.1.**152**\n\t\t- **1** blink -\u003e pause -\u003e **5** blinks -\u003e pause -\u003e **2** blinks -\u003e steady on -\u003e *repeat*\n\t- Blinking on and off with no pauses/steady-on means the Pi has **no** IP address\n\t- Three quick flashes equals a \"0\"\n\n\u003cbr\u003e\n\n## Hardware\n- [Raspberry PI 4 (Bundle)](https://www.amazon.com/gp/product/B07TKFKKMP/)\n\t- Includes a basic case, power supply, and heatsinks. *Optional, but recommended*\n\t- Used as the main *hub*.\n- [Raspberry PI Camera Module](https://www.amazon.com/gp/product/B07M9Q43MX/)\n\t- A [USB webcam](https://www.amazon.com/dp/B004FHO5Y6/) will also work for this project, but may require small tweaks in the code.\n\t- For Tensorflow Lite AI pet detection\n- [Pi Traffic Light](https://www.amazon.com/gp/product/B00RIIGD30/)\n\t- Used to *simulate* a pet has been detected.\n\t- These are nice because they do not require a breadboard\n- [Bluetooth Beacon](https://www.amazon.com/gp/product/B085XN9B7N/)\n\t- For pet presence detection\n\t- This particular beacon is highly customizable. Setting the broadcast frequency increases the speed of pet detection at the cost of higher battery consumption.\n- [Micro SD Card](https://www.amazon.com/gp/product/B07XDCZ9J3)\n\t- These are the ones I used, but anything greater than 16gb should work fine\n\n\u003cbr\u003e\n\n## Setup\n### Setup Raspberry Pi\n- Use the [Raspberry PI Imager](https://www.raspberrypi.com/software/)\n\t- The version I used was: `Raspbian GNU/Linux 11 (bullseye) 32bit` which was the default at the time\n- Ensure you are using the `pi` user, unless you want to change ALL the paths\n- Clone this Repo to your `Documents` folder\n\t```bash\n\tcd /home/pi/Documents\n\tgit clone https://github.com/Minituff/pet-surfer.git\n\t```\n\n\u003cbr\u003e\n\n### Install **noble.service**\n1. Install dependencies for the noble service:\n\t```bash\n\tsudo apt-get install node \t\t\t# Install node.js\n\tcd noble\n\tnpm install \t\t\t\t\t# Install dependencies\n\tsudo node app.js \t\t\t\t# Just test if the app works, if it does, quit and proceed to next step\n\t```\n\t- Here you should see the 🔴**RED** light turn on if the BlueCharm is in range\n\t- Quit the script (`ctrl + c`) and move on to the next step\n1. Install, enable and activate the **noble.service**:\n\t```bash\n\tsudo cp services/noble.service /etc/systemd/system/\n\tsudo systemctl enable noble            \n\tsudo systemctl start noble\n\tsudo systemctl --no-page status noble  # Ensure the status is active\n\t```\n\n\u003cbr\u003e\n\n### Install **detect.service** \u0026 **led-ip.service** requirements\n1. Create Python Virtual Enviornment ([venv](https://docs.python.org/3/library/venv.html))\n\t```bash\n\tcd playground\n\tpython3 -m venv /home/pi/.virtualenvs/playground-flql \t# playground-flql is the venv name\n\t```\n\t- I used [this](https://github.com/MichaelAquilina/zsh-autoswitch-virtualenv) module for my ZSH terminal\n\t- If you do not use a venv, then just change the `ExecStart` commands in each *.service* file\n1. Activate the virtual env\n\t```bash\n\tsource /home/pi/.virtualenvs/playground-flql/bin/activate\n\t```\n\t- You WILL need to do this every time you SSH into your PI, unless you use the plugin mentioned above, then the venv will be activated upon cd'ing into the playground folder.\n1. Install requirements\n\t- Install Tensorflow lite using this [guide](https://www.tensorflow.org/lite/guide/python#install_tensorflow_lite_for_python) \n\t- Install remaining reqs for the venv:\n\t```bash\n\tpip install -r requirements.txt \t# This will install the reqs for both scripts\n\t```\n\n\u003cbr\u003e\n\n### Test \u0026 Install **detect.service**\n1. Ensure your venv is active and you are in the `playground` folder\n1. Test **detect.service**\n\t```bash\n\tpython3 detect.py\n\t```\n\t- You should see the flask server start.\n\t- To View the AI pet detection visit: **http://your-pi-ip:8000**\n\t- Here you should see the 🟡**YELLOW** turn on if the AI detects a Pet.\n\t- Quit the script (`ctrl + c`) and move on to the next step\n1. Install, enable and activate the **detect.service**:\n\t```bash\n\tsudo cp services/detect.service /etc/systemd/system/\n\tsudo systemctl enable detect            \n\tsudo systemctl start detect\n\tsudo systemctl --no-page status detect  # Ensure the status is active\n\t```\n\n\u003cbr\u003e\n\n### Test \u0026 Install **led-ip.service**\n1. Ensure your venv is active and you are in the `playground` folder\n1. Test **led-ip.service**\n\t```bash\n\tpython3 led-ip.py\n\t```\n\t- Here you should see the 🟢**GREEN** blink the PI's IP address (see above to decode)\n\t- Quit the script (`ctrl + c`) and move on to the next step\n1. Install, enable and activate the **led-ip.service**:\n\t```bash\n\tsudo cp services/led-ip.service /etc/systemd/system/\n\tsudo systemctl enable led-ip            \n\tsudo systemctl start led-ip\n\tsudo systemctl --no-page status led-ip  # Ensure the status is active\n\t```\n\n\u003cbr\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n\n## Useful Links and other tutorials\nThese links and videos really helped me out:\n* [Pet Detection YouTube Link](https://www.youtube.com/watch?v=gGqVNuYol6o\u0026t=5s)\n* [L1 Linux Guides](https://forum.level1techs.com/t/bluetooth-presence-detection-for-home-automation-the-level1-way/148516) and [YouTube Link](https://www.youtube.com/watch?v=7vm7oL4JDi8*)\n* [Monitor](https://github.com/andrewjfreyer/monitor) - MQTT trigger of detection\n* [BlyPy](https://github.com/IanHarvey/bluepy)\n* Enable RDP [Video](https://www.youtube.com/watch?v=IfzBPi4FHpI)\n* Sending Texts Free [Youtube](https://www.youtube.com/watch?v=4-ysecoraKo)   - [Python Script](https://www.reddit.com/r/Python/comments/8gb88e/free_alternatives_to_twilio_for_sending_text/)\n* [Capstone](https://gitlab.com/mark-matura/ble-ips-rpi-client)\n* [Beacons - nice video](https://www.youtube.com/watch?v=keruN9f92so)\n* [iBeacon](https://www.hackster.io/memoryleakyu/diy-ibeacon-and-beacon-scanner-with-raspberry-pi-and-hm13-fe558a)\n\n### A somewhat working BT LE Setep\nFollow [this](https://www.thepolyglotdeveloper.com/2018/03/use-nodejs-raspberry-pi-zero-w-scan-ble-ibeacon-devices/) guide. (esure monitor is *not* running or this will break noble)\nFix for Raspberry PI [here](https://github.com/noble/node-bluetooth-hci-socket/issues/107)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fminituff%2Fpet-surfer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fminituff%2Fpet-surfer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fminituff%2Fpet-surfer/lists"}