https://github.com/alpoktem/ritaframe
Cloud-based photo frame using Raspberry Pi, Python Flask, PIR motion sensor and Google Photos API
https://github.com/alpoktem/ritaframe
flask google-photos-api hobby-project photo-frame pir-sensor python raspberry-pi
Last synced: about 2 months ago
JSON representation
Cloud-based photo frame using Raspberry Pi, Python Flask, PIR motion sensor and Google Photos API
- Host: GitHub
- URL: https://github.com/alpoktem/ritaframe
- Owner: alpoktem
- License: gpl-3.0
- Created: 2023-07-16T11:41:34.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-07-21T14:04:57.000Z (almost 2 years ago)
- Last Synced: 2024-12-29T10:37:29.478Z (over 1 year ago)
- Topics: flask, google-photos-api, hobby-project, photo-frame, pir-sensor, python, raspberry-pi
- Language: Python
- Homepage:
- Size: 48.8 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# RitaFrame - Cloud-based Photo Frame for Raspberry Pi
This project turns a Raspberry Pi into a dynamic digital photo frame, capable of displaying images live from a Google Photos album on the browser with a Flask-based app. Optionally, it utilizes motion detection to conserve energy, turning the display off when no activity is detected and on when someone is nearby.
### Why RitaFrame?
I created this during my paternity leave so that my parents who live abroad can see the latest photos of their granddaughter on a frame in the living room. I especially wanted to be the one managing the photos, uploading new ones and removing the old ones. To avoid burning the LCD running all day, I attached a motion sensor and a timer module which controls the screen so that the moment my parents walk in the room, the frame gets activated.
## Hardware Setup
- Raspberry Pi (any model with network connectivity)
- MicroSD card (8 GB or more recommended) with Raspberry Pi OS
- Power supply for the Raspberry Pi
- HDMI-compatible display monitor
- PIR motion sensor
- Jumper wires (for connecting the PIR sensor to the Raspberry Pi)
### PIR motion sensor setup
PIR sensors come with three pins: GND, OUT and VIN. Use the jumper wires to connect GND to a ground pin (e.g. 6), VIN to a power pin (e.g. 2) and OUT to a GPIO pin (e.g. 11, which is GPIO 17). For further information on GPIO pins [check here](https://randomnerdtutorials.com/raspberry-pi-pinout-gpios/).
## Software Setup
1. **Prepare Raspberry Pi OS**: Flash Raspberry Pi OS onto your microSD card using the [Raspberry Pi Imager](https://www.raspberrypi.org/software/) and boot up your Raspberry Pi.
2. **Clone the Repository**:
```bash
git clone https://github.com/alpoktem/RitaFrame.git
cd RitaFrame
```
3. **Install Required Packages**:
Raspberry Pi OS should come with Python3 installed. If not:
```bash
sudo apt-get update
sudo apt-get install -y python3-pip
```
To install required Python libraries:
```bash
pip3 install -r requirements.txt
```
4. **Get a Google Photos client secret file**:
The photos are pulled from the cloud using Google's [Photos Library API](https://developers.google.com/photos/library/reference/rest). To enable the app accessing your photos, you need to download a credentials file from Google Cloud console. There's a good tutorial to do that [here](https://github.com/polzerdo55862/google-photos-api/blob/main/Google_API.ipynb).
5. **Configure Application**:
Edit the `config.py` file to set up the path to your Google Photos API credentials, album name, and other configurations like display and transition times. You can also enable and disable the motion detection here.
6. **Run the Application**:
For development with debugging:
```bash
python3 app.py
```
For production:
```bash
./run.sh
```
You might need to give run access to run.sh by:
```bash
chmod +x run.sh
```
7. **View the app on browser**:
Open your browser and direct it to [localhost:8000](http://localhost:8000) to start viewing the photos on loop.
## Autostart Setup
To have your Raspberry Pi photo frame application start automatically on boot, copy the `autostart` file to `~/.config/lxsession/LXDE-pi`:
```bash
sudo cp etc/lxboot/chromium/autostart ~/.config/lxsession/LXDE-pi
```
Now, when Raspberry Pi boots up, it will open up Chromium browser on kiosk-mode showing the Flask web app.
## Raspberry Pi Zero setup
I wanted to run this on a Zero but it turned out that it's not able to support Chromium. Looking for a lightweight browser alternative, I found [surf](https://surf.suckless.org/).
To install:
```bash
sudo apt-get update
sudo apt-get install surf
```
Surf unfortunately doesn't have a kiosk mode like Chromium. But you can put it to full screen using the F11 key. There are two additional files under `etc/surf` to make it boot up smoothly, first running surf once the web app is ready and then putting it on full screen. The autostart script to automate all this can be installed with the command:
```bash
sudo cp etc/lxboot/surf/autostart ~/.config/lxsession/LXDE-pi/autostart
```
## References
I got inspired and built on top of the work below:
- [samuelclay/Raspberry-Pi-Photo-Frame](https://github.com/samuelclay/Raspberry-Pi-Photo-Frame)
- [polzerdo55862/google-photos-api](https://github.com/polzerdo55862/google-photos-api)
- [Google Photos Library API](https://developers.google.com/photos/library/reference/rest)
## If you like this project
