Raspberry Pi Setup/Config – Add Pi to Windows Network and config for GPIO access
This tutorial covers adding a wireless Raspberry Pi node on a Windows home network, with an emphasis towards creating a machine ready for GPIO pin access and prototyping. There are many great tutorials floating around that cover these points equally as well. My intent was to create a more summarized version to follow in setting up my own network.
Let’s get started!
1. Go to rasperrypi.org and download official Raspbian Wheezy image (update: now titled Raspian “Jessie”)
Raspberry Pi Downloads
2. Write to SD card using win32diskimager
a. put blank SD card in reader and format if necessary.
b. write Raspbian image (.img file) to that SD card using win32diskimager. Be sure to double-check which drive you are writing the image file to!
3. Pop the card in the Raspberry Pi, plug in your ethernet cable, and power it up!
(This tutorial continues using the SSH access method (headless), as opposed to setting up the displays. However, if you choose to use the display port instead, and get no display when hooking it up to a monitor or TV, etc., just open config.txt and adjust the settings in that file. There are many good tutorials that will give you the settings you need. Simply search using term: “raspberry pi no display”)
4. Get the IP address of the booted-up Raspberry Pi. You can find the IP address by accessing your router’s admin page, for example http://192.168.1.254. Look for device details and note the IP address of the new device, the Raspberry Pi.
6. We’re in! And that’s how easy it is. So now you have the Pi running, lets go through a few config steps and add some software to get it ready for prototyping, coding, etc., using Python, C and Bash libraries.
1. First things first:
sudo raspi-config to finish initial config. Change your password, expand to fill entire hard drive, etc. Use this guide for raspi-config specifics
2. Now, lets change the name of the computer from “raspberrypi” to something else. If you have only one single Raspberry Pi, you can skip this, but if you have or will have more than one on your network, you’ll want an easy identifier.
sudo nano /etc/hosts
sudo nano /etc/hostname
3. Change keyboard layout, so that it matches your country’s. The default is “gb”, so I needed to change it to “us”.
sudo nano /etc/default/keyboard
or (sudo shutdown -h now) to shutdown
a. sudo apt-get update updates the list of available packages and their versions, but it does not install or upgrade any packages.
b. sudo apt-get upgrade actually installs newer versions of the packages you have. After updating the lists, the package manager knows about available updates for the software you have installed. This is why you first want to update.
The next few steps mostly follow the Adafruit lesson #4.
sudo apt-get install git
git clone https://github.com/adafruit/Adafruit-Raspberry-Pi-Python-Code.git
sudo apt-get install python-dev
sudo nano /etc/modules (append: i2c-bcm2708 and i2c-dev to bottom of list, one line each)
sudo apt-get install python-smbus
sudo apt-get install i2c-tools (it appears this is already installed with smbus, but just to be sure)
sudo adduser pi i2c
sudo nano /etc/modprobe.d/raspi-blacklist.conf (comment out – # – spi and i2c -both lines)
sudo apt-get install xrdp (this allows for Remote Desktop Connection with GUI)
Now it’s time to change the IP address to be static rather than dynamic DHCP. This is helpful especially if you want to point services to different machines on your network. For instance, you could have a webserver pi and a file server pi and a webcam streaming pi…etc. Additionally, this setup allows for a wireless usb adapter which can be activated simply by plugging it in, while the ethernet cable is unplugged.
sudo nano /etc/network/interfaces
append this to the text in the file and save
iface lo inet loopback
#iface eth0 inet dhcp
iface eth0 inet static
iface wlan0 inet manual
iface default inet static
Now edit wpa_supplicant.conf for wireless network credentials:
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
Append the following to any existing text. [Subsitute ssid and psk (password) with your own:]
Great! Now enable your Raspberry Pi to be recognized by your Windows network.
sudo apt-get install samba samba-common samba-common-bin winbind
sudo cp smb.conf smb.backup
sudo nano smb.conf //edit this file to include this server on the windows workgroup list
Follow this quick guide for Samba settings:
(If you can’t connect using these settings, make sure to try //192.168.xxx.xxx instead of the hostname)
Great! Now that you’re done installing everything, you’re ready to start using the Pi’s GPIO pins to connect all kinds of fun things. If you need any inspiration, just go to adafruit.com or sparkfun.com or seeedstudio.com and have a look at everything that is available for projects.
The rest of the tutorial is for added functionality if you choose to continue!
For additional configuration options for GPIO control, I followed this excellent tutorial:
Here is a summarized command list of part of that tutorial. I changed directories only slightly from the tutorial to fit my needs.
tar xvf Raspberry_Pi_GPIO.tar
tar zxvf bcm2835-1.8.tar.gz
sudo make check
sudo make install
git clone git://git.drogon.net/wiringPi
sudo make install
sudo make install
Installing a MEAN stack
The MEAN stack can be summarized as follows:
- M = MongoDB/Mongoose.js: the popular database, and an elegant ODM for node.js.
- E = Express.js: a lightweight web application framework.
–if Raspberry Pi Model A, B, B+ and Compute Module
wget https://nodejs.org/dist/v4.0.0/node-v4.0.0-linux-armv6l.tar.gz tar -xvf node-v4.0.0-linux-armv6l.tar.gz cd node-v4.0.0-linux-armv6l
–if Raspberry Pi 2 Model B
wget https://nodejs.org/dist/v4.0.0/node-v4.0.0-linux-armv7l.tar.gz tar -xvf node-v4.0.0-linux-armv7l.tar.gz cd node-v4.0.0-linux-armv7l
–Copy to /usr/local
sudo cp -R * /usr/local/
To check Node.js is properly install and you have the right version, run the command node -v
Install Express with this generator tool
sudo npm install -g express-generator
then use this command (replace dir/appfolder with your own location)
sudo express /dir/appfolder && cd /dir/appfolder
:/dir/appfolder $ sudo npm install
then to start the website:
:/dir/appfolder $ DEBUG=appfolder:* npm start
On a Raspberry Pi, make sure you have at least 512mb ram for this to work.
Follow this install method: