Articles Hierarchy

Articles Home » RPI » RASPBERRY PI


happy new year to all geeks

my friends from the arduino powermonitor sms project
( what is running on a remote island in malaysia with 4 power feeder
to under water power supplies ) BIOROCK send me a RASPBERRY PI for test.

i never used linux, so i know it will be hard for me to play with it,
and browsing the web for info i see that it is not so well organized as with arduino.

(1) As i got the pure SBC ( Single Board Computer ) board i needed some shopping first:
-- a SD card (min 4 GB )( 8GB Kingston uSD (class 4) with SD holder ) for 140THB
-- a keyboard mouse : Logitech wireless combo mk200 for 800THB
it works, the USB to 2.4GHz wireless use max 5V, 55mA,
the mouse and keyboard run on batteries ( 2 AA and 2 AAA )
and one USB slot is still free!! and no cables, so perfect for using RPI on your TV...

as powersupply i use my LG phone charger ( 5V, 0.7A model STA-U12WS )

a yellow RCA cable to a old TV.

(2) following quick-start-guide
download the operating system
and the SD image tool from here
unzip to subdirs, and run Win32DiskImager.exe
and load to SD 2012-12-16-wheezy-raspbian.img
at 5MB/s


Features of the Raspberry Pi model B board

Broadcom BCM2835 700MHz ARM1176JZFS processor with FPU and Videocore 4 GPU
GPU provides Open GL ES 2.0, hardware-accelerated OpenVG, and 1080p30 H.264 high-profile decode
GPU is capable of 1Gpixel/s, 1.5Gtexel/s or 24GFLOPs with texture filtering and DMA infrastructure
Boots from SD card, running a version of Linux
10/100 BaseT Ethernet socket
Price: 21.60 (exc VAT & delivery)

-- HDMI,
-- or RCA / stereo audio to plug in your analogue TV or display !! NO RGB !!
-- USB keyboard and mouse ( USB hub , USB stick, drive )
-- ethernet 10/100 wired network
-- micro USB power supply ONLY ( 5VDC , 3V3 internal )
-- 26 pin GPIO header
-- DSI lcd screen and camera

(4) on 1.1.2013
first test on old TV worked, but on a 32"LCD TV with HDMI cable we see a crystal clear picture

at first boot see a config screen
on second boot must login
user pi password raspberry
start the desktop with startx
where you can only logout, not shutdown!
this you do with sudo halt
if you need to call the config screen again: sudo raspi-config
for reboot: sudo reboot

(5) RPI remote
first changes:
because the old TV screen and the 15m ethernet cable from router...
not so funny for operation
i try to operate the RPI from my win7 computer.
boot RPI with ethernet/router connected
show on TV : IP add:
download/install PUTTY on win7
start PUTTY
pi@ port 22 SSH
password: raspberry

get console window

now from there install the VNC server for RPI sudo apt-get install tightvncserver

vncserver : 1

password for VNC must be 8 chars like "PIremote" verify,
view only: no

and download and start VNC viewer on win7 ( need to give name and email...)

the resulting VNC remote window RPI_VNC.jpg

even VNC is installed now, its not started at BOOT,
you still have to connect by SSH / PUTTY first
and start it with
vncserver :1
pi@raspberrypi ~ $ vncserver :1

New 'X' desktop is raspberrypi:1

Starting applications specified in /home/pi/.vnc/xstartup
Log file is /home/pi/.vnc/raspberrypi:1.log

pi@raspberrypi ~ $

and remember the vnc password from installation / first call.

(6) Full Backup

there are so many things i need to do, to test...
7.1 - adjust system space to SD card size
7.2 - fix IP add.
7.3 - something like total commander
7.4 - auto start VNC server
7.5 - system update
7.6 - install a web server
7.7 - connect a ARDUINO
7.8 - make some baby steps with PYTHON
- and test GPIO..

but first do a backup of the system / a image of the SD card.
for this use the same software like for burning it, Win32DiskImager.exe
give name and path for the backup image file, the drive of the SD card
and press READ

( by USB card reader , Win32 Disk Imager, 13MB/sec with a class 4 SD card, 8GB )

(7) next steps
7.1 - adjust system space to SD card size
with sudo raspi-config from PUTTY get

7.2 - fix IP add.
change from

with editor: sudo nano /etc/network/interfaces change to

to get

7.3 - something like total commander
because i am unwilling to use DOS, windows, linux from command line
and also find the file explorer under windows and linux desktop not that useful
i use the TOTAL COMMANDER under windows ( NC under DOS )
and test now the KRUSADER in LINUX
but because it is made for KDE.. installation needed an hour
( there could be a better option for the RPI? )

sudo apt-get update
sudo apt-get install krusader

but it looks good and i feel HOME
( pls find here also that a 4GB USB stick works fine )

7.4 - auto start VNC server
actually i tried that after webserver was running, to make sure that
-- SSH
-- VNC
can run over the ethernet at same time!!

sudo nano /etc/init.d/vncserver

# Provides: vncserver
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start VNC Server at boot time
# Description: Start VNC Server at boot time.

# /etc/init.d/vncserver
# Set the VNCUSER variable to the name of the user to start tightvncserver under
case "$1" in
su $VNCUSER -c '/usr/bin/tightvncserver :1'
echo "Tightvncserver started"
/usr/bin/tightvncserver -kill :1
echo "Tightvncserver stopped"
echo "Usage: /etc/init.d/vncserver {start|stop}"
exit 1
exit 0

sudo chmod 755 /etc/init.d/vncserver
sudo update-rc.d vncserver defaults get
update-rc.d: using dependency based boot sequencing
insserv: warning: current start runlevel(s) (S) of script `vncserver' overrides LSB defaults (2 3 4 5).
insserv: warning: current stop runlevel(s) (0 6) of script `vncserver' overrides LSB defaults (0 1 6).

