Raspberry pi (Raspbian Jessie) as a dashboard (Kiosk mode)


Update (04/01) – Project aborted for some reasons:
No efficient nor stable browsers are available for the moment:
  -> Midori or Epiphany use one core only, very poor javascript performance, freeze my pi
  -> Chromium (Ubuntu supported version) is unstable, crashes for no reason and restart is impossible in the same session (you have to log off or reboot)
  -> Iceweasel which has good javascript performance but suffers the same behavior as Chromium
My raspberry doesn’t appreciate to be powering on during many hours, Kernel Freeze appears after a few moment


Objectives:
Use a raspberry pi 2B to replace my home dasboarding system that currently uses Microsoft Windows Today.
In the same time try to display it on a new lcd display with 21:9 (2560/1080) resolution.

Context:
The dashboarding system should be activated only when there is someone in the room (a motion sensor informs my Home Automation System and then send a web http request to the raspberry pi)

Functional needs:
-> Web Browsing a web page with javascript
-> Switch on/off the monitor
-> Minimize / Maximize the browser (chrome) in order to decrease cpu usage
-> Can receive order/request from web http command
-> is able to be easily monitored

1st Step : Preparation and primary configuration


Download and install Raspbian Jessie (micro sd card SanDisk 16Go ultra gives great performance, boot duration under 7 seconds)

Open Terminal in order to update raspbian:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade

Update the firmware of your raspberry pi: Follow this procedure

Keyboard configuration

sudo nano /etc/default/keyboard

replace « gb » per « fr » (in my case)

Network static ip configuration

How to give a static ip (ip fixe):  (source)

sudo nano /etc/dhcpcd.conf

and add at the end of the file

static interface eth0static ip_address=xxx.xxx.xxx.xxx
static routers=xxx.xxx.xxx.xxx
static domain_name_servers=xxx.xxx.xxx.xxx

2nd Step : HDMI resolution and blank screen problem


Custom HDMI resolution and configuration

My monitor in this case is a LG25UM55 (resolution : 2560/1080) which is not a 1080p standard resolution, the pi doesn’t natively support it.

I followed this : 

Update config.txt file (follow this) and enter :

dmi_ignore_cec_init=1
hdmi_drive=2
disable_overscan=1

hdmi_ignore_edid=0xa5000080
hdmi_group=2
hdmi_mode=87
hdmi_timings=2560 1 64 64 96 1080 1 3 10 31 0 0 1 60 0 185580000 8

config_hdmi_boost=4

max_framebuffer_width=2560
max_framebuffer_height=1280
framebuffer_width=2560
framebuffer_height=1080

gpu_mem=128
arm_freq=900
gpu_freq=275
sdram_freq=500
hdmi_pixel_freq_limit=400000000
avoid_pwm_pll=1

Don’t  forget to reboot.

Avoid Blank Screen

In order to kill the useless blank screen which doesn’t fucking log off or switch off the monitor, the simple way is to install xscreensaver, a standard paquet of Raspbian Jessie (Source), and manually cancel blank screen.

sudo apt-get update
sudo apt-get install xscreensaver

Then go manually (with the mouse, no config text here) to the preferences, turn off the screensaver « et Voilà » your raspberry pi will never propose you any blank screensaver.

3rd Step : WEB Server APACHE2 and PHP5 Installation and Browser choice


APACHE2 et PHP5

Follow this procedure only for apache2 and php5, mysql is not necessary in our case : https://www.howtoforge.com/tutorial/install-apache-with-php-and-mysql-lamp-on-debian-jessie/

apt-get -y install apache2
apt-get -y install php5 libapache2-mod-php5
service apache2 restart

I’m using APACHE in order to build up php script that calls a bash script by using the famous php exec(); command.

But by default, www-data user which is the apache user/group doesn’t have the rights to execute all the commands (and especially the tvservice command).

A quick and dirty workaround consists to change APACHE2 user/group 

sudo nano /etc/apache2/envvars
Replace www-data with pi (for user and group)

Please, be conscious that this is a security breach, please do not apply this if your pi is on DMZ.

BROWSER CHOICE

I decided first to install chromium, but this browser is not longer supported by raspbian.

Ubuntu community continues to maintain it : https://launchpad.net/ubuntu/+source/chromium-browser/

I tried every browser without any successful results :

No efficient and stable browsers are available for the moment on JESSIE for a dashboarding use:
-> Midori or Epiphany use one core only, very poor javascript performance, freeze my pi
-> Chromium (Ubuntu supported version) is unstable, crashes for no reason and restart is impossible in the same session (you have to log off or reboot)
-> Iceweasel which has good javascript performance but suffers the same behavior as Chromium
-> Kweb is very low, seems somehow stable but is a pain to configure. Unfortunately I decided to abort this project before being able to test whether kweb could do the job, my pi undergoes some kernel freeze.

4th Step : SCRIPTING .sh (bash) & php


BASH SCRIPT

Here I would like to turn off/on the monitor by a bash script and in the same time I would like to minimize/maximize the browser (chrome) in order to save some cpu usage and be more energy efficient.

File : wakeup.sh (on /home/pi/Desktop)

#!/bin/sh

# MAXIMIZE BROWSER
export DISPLAY=:0.0
wmctrl -a chromium

#ACTIVATE HDMI AND SHAKE
tvservice -p && chvt 1 && chvt 7

Please note that wmctrl has to be installed (standard paquet) and if used remotely, you’ll have to specify the display which is concerned by your order (really a pain to find)

TIPS here : chvt 1 && chvt 7 allow Xorg to refresh by tty switching

File : sleep.sh  (on /home/pi/Desktop)

#!/bin/sh

# DEACTIVATE HDMI
tvservice -o

# MINIMIZE BROWSER

export DISPLAY=:0.0
wmctrl -r chromium -b add,hidden

PHP SCRIPT

Template :

<?php echo exec("/home/pi/Desktop/script.sh"); ?>

Create two files on /var/www/html

wakeup.php : replace script.sh by wakeup.sh

sleep.php : replace script.sh by sleep.sh

 

5th Step : AUTOSTART BROWSER IN FULLSCREEN


Execute chromium in fullscreen at the beginning of the x session

Edit .config file (source 1 ; source 2)

[Desktop Entry]
Encoding=UTF-8
Name=Connect
Comment=Checks internet connectivity
Exec=/usr/bin/chromium-browser -incognito --kiosk YOUR_WEB_ADDRESS

 

BONUS : Simple PHP script monitor cpu, memory and temperature


How to get a json that renders cpu frequency and temperature in order to display it.

mini_sysinfo.php

<?php
header('Content-Type: application/json');

$cpu = exec("cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq")/1000;
$temp = round(exec("cat /sys/class/thermal/thermal_zone0/temp")/1000);

$arr = array('cpu' => $cpu, 'temp' => $temp);
echo json_encode($arr);
?>

mem_info.php

<?php
$out = array();
 exec("cat /proc/meminfo | grep Mem", $out);

foreach($out as $line) {
 echo $line.";";
}
?>

 

 

  •  
  •  
  •  

Laisser un commentaire