Press a button, get a dog fortune
There are 7 possible fortunes and 100 possible dogs! I hand-picked 100 dogs from the Dog API and added in a few celebrity dogs too (e.g. friends's dogs, my family dogs, instagram famous dogs). Each dog's vibe matches the fortune.
I have 3 versions of the same script:
fortune.py- CLI interfacefortunate-pi.py- Physical button interface connnected to GPIO pins on a Raspberry Pi Zerofortunate-gui.py- GUI interface, used on a Rasperry Pi 4 + display
Demo of fortunate-gui.py:
444.mov
What to do when starting from a fresh raspberry pi lite install:
On the machine you're sshing from:
- Reset ssh keys so you can ssh in:
ssh-keygen -R <HOST> - Then ssh in
On the raspberry pi:
sudo apt updatesudo apt upgradesudo apt install vim git pip- Set up GitHub ssh keys
- Clone this repo
- cd into
fortunate-button python -m venv envthen install the missing thingpython -m venv envsource env/bin/activatepip install --upgrade bleak Pillow RPi.GPIO gpiozero(or maybe can usepython -m pip install -r requirements.txt?)sudo apt-get install libopenjp2-7sudo pip3 install Pillow --break-system-packages<- needed for running script with root- Start script on launch
sudo vim /etc/rc.local- add:
sudo bash -c 'source /home/vrk/fortunate-button/env/bin/activate > /home/vrk/blink1.log 2>&1' & sudo python3 /home/vrk/fortunate-button/fortune-pi.py &
- get the process id:
sudo ps -ax | grep python sudo strace -p <PID> -e write