7.5 - system update

system memory split for GPU from 64 down to 16, because as webserver not need the graphic power
sudo raspi-config

sudo reboot

time zone adjust:
sudo dpkg-reconfigure tzdata

update LINUX
sudo apt-get update ( ok )
sudo apt-get upgrade ( ok )

sudo apt-get install ca-certificates ( was already )
sudo apt-get install git-core ( ok )
sudo wget -O /usr/bin/rpi-update && sudo chmod +x /usr/bin/rpi-update failed

sudo rpi-update (not used )

sudo reboot

7.6 - install a web server

To install Apache and PHP, execute the following commands:
sudo apt-get install apache2 php5 libapache2-mod-php5 3 error connection failed
sudo apt-get install apache2 ( ok )
try again
sudo apt-get install apache2 php5 libapache2-mod-php5 ok

If you get an installation error, run: ( not tested )
sudo groupadd www-data
sudo usermod -g www-data www-data
+++ sudo nano /etc/apache2/sites-enabled/000-default
AllowOverride ALL <-- change to here
Now restart the service:
sudo service apache2 restart

now optional PHP, SQL and FTP, i did for test, but this is better for a HD,
not for a system on SD card

Install PHP:
sudo apt-get install php5-cgi ( ok )

Now, to fix any bugs, edit the php.ini file and remove the semicolon in front of
sudo nano /etc/php5/cgi/php.ini

sudo service apache2 restart

To install MySQL, install a few packages with the following command:
sudo apt-get install mysql-server mysql-client php5-mysql error connection failed

sudo apt-get update and try again
sudo apt-get install mysql-server mysql-client php5-mysql
sql root password: PIsql

as i fixed my IP to i can call it from by win7 PC browser by it.

but you too can check if my RPI is online

the web source is under
but its root protected! so need to adjust permissions

sudo chown -R pi:pi /var/www
sudo chmod -R 755 /var/www
check with
ls -la /var/www
total 24
drwxr-xr-x 2 pi pi 4096 Jan 5 21:53 .
drwxr-xr-x 12 root root 4096 Jan 5 19:49 ..
-rwxr-xr-x 1 pi pi 177 Jan 5 19:50
-rwxr-xr-x 1 pi pi 132 Jan 5 21:51 index.php
-rwxr-xr-x 1 pi pi 184 Jan 5 21:51 index.php~
-rwxr-xr-x 1 pi pi 2 Jan 5 21:53 test.html
-rwxr-xr-x 1 pi pi 0 Jan 5 21:53 test.html~

now i can change my WEBSITE from krusader...

first look:

We will now install FTP to allow transferring files to and from your Raspberry Pi.
Take ownership of the web root:
sudo chown -R pi /var/www
sudo apt-get install vsftpd

Edit your vsftpd.conf file, and change anonymous_enable=YES to anonymous_enable=NO, Uncomment local_enable=YES and write_enable=YES, then go to the bottom of the file and add force_dot_files=YES. Now save and exit the file.

sudo nano /etc/vsftpd.conf
sudo service vsftpd restart

from PC browser use
and get login window
but i will use my total commander as FTP software

test later adjust login path for FTP
temporary password
sudo passwd root
sudo nano /etc/passwd
Find the line pi:x;1000:1000:Raspberry Pi User,,,:home/pi:/bin/bash and add a # sign to the beginning of it. Now save and exit the file.
Add the user pi as a mod.
sudo usermod -d /var/www pi
Now exit your SSH session, and log back in as pi, then grant mod rights to root.
sudo usermod -L root

Now exit. Your server should be up and running. You can transfer files through FTP by using your servers I.P., and connecting through port 21.

7.7 - connect a ARDUINO
pls see in other chapter: RASPBERRY PI and ARDUINO

7.8 - make some baby steps with PYTHON
pls see in other chapter: RASPBERRY PI and ARDUINO

just to get a feeling for that job load:
RPI with webserver and VNC and python arduino script running
is on basic 13% cpu load and 100 of the 500MB ram usage.

here now some more installations:
as we install mySQL with the webserver, we need the tool for creating a database

sudo apt-get install libapache2-mod-auth-mysql php5-mysql phpmyadmin
use apache2
use dbconfig-common YES
password admin user PIsqladmin
get error access denied for user root@localhost select IGNORE

sudo apt-get --purge remove libapache2-mod-auth-mysql php5-mysql phpmyadmin
do again

sudo nano /etc/php5/apache2/php.ini
CTRL SHIFT _ 841 enable

create new DB
pi_fusion latin1_swedish_ci

make a db user
user: phpfusion pw: raspberry
all privileges but did not work while install php-fusion needed to use root ??

install PHP-FUSION
later this might be the main webpage,
temporary i just made a link from the index.php to the php-fusion subdir.

SD card issues

while i backup the SD card ( as a 8GB img file ) i zip that to about 1GB
now i want do following test:
-- unzip that file
-- burn it on a 16GB SD
uSD HC1 class 10 sandisk mobile ultra ( up to 30MB/s (read) ) for 690 THB
see 9.5MB/s write speed

if i need more linux space could adapt it to SD card space, or i could make a FAT32 partition for easy file transfer with windows...later.

when i did a readback of that what i just burned i see the 13MB/s ,
like with the cheap 8GB class 4 SD card.
so i think thats more about cardreader and USB2 and windows
and not so much about SD card.
but the readback file is 15.9GB, could never burn a 8GB again from it.

- checking about the webserver, cms ... SD card WRITE problem i needed some tools
and tested:
sudo apt-get install nmon
and see heavy disk writes at web traffic.