book collections email follower instructable user

Step 4: Software Setup

Picture of Software Setup

Software Setup Video:

After a lot of experimenting I refined the setup process to the steps below.

With a fresh (full) installation of Raspbian it's best to do most of the setup below with a monitor connected. First enable VNC server, and ideally log in / create a VNC account to make connecting to the Pi as straightforward as possible. With the Pi running headless you need to connect and log in to Duo after booting up, which is easy and just takes a few seconds - I normally just use my phone for this.

VNC can be enabled under Start > Preferences > Raspberry Pi Configuration (Interfaces tab). Because the Pi will be running headless we also need to tell it to assume an HDMI monitor is connected, and manually set a resolution (System tab) so that the mouse commands in the script line up with the elements on the web app. I chose option 19, 1280x720, if you use a different resolution you'll likely need to edit the mouse co-ordinates in the script.

Next we need to install PyUserInput from the terminal:

pip3 install PyUserInput

...and download the script from GitHub onto the Pi, I just popped it in the main Pi folder. To save having to start the script after each reboot it's worth setting it to run automatically once the desktop has loaded, by editing the global autostart file:

sudo nano /etc/xdg/lxsession/LXDE-pi/autostart 

...and adding in the following line at the bottom to point at the script location:

@python3 /home/pi/ 

After a reboot the script should run automatically.

As the Pi will be probably be waiting a while for the doorbell to ring (unless you're really popular) it's also best to disable the default screen dimming, as this could interfere with the mouse clicks. Counter-intuitively the best way to achieve this is to install Xscreensaver:

sudo apt-get install xscreensaver after installation you can configure the screensaver options (Start > Preferences > Screensaver) and set it to Disabled.

The Python code is on GitHub and is very simple - it essentially just programs the doorbell button to perform a series of mouse clicks to control the Duo web app on screen. Except it's not really on screen as the Pi is running headless.

If you've completed the above and the Pi has rebooted, you should be able to disconnect the monitor (if you used one), connect to the Pi via VNC from a phone or PC and log in to Duo, setting it to full-screen, choosing the audio sources and setting the video width as detailed above. Once that's done you can disconnect VNC and the doorbell is ready for use!