Monday, 17 February 2014

bittorrent sync

Instead of using owncloud, which ran extremely slow on my Pi, I installed btsync (bittorrent sync). 

It is not an alternative for an "owncloud"-like service, but it is simple and efficient when it comes to syncing files made on the Raspberry's USB storage disk. 

When for example pictures are taken by the Raspberry, they immediately get synced to my other devices (iphone, ipad and mac), that is if you have the free BTsync app installed on your devices of course. There is also a version available for Mac which runs in the background.

You start by downloading the package from BitTorrent sync (ARM) and then follow these instructions (please note: I only used step 2 and 3 since I did not want the owncloud part!)

Have fun!

Thursday, 6 February 2014

Non graphical web browser and sending mails with RPi

This article is about setting up an automated task, using Lynx and sSMTP.

The goal is to set up a script which will automatically send an email to you with the current external IP address.

Lynx is a text browser for the web which you can use through the terminal. 

sSMTP is a lightweight mail client (it can not send attachments).


  • first install Lynx
sudo apt-get install lynx
You're done. Try this command line and see the result:
lynx -dump http://ipecho.net/plain 
(so this command reads the output of the webpage http://ipecho.net/plain and prints it out)
  • now install sSMTP
sudo apt-get install ssmtp
edit the ssmtp.conf file
sudo nano /etc/ssmtp/ssmtp.conf
verify that these settings are applied:
    • root=postmaster 
    • mailhub=smtp.gmail.com:587 
    • hostname=raspberrypi 
    • AuthUser=YourGmailUserName@gmail.com 
    • AuthPass=YourGmailPassword 
    • UseSTARTTLS=YES 
To be clear: in this case, the setup is for a gmail account. Change the mailhub if you use another account. Verify your hostname and enter your credentials.
Save and close this file.
Now edit the file revaliases
sudo nano /etc/ssmtp/revaliases
and add a line
pi:youremail@gmail.com:smtp.gmail.com:587  
Save and close this file.
Set permissions for ssmtp.conf to 774
sudo chmod 774 /etc/ssmtp/ssmtp.conf 
to test, try: lynx -dump http://ipecho.net/plain | mail -s "Your PI IP" me@myemailaddress.com


  •  instead of typing the complete command, you can create a script. Move to the directory where you want to create it, for example /home/pi and type:
sudo nano sendmemyIP.sh
copy the command line from above into the script and save and close it.
to make a cron job of this, you can copy this script to the hourly crons or daily crons, whichever you prefer:
sudo cp sendmemyIP.sh /etc/cron.hourly/sendmemyIP.sh

Pi Camera Board and Motion MMAL

I found this good working guide for installing Motion MMAL on the Raspberry Pi together with the Raspberry Pi Camera Board.

It enables you to build your own web surveillance camera.

First, when you connect your RPi camera board, make sure you have enabled it in raspi-config!

Now you can follow the clear instructions on this page: installing Motion-MMAL with Raspberry Pi Camera Board


Wednesday, 5 February 2014

Webmin: easy remote access to the Raspberry Pi through a web interface

Webmin allows you to see the complete setup of your RPi: configuration, attached storage, running processes, running servers, ability to create cron jobs, boot- and shut down options, network settings, and much much more... Very handy if you are not efficient enough with the linux tools and commands.

NOTE: it is better to install Webmin AFTER you have installed Apache2, PHP and MySQL (see later on in this blog)
  • Webmin website and installation instructions:
http://www.webmin.com/deb.html
After installation, open a web browser window on your Mac and enter the following address: 
https://yourIP:10000 
There you will be asked your login and password. 
The default port "10000" can be modified in the Webmin Configuration (left side bar), should you want to change that.

And voilĂ , a print screen for your information:


Make your web server accessible from the outside

The web server is now running (see previous article), but is only accessible from the local network. We should need outside access.

In this case I am lucky that we recently had a new modem/router from our ISP (Belgacom) on which you can easily enable DynDNS (Dynamic DNS).  (See below for non-Belgacom routers).

the steps:

  • sign up for a free account at No-IP and set up a hostname;
  • log in your router's page, mostly something like 192.168.1.1; 

  • click the "My Modem" section, and you will get this screen. Select the DynDNS tab. Switch the DynDNS button to "on", select the supplier (in this case No-IP) and fill out your username, password and hostname which you created at the No-IP web site;



  • go back to the home screen (192.168.1.1) and in the list of connected devices, select your Raspberry Pi;


  • A screen will pop-up in which you select the Port Forwarding tab. There you click "Add Rule" and fill out the following:
      • service: (no choice possible, so leave)
      • Protocol: TCP-UDP
      • External port: 80 (=default for web pages)
      • Internal host: is your Raspberry Pi's internal IP address
      • Internal port: 80
      • click OK and you're done.



Now if you connect your Raspberry to an external network (neighbour's wifi or wifi from iPhone) then you should be able to access the webpage (index.html in the /var/www folder) by typing the hostname which you created at No-IP instead of typing the Raspberry's static internal IP.


In case that you don't have a modem/router on which you can enable DynDNS then you can do the following: No-IP provides a DUC (Dynamic Update Client) which has to be installed on the Raspberry Pi. This software looks at an interval of 30 minutes (can be configured) what your external IP address is  and so enables that your web site stays accessible. The installation instructions are well explained in the link provided.

Tuesday, 4 February 2014

Apache2

setting up the webserver

For this we will be installing Apache2

sudo apt-get install apache2
Type "y" to agree for installation.

The folder /var/www is where the webpages will be located. This folder is owned by root and needs to be reassigned to user 'www-data' and group 'www-data'. Therefore type:

sudo chown -R www-data:www-data /var/www

(to check, type: cd /var and then ls -l : you will get a list of files and folders in the /var directory with their permissions)

To test the setup, open a browser window on a local computer (same network) and type in the IP address of the Raspberry Pi. You should see this screen: (this is in fact the index.html file located at your /var/www folder).




back up

Time for a first back up now we have our basic settings configured.

For this, I use the Pi Copier script. Can be found on Ivan's page. Simply install this on your Mac, put the Raspberry SD card in a card reader attached to your Mac and follow the instructions.

Tip: make sure your screensaver or sleep settings from the Mac are more than 30 minutes. If not you could get a time out error, in which case you just have to restart the procedure.




Tip: once the back up is finished, I select the back up file on the Mac and press Cmd+i. In the box "Spotlight comments" above, I fill in all the programs or settings which I already installed.  

Monday, 3 February 2014

hard disks and devices

Just a kind of discovery I made today, not directly Raspberry Pi concerned, but still, could come in handy some day:

I have a hard disk which I formatted in three partitions: 1 in HFS+ for file sharing between Mac and RPi and two other MSDOS FAT ones for music and video's.

The partitions were in this order: 1. HFS+ 2. MSDOS FAT and 3. MSDOS FAT

Disk Utility on Mac OSX for partitioning hard disks
Of course, on the Mac and Pi these were all accessible, but on our Samsung "Smart" TV :) I could not see a thing. 

Finally I figured out that if I put the two MSDOS partitions in the beginning (see print screen) and the HFS+ as last partition that the hard disk can now be read by our Samsung TV. 

Huray! 


wifi and static IP address

Many articles can be found on setting up a static IP address for an ethernet connection, but when it comes to a wifi static connection ... I got lost. So instead, I used an easier way:


  • install a compatible USB wifi dongle (this is a Realtek module and worked out of the box)
  • login to your pi's desktop, using VNCserver
  • on the desktop you will find an icon: WiFi-Config
  • open this program and press "scan": the available wifi networks will be shown
  • select your network and enter the wifi password in the PSK box
  • press OK and click connect 
  • in the menu bar above, click "file" and choose "save configuration"
(These credentials are now stored in the file located at: /etc/wpa_supplicant/wpa_supplicant.conf)


You are now connected to your wifi network, but still don't have a static IP address! So, 

  • in a terminal window (Mac or Pi) type:
    • cd /etc/network (moves you to the directory network under the etc directory)
    • sudo nano interfaces (opens the file "interfaces" with the nano editor)
    • the contents of the file should be the following: of course, I chose 192.168.1.18 as my static IP address, you are free to choose any other number provided it is within the range of addresses available on your router. 

    • "netmask" can be found if you enter the command: "ifconfig"
    • "gateway" is your router's home page

 You should now be able to go wireless! 

Saturday, 1 February 2014

HFS+, Netatalk, avahi daemon: make an RPi and external disks show up in Mac's finder

HFS+ is one of the filesystems used by Mac and is compatible with the Linux filesystem.

Step 1: These packages should be installed if you want to connect external hard disks that can be read by both systems.


  • install these packages first
sudo apt-get install hfsplus
sudo apt-get install hfsprogs
sudo apt-get install hfsutils 

Step 2: now continue over to a well explained guide on this guy's site (note: at the time of writing, this version 3.07 is the latest stable one, so adapt the file name when you execute the wget command). This guide will help you install Netatalk and Avahi Daemon.



tightVNCserver: a view on the RPi's desktop

tightVNCserver runs a VNC server application on your Rapsberry Pi, which then enables you to take control of the RPi's desktop from your Mac


Open a terminal window on Mac and log in on the RPi, using the familiar:

ssh pi@192.168.X.X

get tightvncserver with the command:

sudo apt-get install tightvncserver


- you will be prompted to create a password to access the VNC server
- (optional: create view only password: i chose no)

You can start the VNC server by typing:

vncserver :1 

Now open a Finder window on your Mac and press Cmd+k. A screen will pop-up allowing you to enter the address to which to connect to. The format to use is the following:

vnc://192.168.X.X:5901

(5901 is the port number used by tightvncserver. If you would have started up the vncserver on the RPi by typing vncserver :2 , then the port number would be 5902)

It is possible to let tightVNCserver start at boot-up. This time I chose not to, to keep the background running processes to a limit. The choice is yours of course. 

After all this, you will get your Pi's Desktop: