TORBETA.COM

Raspberry Pi setup with Raspbian Jessie

Raspberry Pi Configuration

On your Pi desktop click Menu -> Preferences -> Raspberry Pi Configuration.
Here you can change the password, give your pi a hostname of your choice and expand the file system to fill your SD card.
It will be necessary to reboot your Pi for some changes to take effect.
Regularly rebooting after making major changes is strongly recommended to get stuff set up properly.

Add root terminal to menu.

Main menu editor is in preferences in the menu. Select it then highlight preferences and click the box for root terminal.
Using root terminal means you don't have to use sudo.
If you need to modify files not in the home directory and it's subdirectories which require root privileges, type 'leafpad' (no quotes) in root terminal and the editor opens with root privileges.
Find the file you want after selecting 'open'.
When you save it you won't have a problem.

Installation of XRDP for remote desktop and proftpd for FTP (file transfer)

Many users run the Pi 'headless', that is without dedicated screen, keyboard and mouse. The following installation is compatible with Windows remote desktop and works well with free Android apps (eg Thinstuff RDC).
Using root terminal
apt-get install xrdp
apt-get install proftpd
With some versions of Raspian Jessie there is a problem with xrdp.
The packages need to be loaded in a particular order
remove the following packages : xrdp, vnc4server, tightvncserver
apt-get remove xrdp vnc4server tightvncserver

install tightvncserver followed by xrdp
apt-get install tightvncserver
apt-get install xrdp
Source for above fix (thank you).

Setting up a Static IP address

Using a static IP may make access to your Pi easier, and is necessary for some applications (eg webserver)
Add this to file: /etc/dhcpcd.conf (as root)
For wireless use wlan0 (as below) for wired use eth0.
Use the IP address range used by your router and choose your static IP address OUTSIDE the range of the DHCP server on your router.
interface wlan0
static ip_address=192.168.1.240/24
static routers=192.168.1.254
static domain_name_servers=192.168.1.254

Start programs after lxde (GUI) loaded.

Navigate to /home/pi/.config/lxsession/LXDE-pi/autostart (hidden) in file manager then modify autostart in leafpad. Eg
@midori -e Fullscreen
This starts the browser in full screen mode.

Installation of apache2 webserver with Perl support.

Using root terminal type in these 5 commands.
apt-get install apache2
apt-get update
apt-get install libapache2-mod-perl2
a2enmod cgi
service apache2 restart
Test by typing localhost in your pi browser or your pi's ip address in a browser on a computer or tablet on the same network.
Put html files in /var/www/html/ and perl files in /usr/lib/cgi-bin/.
Remember to set execute permissions for perl files to 'anyone'
To make your Pi a webserver you need to open port 80 on your router and point it to the IP of your Pi.
You will need to set up a dynamic nameserver to the IP address of your router (which usually keeps changing). This can be done (free) at dtdns.com.

Installation of MySQL (free database) and phpmyadmin (browser based interface for MySQL)

Using root terminal
apt-get install mysql-server
install PHP5 and phpmyadmin
apt-get install php5 libapache2-mod-php5
apt-get install phpmyadmin
Add to file /etc/apache2/apache2.conf
Include /etc/phpmyadmin/apache.conf
If you need to access your database from a program on another Pi or other computer check out :-
Raspberry Pi Forum : Torbeta Post

Now make an image file of your configuration using Win32Diskimager or equivalent.

My Projects using the Raspberry Pi

calendar

Project: Family events calendar ( Raspberry Pi 1 (now upgraded to 2) Model B)

Pi displays a Google calendar in month view in full screen midori browser on a 19 inch monitor. Above the calendar are 4 panels, the outer 2 panels display images which change every 10 minutes. The left of centre panel is a clock with the date. These 3 panels are javascript driven from the html file. The remaining panel shows the weather forecast for 2 days, which is extracted from the BBC weather rss feed using a perl script. This is updated hourly. The system runs all the time in the family kitchen. A WiFi USB dongle connects to my router / the internet. This has been running since the Pi launch with regular improvements.
Entries to the calendar are made by family members using their smart phone or tablet.

calendar

Project: LCD clock / weather forecast. ( Raspberry Pi 1 Model B)

A 16 character 2 line LCD is connected to the Pi via the GPIO. A PERL script runs continously to update the LCD which shows hours, minutes and AM/PM. The display also shows the weather forecast, which is extracted from the BBC weather rss feed using the perl script. This is updated hourly, with the forecast changing from today to tomorrow at 6 PM. The system runs all the time. A WiFi USB dongle connects to my router / the internet. The Pi and the LCD with other components and connections are mounted in a display box.

