Wednesday, December 23, 2015

Full Screen Web Page Display Appliance via Raspberry Pi 2

I have a need for a small PC/Appliance to boot up, and display a web page (and update / reload this page at a set interval).

One would think this would be easier than it is, and granted it's easier today than it's ever been, but it's still not trivial.

To start out, I want to give credit where credit is due. Probably the most helpful site I used in this build was Dan Purdy's Raspberry Pi Kiosk Screen Tutorial page:
https://www.danpurdy.co.uk/web-development/raspberry-pi-kiosk-screen-tutorial/
The content is great, as well as the comments helpful.


To start out, you have to purchase a Raspberry Pi 2 (RPi2). I got one from Amazon for around $38.

I didn't bother to get a case right away; as I wanted to be sure this was going to work first, with the least about of investment.

I didn't buy their $10 Power Supply (PS). Who doesn't have a USB micro PS transformer laying around these days? Especially since it seems to be the standard charger-of-choice for all non-Apple cell phones.
  • USB Volt / Amp Meter; reading 5.07 volts and 0.39 ampsQuick note about power / consumption of the Raspberry Pi 2: In all my testing, even running a basic version of Minecraft on the Pi (which ran surprisingly well) the Pi never had a current draw greater than 0.57 amps (at ~5.07 volts).

With the Pi in hand and an 8 GB SD card I already had, I need to get bootable Linux on the SD card to start-up the Pi2.


I chose to download Raspbian Jessie (Full desktop image based on Debian Jessie) available here:
https://www.raspberrypi.org/downloads/raspbian/

Then I had to use Win32 Disk Imager to write the .IMG file to the SD card in Windows (and create the boot sector and all that good jazz):
http://sourceforge.net/projects/win32diskimager/?source=typ_redirect
This worked impressively well.
However, turns out that the IMG on an 8GB SD card is FAT formatted, and leaves ~3.7 GB of the card unallocated. The main partition, with the Full Debian Jessie desktop image, has only 2% free space on the disk at boot up! This leaves basically no room to add anything else.

I tried several different ways to add the unallocated space back into the primary partition, including Windows 7 partition manager, but eventually stumbled upon a much easier solution: Once you boot the Pi, goto [Start]Menu → Preferences → Raspberry Pi Configuration. The first tab, first option, is "Expand Filesystem". One click there, and a reboot, and it's done! The working drive goes from 2% free, to 52% free! Now, we've got some space to work with.
(Note: use command "df" to check disk free space in Linux terminal.)


The next problem I ran into is the web browser. This Raspbian Debian Jessie OS comes with the Epiphany Web Browser. This seems like a nice browser, and would probably be usable, IF there was a way to start it up in Full Screen (F11-style) mode. But there isn't:


Chromium browser (the generic / open-source? version of Chrome) does have a -kiosk switch that can do this. Snag: Chromium is not in the repositories on Jessie. So you have to get in manually:
wget https://dl.dropboxusercontent.com/u/87113035/chromium-browser-l10n_45.0.2454.85-0ubuntu0.15.04.1.1181_all.deb
    wget https://dl.dropboxusercontent.com/u/87113035/chromium-browser_45.0.2454.85-0ubuntu0.15.04.1.1181_armhf.deb
    wget https://dl.dropboxusercontent.com/u/87113035/chromium-codecs-ffmpeg-extra_45.0.2454.85-0ubuntu0.15.04.1.1181_armhf.deb
    sudo dpkg -i chromium-codecs-ffmpeg-extra_45.0.2454.85-0ubuntu0.15.04.1.1181_armhf.deb
    sudo dpkg -i chromium-browser-l10n_45.0.2454.85-0ubuntu0.15.04.1.1181_all.deb chromium-browser_45.0.2454.85-0ubuntu0.15.04.1.1181_armhf.deb
