Introduction: Tab for Pets
Hi ! Welcome on the instructable of the Tab For Pets project.
Tab For Pets aims to :
- Keep your pet busy when you are away ;
- Increase your pet's understanding thanks to challenging games ;
- Provide fun videos of your pet playing games.
The final product is 1 tablet + 1 dispenser. On the tablet an application is running, and when your pet win the game a HTTP POST request is sent to the dispenser. This request activates the servomotor so that the food can drop to the dispenser's feeder. Moreover, an ultrasonic ranger will sense when your pet is near the tablet and it will activate a camera, so that you can have a video of your pet playing the game on the tablet. The image of the architecture describes how it works.
We did not test it because we don't have pet, and there is surely some things to adapt to be efficient. So don't be afraid and adapt/enhance it. :)
Bill of Materials :
- Raspberry Pi 3 B+
- Ultrasonic Ranging Module HC-SR04
- DF Robot Micro Servo 9g DF9GMS
- Raspberry Pi NoIR Camera V2
- Green LED
- 330 Ohms Resistor
- 3D Printer
- Tablet (Or a smartphone) (We use a smartphone for our prototype, but we recommend using a tablet designed for pets since classical screen technology is not adapted for animals).
Software :
- Unity
PREREQUISITES:
You need an account on Cloudinary, since videos are directly uploaded on the platform.
Attachments
Step 1: Setting the RPi
First, we need to load the python code in the RPi. To do that, we recommend using a screen, a mouse and a keyboard, and of course a HDMI connector to connect the RPi to the screen. You must have an internet connection too.
After the boot, Go in :
/home/
and create a folder :
mkdir TabForPets || cd TabForPets
Here, you add the python file : serveurMotorCamControl.py
Then you must install all the required packages.
pip install Flask pip install cloudinary sudo apt-get install -y gpac sudo apt-get install xterm
Now, you must add a config file, so create a config.ini file, and write the following :
['DEFAULT'] CLOUD_NAME = your-cloudinary-name API_KEY = your-api-key API_SECRET = your-api-secret
Replace what is after the "=" with your cloudinary name, key, and secret.
Step 2: Setting Wifi
We recommend using a dedicate wifi channel.
To do this, on the Raspberry Pi, enter :
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf<br>
Add the following lines in it:
network={ ssid="Tab4Pets" psk="password" key_mgmt=WPA-PSK }<br>
You can modify the parameters as you want : Add another network,...
Step 3: Setting the Camera, Sensor, Servomotor
Look at the scheme for the connections.
Camera :
You need to enable the camera interface. To do this, type :
sudo raspi-config
Go to Interfacing Options, then Camera, select Yes, and select Yes to reboot.
To test if the camera is enable :
vcgencmd get_camera
You should have the line supported=1 detected=1, if not try to update :
sudo apt-get update sudo apt-get upgrade
Step 4: Setting Run at Startup
You must add the lxterm-autostart.desktop file that we provide, in the /home/pi/.config/autostart directory
This file contains :
[Desktop Entry]<br>Encoding=UTF-8 Name=Terminal autostart Comment=start a terminal Exec=source /home/pi/TabForPets/env/bin/activate Exec=/usr/bin/lxterm -hold -e "sleep 10; FLASK_APP=/home/pi/TabForPets/serveurMotorCamControl.py flask run --host=0.0.0.0"
Step 5: Print the Dispenser
Get the stl files in annex, and use it to print the dispenser and the other parts thanks to your 3D printer.
You should have : 1 dispenser, 1 screw, 2 cylindrical gears (one for the motor and one for the screw), and 3 assembly equipments.
Step 6: Loading the Application in the Tablet
Simply connect your tablet or smartphone to your PC, and load the iot.apk file that we provide.
Then, on your tablet or smartphone, install the apk.
Step 7: Use of TabForPets
Power the RPI and wait for the Green LED to light.
TabForPets is ready to use.