Saturday, 15 June 2019

How to make a mini bird box monitor

It's all very well having a bird box camera that you can view on a PC/ipad/etc, I wanted an unobtrusive static monitor, so I made one

My little Elf Helpers demonstrating their bird box monitor

Some prerequisites....

  1. Bird box camera live streaming to your local network that can be viewed via a web-browser on a PC / ipad / other tablet computer.
  2. In my case I use Pikrellcam software running on a Raspberry Pi-equipped bird box with raspberry pi camera module (see a recent blog post on the nest that is showing on this ).
  3. In the picture above I've used a HyperPixel 4.0 screen from Pimoroni, which is plugged into a Raspberry Pi 3 Model A+, in a case to protect it.  Pimoroni have comprehensive setup instructions.

My normal way of monitoring this box on a PC using pikrellcam looks like this...


To get a minimal interface, you need to switch the Raspberry to 'kiosk mode'.  This means that when it boots up, it loads a specific website and removes extraneous stuff from the active window such as mouse cursors, scroll bars and distracting error messages.  This is the same approach that you get in applications such as photo booths, cash dispensers etc.

I modified a method from the  https://pimylifeup.com/raspberry-pi-kiosk/ website.  There are probably other ways of achieving the same end.  I'm also assuming that you're familiar with entering commands via SSH.  Google it if you don't know how.

Brief summary...

Make a file called kiosk.sh
nano /home/pi/kiosk.sh

Install dependencies
sudo apt-get install xdotool unclutter sed

Add this to the kiosk.sh file.  Substitute 'http://xxxurlToYourWebCam' with your local URL
#!/bin/bash

xset s noblank
xset s off
xset -dpms

unclutter -idle 0.5 -root &

sed -i 's/"exited_cleanly":false/"exited_cleanly":true/' /home/pi/.config/chromium/Default/Preferences
sed -i 's/"exit_type":"Crashed"/"exit_type":"Normal"/' /home/pi/.config/chromium/Default/Preferences

/usr/bin/chromium-browser --noerrdialogs --disable-infobars --kiosk http://xxxurlToYourWebCam  &

Interestingly if you're doing his setup over SSH, if you run sh kiosk.sh from an SSH terminal window on another machine the kiosk wont start.  Probably as the active SSH session cant find a screen.  If you run it directly on the Pi with connected keyboard it works fine

Most of the following is copied verbatim from 'how to' the link above, with a couple of changes

Run script from command line using service file
sudo nano /lib/systemd/system/kiosk.service

Add the following text to this file:
Note that using the hyperpixel, this only works if 'Type=simple' is changed to 'Type=forking' (as suggested in the commentary at the end of the above article)
[Unit]
Description=Chromium Kiosk
Wants=graphical.target
After=graphical.target

[Service]
Environment=DISPLAY=:0
Environment=XAUTHORITY=/home/pi/.Xauthority
Type=forking
ExecStart=/bin/bash /home/pi/kiosk.sh
Restart=on-abort
User=pi
Group=pi

[Install]
WantedBy=graphical.target

Enable, then start the service
sudo systemctl enable kiosk.service
sudo systemctl start kiosk.service

Check status like this
sudo systemctl status kiosk.service

There's loads more detail on https://pimylifeup.com/raspberry-pi-kiosk/ but I've just listed the modified version I did to make it work.

One more thing....

There's some sort of bug/security procedure combo affecting the chrome web browser boot up time, such that it wont load chrome browser until it generate sufficient 'Entropy' in particular when there is no keyboard connected.  Seriously.  I think this has something to do with random number generation & cryptography and reflects how 'secure' the machine is.  Or something.

Anyway, the effect is that our kiosk wont load for several minutes after boot, which is a pain especially if you need to do a quick demo.

There's a solution detailed here:
https://www.raspberrypi.org/forums/viewtopic.php?t=237069
I'm not vouching for the relative safety or what it does (use at your own risk etc...)

sudo apt-get install haveged
sudo systemctl enable haveged
sudo systemctl start haveged

After all that I have a stand-alone Pi with screen that boots directly to my bird boxes webpage :)



2 comments:

  1. Replies
    1. Was standing next to the crate of lego when looking for some way of getting scale across.... :)

      Delete