This small article is meant to be an easy, step by step guide to installing a headless Raspberry Pi with Node.js.
What’s covered:
- Install Raspbian Lite
- Find your Pi
- Go wireless
- Upgrade and get some goodies
- Node time
Let’s do it!
1. Install Raspbian Lite
Raspbian lite is a minimal version of Raspbian that doesn’t contain the desktop environment (useless for a headless setup).
Download it on the RaspberryPi website website and install it following the instructions.
2. Find your Pi
After you have your Raspberry Pi turned on and connected to the Ethernet network, you need to find its IP address.
To make this work, you’ll need your router to have a DHCP server enabled and you also need to know the network your DHCP is releasing addresses to.
Suppose the network is 192.168.0.0/24, then run: nmap -sn 192.168.0.0/24
➜ ~ nmap -sn 192.168.0.0/24
Starting Nmap 6.46 ( http://nmap.org ) at 2016-01-16 16:01 GMT
Nmap scan report for Router.Home (192.168.0.1)
Host is up (0.045s latency).
Nmap scan report for air (192.168.0.4)
Host is up (0.023s latency).
Nmap scan report for raspy (192.168.0.19)
Host is up (0.040s latency).
Nmap done: 256 IP addresses (3 hosts up) scanned in 1.25 seconds
Now that you know where it lives (in this case 192.168.0.19), connect to it via SSH ssh [email protected]
password is raspberry.
3. Go wireless
You’re now ready to connect to a WiFi network and get rid of that annoying cable:
- Find the network you want to connect to
sudo iwlist wlan0 scan
You’ll need the SSID and passkey to connect to the network.
- Configure wpa_supplicant
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
# /etc/wpa_supplicant/wpa_supplicant.conf
network={
ssid="network_name"
psk="network_passkey"
}
Save, disconnect the cable and restart the network: sudo /etc/init.d/networking restart
Now run the search again (point 2) and ssh to the new IP address.
4. Upgrade and get some goodies
Just to make sure you’re on the bleeding edge.
- Update your system
sudo apt-get update && sudo apt-get upgrade
- Add some useful packages
sudo apt-get install vim git zsh
- Get a better shell (Oh-my-zsh)
sh -c "$(wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
5. Node time
Time to get Node.js!
- Get and unpack it
wget https://nodejs.org/dist/v5.5.0/node-v5.5.0-linux-armv6l.tar.gz`
tar -xvf node-v5.5.0-linux-armv6l.tar.gz`
cd node-v5.5.0-linux-armv6l
Note:
For Raspberry Pi Model A, B, B+ use the node-vx.x.x-linux-armv6l version.
For Raspberry Pi 2 Model B use the node-vx.x.x-linux-armv7l version.
- Remove non useful files
rm CHANGELOG.md LICENSE README.md
- Install it in
/usr/local
sudo cp -R * /usr/local/
That’s it! You can now enjoy your headless, lightweight Rapberry Pi now!
Sources: