Raspberry Pi Setup/Config – Add Pi to Windows Network and config for GPIO access

Raspberry Pi Model B

Raspberry Pi Model B

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.

5. Putty (or Mobaxterm) into the IP address using default pi/raspberry password credentials.

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.

————————————-Raspberry-Pi-New-Setup————————————————————————————————–

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

4. Reboot.
sudo reboot
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.
http://learn.adafruit.com/adafruits-raspberry-pi-lesson-4-gpio-setup

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

#sample /etc/network/interfaces

 

append this to the text in the file and save
#—————————————–
auto lo

iface lo inet loopback
#iface eth0 inet dhcp
iface eth0 inet static
address 192.168.1.82
netmask 255.255.255.0
gateway 192.168.1.254

auto wlan0
allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet static
address 192.168.1.82
netmask 255.255.255.0
gateway 192.168.1.254

#—————————————–

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:]

network={
ssid=”2WIRE678″
proto=RSN
key_mgmt=WPA-PSK
pairwise=CCMP TKIP
group=CCMP TKIP
psk=”———-password”
}

sudo reboot

Great! Now enable your Raspberry Pi to be recognized by your  Windows network.

————Install Samba———————-
sudo apt-get install samba samba-common samba-common-bin winbind
cd /etc/samba
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:
http://blogs.arcsoftwareconsultancy.com/pi/2013/03/07/windows-networking/

(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!

Have fun!

 

 

——————————————————

For additional configuration options for GPIO control, I followed this excellent tutorial:
http://blog.tkjelectronics.dk/2012/09/raspberry-pi-gpio-control/

Here is a summarized command list of part of that tutorial. I changed directories only slightly from the tutorial to fit my needs.

mkdir GPIO
cd GPIO
wget http://www.tkjelectronics.dk/uploads/Raspberry_Pi_GPIO.tar
tar xvf Raspberry_Pi_GPIO.tar

wget http://www.open.com.au/mikem/bcm2835/bcm2835-1.8.tar.gz
tar zxvf bcm2835-1.8.tar.gz
cd bcm2835-1.8
./configure make
sudo make check
sudo make install

 

WIRING library
————————

cd ~

git clone git://git.drogon.net/wiringPi
cd wiringPi/wiringPi
make
sudo make install
cd ../gpio
make
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.
  • A = Angular.js: a robust framework for creating HTML5 and JavaScript-rich web applications.
  • N = Node.js: a server-side JavaScript interpreter.

——-Node 4.0.0—————————–

–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

——-Express——–

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

then

:/dir/appfolder  $    sudo npm install

then to start the website:

:/dir/appfolder  $   DEBUG=appfolder:* npm start

———-Mongo——-

On a Raspberry Pi, make sure you have at least 512mb ram for this to work.

Follow this install method:

https://github.com/Barryrowe/mongo-arm

 

You may also like...

2 Responses

  1. Mavi Bausa says:

    Brilliant Mr Engi-nerd 😀
    And now…
    sudo make a post about what did you do with your RasPi

    and just because…
    sudo make a selfie

    Enjoy!

Leave a Reply

Your email address will not be published.