I’ll just dive in. Note: this is a mac only tutorial.
SD Card
You need to flash an sd card with the latest distro of raspbian. Don’t worry about it, just do it.
Download a copy of raspbian.
Unzip it on your desktop and do the following…
Open an terminal and type
df -h
Look at what you have. Then insert your sd card and do the same thing again.
df -h
Notice a difference? You should see something added like /dev/disk3s1 or something
Now unmount the sd card so you can write it.
sudo diskutil unmount /dev/disk3s1
Now look at the name, we’re gonna change it. disk3s1 becomes rdisk3 just drop the “s1” and add an “r”.
We need to copy it over so do this with your disk name and location of the download file:
sudo dd bs=1m if=~/Desktop/2013-02-09-wheezy-raspbian.img of=/dev/rdisk3
It’s not gonna tell you anything and it will take a long time. be patient. It will tell you when it’s done.
Setup
eject the sd card and pop it into your raspberry pi. Boot it up with a keyboard and hdmi cable to your monitor already plugged in. You should see s setup screen after it does some stuff.
Do the following setup:
- Expand root partition to fill SD card (just hit enter on this and it will expand)
- Set keyboard layout (I set it to logitech english US version generic)
- Enable ssh server
- Start desktop on boot? (I set this to no)
- Finish
Now your set up. It will ask you if you want to reboot. Say yes.
Install some stuff
log back in:
Username: pi
Password: raspberry
Now we need wifi.
sudo pico /etc/network/interfaces
Edit your interfaces file to look like this:
auto lo
iface lo inet loopback
iface eth0 inet dhcp
auto wlan0
allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-ssid "network name"
wpa-psk "password"
Reboot your pi to it can log in and get wifi
Now we want to install some stuff we’ll use. But first:
sudo apt-get update
sudo apt-get upgrade
Your password is just “raspberry”
Next we want to install build-essential and git-core so we can check things out.
sudo apt-get install build-essential git-core nodejs npm
Next we want to make sure we can use node instead of typing nodejs everytime.
update-alternatives --install /usr/bin/node node /usr/bin/nodejs 10
You can double check this is working with:
node -v
If you get a version number output then it worked. Then we want to make sure we can use the gpio pins. I use pi-gpio. To use this library without having to type “sudo”. To do this you need GPIO admin:
git clone git://github.com/quick2wire/quick2wire-gpio-admin.git
cd quick2wire-gpio-admin
make
sudo make install
sudo adduser $USER gpio
Next we install pi-gpio
sudo npm install -g pi-gpio
Now we want to manage our nodejs processes without worrying about them crashing. I user “forever” for this. NOTE: if you upgrade to node 0.10.5 there’s a known bug
sudo npm install -g forever
Let’s say you install your package and you have a node process like “web.js”. To start forever you might do:
forever start /PATH/TO/FILE/web.js
Then if you want to stop it:
forever list
forever stop 0
And boom. In about 5 minutes you can go from no pi to pi with a working install of NodeJS.
General stuff
You will also need to generate some ssh keys if you want to pull from github…
cd ~/.ssh
ssh-keygen -t rsa -C "my@email.com"
#enter
#enter
#enter
Then you will need to ssh into your pi. You can find it on your network by doing:
nmap 192.168.0.0/24
Then look for an interface that only has the ssh port open “22”
ssh pi@192.168.0.102
Enter your password “raspberry”.
If you really can’t find your pi’s ip by nmapping, then login into it with your keyboard and monitor and do:
ifconfig
This should tell you if your connected and what IP your on. Look for an IP that doesn’t have a .255 address.
Next we want to copy that ssh key we generated so we can pull down from github
less ~/.ssh/id_rsa.pub
copy the output and add it to your github repo ssh keys
Now you can pull from github.
If you want to reboot your pi:
sudo reboot
You should always shut your pi down, instead of just unplugging it. I just corrupted an sd card by unplugging it myself. Make sure you shutdown properly:
sudo shutdown -h now
Remember there really arent that many consequences. If you corrupt your card, just reflash it. and reinstall.
UPDATE:
If you would like to see how much memory is left on your pi:
df -h /dev/root