4 line clock

Project: LCD clock with room temperature,weather forecast, and news headline. ( Raspberry Pi 1 Model B)

Following the successs of the 2 line clock I decided to display more data with a 4 line LCD. A 20 character 4 line LCD is connected to the Pi via the GPIO. A DS18B20 digital thermometer is connected via GPIO4. A PERL script runs continously to update the LCD which shows hours, minutes and AM/PM and the room temperature. The display also shows the weather forecast, which is extracted from the BBC weather rss feed using the perl script. This is updated hourly, with the forecast changing from today to tomorrow at 6 PM. The last line scrolls the first news headline item from the BBC extracted from the rss feed. The system runs all the time. A WiFi USB dongle connects to my router / the internet. The Pi and the LCD with other components and connections are mounted in a display box.

Just a Pi in a case

Project: Network utilities. ( Raspberry Pi 2 (now upgraded to 3) Model B)

A USB printer is connected to the Pi and managed as a network printer using CUPS. As the printer is located close to my router, so is the Pi which is cable connected to the router. The Pi also functions as a Web server (apache2) and as VPN (PPTP). The VPN has had mixed success and now I have Jessie I intend to try again with L2TP which failed to install properly with Wheezy. As I do not have a fixed IP address I use dtdns service to link to my changing IP address. My router has a function in built to update dtdns. When working the VPN behaved well and I was able to stream video as I have plenty of upload bandwidth with my fibre broadband. I have now installed OpenVPN which is extremely reliable. This system runs continuously.

led led

Project: LED and motor control via GPIO ( Raspberry Pi 2 Model B)

This project has been built with the electronics on a breadboard for software testing. It will be connected to external hardware when the latter is complete. The specification involves several variable frequency flashing LEDs (including fully on or off) with variable on/off (mark/space) ratios. All LEDs are independently set. 2 independant channels of PWM output are for motor speed control, but in the breadboard mock up they dim LEDs. The controller is a browser based interface. You may be aware that the GPIO can only be controlled from a program run as Root with Wheezy and a browser cannot (without much tricky setting up in apache) access Root programs. My solution is to use a MySQL database. Controls on the browser interface invoke a Perl script which updates the database. A program written in C runs continuously, looking for changes on the database and implimenting them, whilst looking after the on/off timings set for each led when there are no changes. The control interface may be run on another computer, tablet or smart phone on the same network. The continuously running C program uses less than 1% cpu resource. I have tried to upgrade to a Pi 3 running Jessie, but only some GPIO functions work without root priviledges, so my 'C' program needs to be run as root as with Wheezy. I don't find this to be a problem, however.

calendar calendar

Project: Central Heating Controller (Raspberry Pi Model 3)

This project uses a Pi 3 to replace a standard room thermostat, with extra features. A DS18B20 digital thermometer is connected via GPIO4 and controls are selected using a browser interface (pictured). At the first level the desired room temperature is set and if lower than the measured temperature the a relay is operated via GPIO11 to activate the boiler. The advanced feature is a daily multiple time zone system which allows the temperature to be set according to the time of day. This may be overridden by the first level system until the end of the current time zone.
Persistance of data and data communication between software modules is via a MySQL database on the Pi. A perl script is run at start up and loops every 30 seconds looking for demand changes. If found or if 10 loops have completed (5 minutes) a temperature measurement is taken and the appropriate thermostatic action instigated. Note that although this is running with Jessie, it needs to be run as root to function. A watchdog Perl script is run every 30 minutes as a 'cron' job which checks that the database has been updated within the last 7 minutes (5 minutes plus a bit) confirming that the looping script is ok. If not, a reboot is ordered.

PiSpy

Project: PiSpy USB camera (Raspberry Pi Model 3)

Originally on a Pi 2, this was recently re-programmed for Pi 3. It uses the package 'motion' to detect camera view changes and stores a an mpeg4 video of the motion detected. The camera output is also viewable in a browser both on the local network and over the internet. Migrating to the Pi 3 with Jessie was not straightforward as the format of the 'motion.conf' file is different from the Wheezy version. A 10400mAh Li-ION power pack allows the unit to be deployed in locations where mains power is not readily available.

screen

Project: Pi with 3.5 inch lcd touchscreen ( Raspberry Pi 1 Model B)

I have got the screen up and running with a Pi 1. It works well using the stylus to navigate. Still thinking about a project for it.