RSSCategory: Geekery

Sharing with the PI

A super simple way to share files and folders with your Mac over the network, install netatalk.

Again I guess there is a zillion ways to get this done. This is how I did it.

Log in to you PI. How you do that is your choice. I used terminal on my Mac and ssh’d in to the PI.

Firstly

sudo apt-get update; sudo apt-get install netatalk

Then

sudo /etc/init.d/netatalk stop

Stop the netatalk service while the config file is edited

sudo vim  /etc/netatalk/AppleVolumes.default

Now I use vim to edit the file. It doesn’t matter what you use to edit the file, any editor will do. At the very end of the AppleVolumes.default file is the section we are going to edit. Look for…

# The line below sets some DEFAULT, starting with Netatalk 2.1.
:DEFAULT: options:upriv,use dots

Now add to the end of the :DEFAULT line this ,rw this will set your home directory to Read & Write. While you have the file open check the lines below…

# By default all users have access to their home directories.
~/                      “Home Directory”

The line should look like the above. These are your shares as you will see them in finder. You can of course add and edit as many as you wish. Me, I kept it simple with only my Home Folder being shared.

Then the last step is to restart netatalk

sudo /etc/init.d/netatalk start

Thats it now open finder and select your RaspberryPI in the sidebar and click connect. You will have to enter your username & password for the PI and not you Mac

Thats it.

September 30, 2014 | By | Reply More

Backup your PI SD Card

After customization the Raspberry Pi, you may want to take a backup of it so that in case the SD card gets corrupted, you can easily restore the image.

  • Plug the SD card into the Mac or card reader
  • In Terminal, execute diskutil list to find your SD card make note of the disk number (/dev/diskX)
  • Then execute the following command for a backup: sudo dd if=/dev/rdiskX bs=1m | gzip > /path/to/backup.img.gz
    Replace the X with your disk number that you found in the previous step. Note the ‘r’ in /dev/rdiskX is intentional to take advantage of better performance (see the blog post I linked for details).
  • For a restore, the command would be: gzip -dc /path/to/backup.img.gz | sudo dd of=/dev/rdiskX bs=1m

Of course there is an app for that too if you aren’t comfortable with the command line. Its called Apple-PI Baker and its available for download from here. It currently at version 1.6 at the time of writing this.

Comments below please.

September 29, 2014 | By | Reply More

Setting up VNC Access on the PI

I wanted to set up VNC on my Raspberry Pi so I could use it via a remote desktop on my MacBook Air. There are lots of instructions scattered in various places around the web, and I guess I’m going to add to that here. This is not a replacement for all the others but just how I did it.

Firstly, I completed the installation through a ssh session. You could also acheave the same through terminal through the GUI on the PI.

Right… At the terminal enter.

sudo apt-get update
sudo apt-get install avahi-daemon
sudo update-rc.d avahi-daemon defaults

So now I have installed the bonjour service on the PI. I can now find my PI on the network by using it’s hostname.local. In my case raspberry.local and so now pi@raspberrypi.local allows me access.

The next step is to configure the avahi service by entering

sudo vi /etc/avahi/services/afpd.service

And enter the following

<?xml version=”1.0″ standalone=’no’?><DOCTYPE service-group SYSTEM “avahi-service.dtd”>
<service-group>
<name>replace-wildcards = “yes” >%h</name>
<service>
<type>_afpovertcp._tcp</type><port>548</port>
</service>
</service-group>

Then I ran

sudo /etc/init.d/avahi-daemon restart

That got the bonjour service runing and configured.

Now the VNC Server

Back at the terminal I entered these commands…

sudo apt-get install tightvncserver; vncserver

You should now be able to set your VNC password. Choose wisely. The next step is a little configuring. Change in to the init.d dir buy entering

cd /etc/init.d; sudo vim tightvncserver

And enter the following in to vim

#!/bin/bash

### BEGIN INIT INFO

# Provides:          tightvncserver

# Required-Start:    $syslog

# Required-Stop:     $syslog

# Default-Start:     2 3 4 5

# Default-Stop:      0 1 6

# Short-Description: vnc server

# Description:

#

### END INIT INFO

# Carry out specific functions when asked to by the system

case “$1” in

  start)

    su pi -c ‘/usr/bin/vncserver’

    echo “Starting VNC server “

    ;;

  stop)

    pkill vncserver

    echo “VNC Server has been stopped (didn’t double check though)”

    ;;

  *)

    echo “Usage: /etc/init.d/blah {start|stop}”

    exit 1

    ;;

esac

exit 0

Save that with :wq and…

sudo chmod +x tightvncserver; sudo pkill Xtightvnc

Now check that VNC Server is NOT running with

ps aux | grep vnc

Which came back with

pi        3724  0.0  0.1   3520   740 pts/0    S+   14:07   0:00 grep --color=auto vnc

This shows no VNC server running only the command I ran to check.

Now… Almost there

[code language=”plain”]sudo /etc/init.d/tightvncserver start
cd /etc/init.d
sudo update-rc.d tightvncserver defaults[/code]

The next step will announce the VNC Server using bonjour. It just make life easier on the Mac.

Now I created the avahi rfb service by…

sudo vim /etc/avahi/services/rfb.service

And entering..

 

<?xml version=”1.0″ standalone=’no’?>

<DOCTYPE service-group SYSTEM “avahi-service.dtd”>

<service-group>  

<name replace-wildcards=”yes”>%h</name>  

<service>    

<type>_rfb._tcp</type>    

<port>5901</port>  

</service>

</service-group>

Finally restart the newly created service

sudo /etc/init.d/avahi-daemon restart

Now if all has gone weel and I’m sure it has you should see screen sharing being announce in the finder window

[code language=”plain”][/code]

September 29, 2014 | By | Reply More

The Tweeting RaspberryPI

I’ve been doing some fun stuff with one of my RaspberryPI’s over the last week or so. I have now got it tweeting the temperature and humidity of the inside of our apartment. It’s only a small step but a fun one never-the-less. I’m also sure it will reduce the number of followers I currently have.

The set up is really simple. A DHT22 Temperature Sensor and a few lines of code.

It’s still very much a work in progress project and the outcome of it is to have a weather station installed upon our roof thats tweets the current weather conditions. I would also like to eventually include a web interface with detailed stats of the current & past weather. 

I will post more details of the code and circuit diagram when I feel its ready. But for now if you have any questions regarding my setup etc please post a comment.

September 16, 2014 | By | Reply More