Monday, February 3, 2014

Using Raspberry Pi for Webview

I've been asked to write up a step by step for using a Raspberry Pi (RPi) computer as an Active911 Webview monitor.

- I purchased a Raspberry Pi computer from Amazon.

- This also needs an operating system.  I bought a 32 GB SD card from Staples and then downloaded the NOOBS image.  Step by step instructions for doing this are at: http://www.raspberrypi.org/downloads

- Once that was done, I downloaded the Chromium browser and installed it onto the machine. It seems to be a better browser for handling Active911 Webview.

- Launch Chromium and enter the Registration Code for your Webview session.  This saved it so when I launch it in kiosk mode, it simply logs in.

Now I needed to do some configuring so I can boot the RPi and have it launch Chromium in kiosk mode and not have the screen saver come on (I am connected to a 1080i monitor via an HDMI cable for all of this).



- Enter the following code into a terminal window:

$ sudo nano /etc/lightdm/lightdm.conf

# add the following lines to the [SeatDefaults] section
# don't sleep the screen
xserver-command=X -s 0 dpms
This essentially turns off the screen saver.

Now, you need to set it up to launch Chromium at boot and load the Active911 client.

- Enter the following code:

$ sudo nano /etc/xdg/lxsession/LXDE/autostart 

# comment everything and add the following lines

@xset s off
@xset -dpms
@xset s noblank
@chromium-browser --kiosk http://webview.active911.com/client
This will launch Chromium about 30 seconds after the computer boots and loads LXDE (the desktop).  You can bypass the entire LXDE session and load Chromium direct but that did not matter to me.

Note, if you want to get out of Kiosk mode, you hit "alt F4" on your keyboard (that's function key 4).

My last problem was some rather thick black lines on all 4 sides of the screen. In other words, there was wasted space due to underscan.  I wanted to fix this.  This is a trial and error process.

- Step 1is to make sure the RPi boots to the same resolution my monitor supports (1920 x 1080).  Launch a terminal window and type:

$ sudo nano /boot/config.txt

Now find the following section of code that is commented out and un-comment it and change it to the resolution you want to use:

#console-width=1024
#console-height=700

I changed mine to read:

console-width=1920
console-height=1080

- Now you need to adjust the black lines and here is where the trial and error comes in.

Go back to the confix.txt page in a terminal window:

$ sudo nano /boot/config.txt
Now, scroll down until you find the following section:

overscan_left=20
overscan_right=12
overscan_top=10
overscan_bottom=10

Your number may be different.  However, to make less black space, you want smaller numbers.  Mine ended up being -60 for each of the overscan settings.  You change them, save the file and then need to re-boot to see your changes.  Took me around 6 tries before I got it to a point I was happy.

UPDATE 02/22/2014:

Next issue was connecting the RPi to a VGA only monitor.  There are HDMI to VGA converter cables out there but after doing some research, most of those draw more power than the RPi can reliably put out of the HDMI port - eventually frying something.  I went with a powered HDMI to VGA converter box, per the recommendation of the RPi forums:

http://www.amazon.com/gp/product/B006JW6M2I/ref=oh_details_o00_s00_i01?ie=UTF8&psc=1

In addition, after doing research on RPi power draws, I decided to ditch the cell phone charger I was using for the power supply and upgrade to a real power supply that could handle the draw the RPi needs:

http://www.amazon.com/gp/product/B00DZLSEVI/ref=oh_details_o00_s00_i00?ie=UTF8&psc=1

Hope this helps. Feel free to leave a comment if you find any errors with this tutorial or have other suggestions!


8 comments:

  1. Thanks for the info! I have been using a Pi for a while here, currently I have one reading the serial output from my Peet Bros weather station and updating the CWOP network. This will be great addition for our unmanned station just south of you in Manitou Springs, CO. I have it running here at home and seems to work great. I would like to add sound and or triggers so I can activate a relay for lights or play an MP3 for an alarm.

    BTW, I have a station monitor running on the Arduino platform that monitors temps and AC power at the station for alarms. I'll run the Pi off a dedicated 5V bus that's run off a 12V AGM battery for availability during an outage. I got a 22" Samsung TV with HDMI input (1080x1920) that runs off of 14VDC, so I'll get it working off the backup system as well.

    ReplyDelete
  2. Thanks Chad! Awesome tutorial. Helped me setup a neighboring departments system.

    ReplyDelete
  3. Out of curiosity why did you switch from HDMI to VGA? Was this due to the monitor had VGA only, or was there an issue with HDMI use?

    ReplyDelete
    Replies
    1. The big monitor we are using is very old and does not have an HDMI input on it. Our only option was VGA.

      Delete
  4. A few things I had to change with the newest version of wheezy. I did not use noobs. I just downloaded the latest wheezy image for raspberry pi 2. I also expanded the file system to use the entire sd card and overlclocked it to the PI2 setting in raspi-config and it has been very stable.

    Had to change sudo nano /etc/xdg/lxsession/LXDE/autostart
    to sudo nano /etc/xdg/lxsession/LXDE-pi/autostart in order for the autostart to work. I also found that you have to change the autostart function in the raspi-config options then change the autostart file or it overwrites the changes you make.

    The only other thing I do is every time I start a pi project is make sure it is up to date with sudo apt-get update and sudo apt-get upgrade. your guide was easy to understand. It is a lot easier to just start the gui and run chromium then trying to run chromium or another browser stand alone. The raspberry pi 2 has enough power now that you do not have to worry about slowing it down compared to older versions.

    ReplyDelete
    Replies
    1. There may be one small change with the RPI 3... I found that modifying the autostart for both /etc/xdg/lxsession/LXDE/autostart and /etc/xdg/lxsession/LXDE-pi/autostart did not work. The workaround I found for our RPI's was to sudo nano /home/pi/.config/lxsession/LXDE-pi/autostart

      It worked fine after that.

      Also, installing chromium-browser is a little more complicated on the RPI3, even if you do sudo apt-get update and sudo apt-get upgrade. Following this how-to will get it to work though: https://www.raspberrypi.org/forums/viewtopic.php?t=121195

      Hope that helps! Chad, thanks for this!

      Delete
  5. I have a raspberry pi and active911 running in webview. I have the chrome browser and raspberry pi scheduled to reboot every morning just to mitigate any potential connection issues that may surface during the day or if we lose connection to active 911 (which has happened). One problem that I have is that the map doesn't auto-position itself over our area...but rather positions itself over our city station which is about 20 miles away. I'm thinking its a geolocation issue that my raspberry pi doesn't know where it's located... Anyone have any thoughts on how I would fix?

    ReplyDelete
  6. I was wondering if anyone could please advise me on how to store the registration code. Right now with kiosk mode running it will load the Webview login screen and entering the code gets it going but the problem is if it is rebooted it doesn't hold the code and a manual login is required again. Any help would be greatly appreciated.

    ReplyDelete