(Source: https://www.raspberrypi.org/forums/viewtopic.php?t=121195&p=818455)

Once that is installed, you can launch a full screen browser window, from the command line:
$ chromium-browser --kiosk www.google.com




Unless you're going to keep this isolated by wrapping it in a receipt for a while (like I did), you're going to need a case for your RPi2. I got this one:
http://www.amazon.com/dp/B00MQLB1N6

I'm impressed with how well this worked, and how good the tolerances are. The only drawback to this design I see, is that it should have a removable cover for the GPIO pins, if you're not using them (like me). Otherwise they're just all hanging out in the open for no good reason.



I was able to find a very small USB wireless NIC card/adapter for this that worked.

I first tried one from X-Media USA - their XM-WN1200. It did not work natively in the RPi2, nor in a full desktop install of Linux Mint 17.1.
I looked on their included mini-CD, and no Linux drivers.
I contacted their support department, and they said: "Please download Linux driver for XM-WN1200 from link below, choose MT7601U USB driver for Linux." and gave me the link:
http://mediatek.com/en/downloads1/downloads/
I tried this, but could not get it to work.
Sent them a follow-up email, and their final response was, "We do not have driver installation of Linux for XM-WN1200 as we only advertised this product supported Windows.  Even though the chipset does support Linux, please search online for any help."

So I purchased an Edimax 150Mbps Wireless 802.11b/g/n nano USB adapter (EW-7811Un):
http://www.amazon.com/dp/B003MTTJOY
And this device seems to work great with Linux.
With Linux Mint 17.1, it installed quickly, and was up and running with in a minute or two.
With the RPi2, it took longer, and I even had to do a reboot before it started working correctly.
But it's running good now.



Unless you have a large work space for testing these kinds of things, you will quickly tire of needing to have another full size keyboard and mouse to work your RPi2. I found this clever little micro keyboard and trackpad (mouse) combo that solved that problem nicely.
Rii 2015 Mini Wireless 2.4GHz Keyboard with Mouse Touchpad (mini X1):
http://www.amazon.com/dp/B00I5SW8MC

As an added bonus, it also combines both the keyboard and mouse to a single USB-nano adapter, freeing up another USB port on the RPi2. This kb/mouse is as big as the average TV remote. It also worked with RPi2, desktop Linux Mint 17.1, and Windows 7 (although the driver find / download / install on Windows took much longer). I can see myself using this a LOT for test PCs, and will probably be getting another one of these soon.



After hours of research and testing the numerous ways to "autostart" an application in this flavor of Linux (it should NOT be this hard -- this is why Linux has to fight for traction with mainstream users) I finally got Chromium to autostart on boot.
Had to create a file called chromium.desktop in the ~/.config/autostart/ folder, but launching nano.
In that file, you need to put:
[Desktop Entry]
Encoding=UTF-8
Name=Connect
Comment=Checks internet connectivity
Exec=/usr/bin/chromium-browser --kiosk --disable-restore-session-state www.GOOGLE.com

Problem: This does not prevent the "Restore pages?" bubble.



To keep the screen from blanking:
All that you should have to do is to open the file:
/etc/kbd/config
And in there set
BLANK_TIME=0

Problem is; this doesn't work.
And apparently it's a known bug.
However, you should set this anyway, as it's expected to be fixed in the future (test!).

So the work-around for now seems to be to set
consoleblank=0
in the
/boot/cmdline.txt
Testing this now... and it doesn't work either...

Still hunting for a solution for this...



---The rest of this is just random notes to myself, as this is still a work in progress for me---


Screen is still blanking... around 10-15m intervals...




% read all the other comments to main article first for ideas.




Next we need a way to remote into the RPi2.

(Ref: http://www.raspians.com/knowledgebase/?knowledgebase=setting-up-a-remote-desktop-view-the-pi-on-your-windows-pc/ )

We need to download Xming on our Windows PC:

http://sourceforge.net/projects/xming/

Install that...




No comments:

Post a Comment