[PYTHON] DigitalSignage with Raspberry Pi

DigitalSignage with Raspberry Pi

Introduction

This is an article about ** Digital Signage with Raspberry Pi **, which won the Raspberry Pi Foundation Award at ** Minna no Raspberry Pi Contest 2019 **. I made it with the aim of digitizing a paper bulletin board and replacing it easily.

Parts used

environment

pydrive (Google Drive API)
pdf2image
PIL
tkinter

Process flow

Overview

  1. Check if the "ScanPDF" folder exists in Google Drive of the linked account (if it does not exist, create a "ScanPDF" folder and remember the id of that folder)
  2. Get all the PDF files under the folder with the memorized id and store them in the local temporary folder
  3. Display the PDF in the temporary folder on the display
  4. If there are multiple PDF files, change the PDF file to be displayed at regular intervals.
  5. Repeat steps 2 to 5 thereafter

Authentication

Allow your account access to the Google Drive API and projects using Google Oauth

Main.py


gauth = GoogleAuth()
drive = GoogleDrive(gauth)
files = os.listdir('./data/')
count = len(files)
dirtxt = 'dirdata.txt'

Folder creation / search for saving

The ScanPDF folder will be created at the first link. After that, the corresponding folder will be acquired.

Main.py


if not os.path.isfile(dirtxt):
    folder = drive.CreateFile({
        'title': 'ScanPDF',
        'mimeType': 'application/vnd.google-apps.folder'
    })
    folder.Upload()
    with open(dirtxt, mode='w') as f:
        f.write(folder['id'])
        dir_id = folder['id']
else:
    with open(dirtxt) as f:
        dir_id = f.read()

PDF file acquisition

The user adds the PDF file they want to display on the signage to the ScanPDF folder. After that, when the inside of the folder is scanned, the added PDF will be displayed on the LCD.

Main.py


  def scan(self):
    global count
    404img_path = "./data/404.png "
    tmp_dir = "./tmp/"
    shutil.rmtree(tmp_dir)
    os.mkdir(tmp_dir)
    i = 1
    query = f"'{dir_id}' in parents and trashed=false"
    try:
        for file_list in drive.ListFile({'q': query, 'maxResults': 100}):
            for file in file_list:
                if file['mimeType'] == 'application/vnd.google-apps.folder':
                    pass
                else:
                    file.GetContentFile(f'./tmp/{i+1}.pdf')
                    i += 1
    except Exception as e:
        print(e)
    files = os.listdir(tmp_dir)
    count = len(files)
    if os.path.isfile(404img_path):
        os.remove(404img_path)
    if count == 0:
        shutil.copy('404.png', 404img_path)
        shutil.rmtree(tmp_dir)
        os.mkdir(tmp_dir)
    else:
        for i in range(0, count):
            shutil.copy(f'./tmp/{i+1}.pdf',
                        f'./data/{i+1}.pdf')
        files = os.listdir('./data/')

File display

Main.py


image = convert_from_path(f'./data/{cnt % (count) + 1}.pdf')
tmp = image[0].rotate(90, expand=True).resize((sw, sh))
self.img = ImageTk.PhotoImage(tmp)
self.canvas.itemconfig(self.imgArea, image=self.img)

Digital Signage.png

Operation image

Digital Signage1.pngDigitalSignage3.png

At the end

Since the Google Drive folder is used as the file storage location, you can update it even when you are out. Furthermore, it is possible for multiple people to update by setting the access authority to the folder. Since the Raspberry Pi itself takes up almost no space, the compactness depends on the thinness of the liquid crystal. We are currently introducing this system as a contact bulletin board for university laboratories, and it is working well. We do not consider security issues.

** We welcome Pururiku Tsukkomi. Come thank you**

Recommended Posts

DigitalSignage with Raspberry Pi
GPGPU with Raspberry Pi
Mutter plants with Raspberry Pi
[Raspberry Pi] Stepping motor control with Raspberry Pi
Use vl53l0x with Raspberry Pi (python)
Serial communication with Raspberry Pi + PySerial
OS setup with Raspberry Pi Imager
VPN server construction with Raspberry Pi
Try moving 3 servos with Raspberry Pi
Using a webcam with Raspberry Pi
Raspberry Pi backup
Measure SIM signal strength with Raspberry Pi
Pet monitoring with Rekognition and Raspberry pi
Hello World with Raspberry Pi + Minecraft Pi Edition
Build a Tensorflow environment with Raspberry Pi [2020]
Get BITCOIN LTP information with Raspberry PI
Try fishing for smelt with Raspberry Pi
Programming normally with Node-RED programming on Raspberry Pi 3
Improved motion sensor made with Raspberry Pi
Try Object detection with Raspberry Pi 4 + Coral
Power SG-90 servo motor with raspberry pi
Working with sensors on Mathematica on Raspberry Pi
Use PIR motion sensor with raspberry Pi
Infer Custom Vision model with Raspberry Pi
Operate an oscilloscope with a Raspberry Pi
Create a car meter with raspberry pi
Inkbird IBS-TH1 value logged with Raspberry Pi
Working with GPS on Raspberry Pi 3 Python
Discord bot with python raspberry pi zero with [Notes]
Media programming with Raspberry Pi (preparation for audio)
What is Raspberry Pi?
I tried L-Chika with Raspberry Pi 4 (Python edition)
Raspberry Pi video camera
MQTT RC car with Arduino and Raspberry Pi
Let's do Raspberry Pi?
Power on / off your PC with raspberry pi
Use Majoca Iris elongated LCD with Raspberry Pi
CSV output of pulse data with Raspberry Pi (CSV output)
Get CPU information of Raspberry Pi with Python
Play with your Ubuntu desktop on your Raspberry Pi 4
Raspberry Pi 4 setup memo
Get temperature and humidity with DHT11 and Raspberry Pi
Cython on Raspberry Pi
Stock investment analysis app made with Raspberry Pi
Logging Inkbird IBS-TH1 mini values with Raspberry Pi
Connect to MySQL with Python on Raspberry Pi
Raspberry Pi system monitoring
GPS tracking with Raspberry Pi 4B + BU-353S4 (Python)
Measure CPU temperature of Raspberry Pi with Python
Record temperature and humidity with systemd on Raspberry Pi
Machine learning with Raspberry Pi 4 and Coral USB Accelerator
Run LEDmatrix interactively with Raspberry Pi 3B + on Slackbot
Using the digital illuminance sensor TSL2561 with Raspberry Pi
Easy IoT to start with Raspberry Pi and MESH
Display images taken with the Raspberry Pi camera module
Try to visualize the room with Raspberry Pi, part 1
Try debugging Python on Raspberry Pi with Visual Studio.
Detect mask wearing status with OpenCV and Raspberry Pi
Take the value of SwitchBot thermo-hygrometer with Raspberry Pi
Measure temperature and humidity with Raspberry Pi3 and visualize with Ambient
Log the value of SwitchBot thermo-hygrometer with Raspberry Pi