Loading... Please wait...

Raspberry Pi Tutorial

Raspberry Pi Tutorial

oddWires Raspberry Pi [Pro] Kit : Inside the box

Here's what is included in your oddWires Raspberry Pi [Pro] Kit:

Raspberry Pi Model B
Model B comes with an Ethernet jack, two USB inputs compared to one on Model A, and 512MB of memory compared to 256MB on Model A.
Clear Case
Clear Case designed by Adafruit. It is compatible for both Model A and B, and it's not just functional, but elegant. You can easily install your Raspberry Pi with a push into the case. The SD Card can be inserted and ejected without removing the case, and the case can be used with the top part off to access your Raspberry Pi.
Power Adapter
This is a 5V 1A USB power supply. This is a more powerful adapter than comes with many other kits.
SD Card
This is an 8GB class 10 SD Card and comes preinstalled with the latest version of NOOBS, which includes 6 ready-to-install linux distros. Most SD cards sold in Raspberry Pi kits come as 4GB and class 4 or 6, which is many times slower. A class 10 SD card works very fast in your Raspberry Pi. Also it is a lot faster when you want to install a new version of a distro.
MCP3008
8-Channel 10-Bit ADC With SPI Interface. This chip is a great and easy way to add analog input to your Raspberry Pi, which does not come with an Analog to Digital Converter. As it uses an SPI interface, only four pins are required.
Breadboard
This is a 400 tie-point breadboard, good for most Raspberry Pi projects.
HDMI Cable
You can use any HDMI compatible monitor or TV to connect to your Raspberry Pi with the included HDMI cable.
Micro-USB Cable
This is a convenient 6ft micro-usb cable to power your Raspberry Pi.
TTL Console Cable
TTL Console Cable is the easiest way to connect your Raspberry Pi using your computer. Using this cable, you do not need any extra keyboard, mouse, or display to control your Raspberry Pi.
USB WiFi Adapter
This module is vastly better than most in that it comes with an antenna; it will give your Raspberry Pi the freedom of connecting to the internet without any wires.
Premium Jumper Wires
This pack combines different sizes and types in one. The 40 wires include: 20 x 6" and 20 x 10", and 20 x M-F and 20 x M-M cables.
Our Standard Kit Items
LED packs, Resistors, Capacitors, Switches, Transistors, Light Dependent Resistor, Thermistor, and Piezzo Buzzer

Our Pro Kit additionally includes the following items:

IR LED + Receiver
For TV style remote control
Real-Time Clock
Keep the real time whether your Pi is off or on
Ultrasonic Sensor
For distance sensing
16x02 LCD Display
A 2 line display for displaying real-time info
433 MHz trans/receiver
Similar device to your garage door opener
RGB LED
Display system health or any other status using different colors
40 pin header
Breakaway header for interfacing to a breadboard
Photo-transistor
Sensitive to the same light frequency as the supplied IR LED

Getting Started with Raspberry Pi

Basic installation

Power Supply

Raspberry Pi is powered by a micro-usb cable, and requires a 5V 700mA power supply. A 5V 1A Adafruit Power Supply is included in your kit along with a micro-usb cable. Plug one end of the micro-usb cable to the power supply and the other end to your Raspberry Pi. There is no on/off button on a Pi, so as soon as you plug in the power, your Pi will start. The power supply included in your kit is tested with the other items, and 1A is sufficient for most projects, however, if you start a project in which you have to plug more energy consuming devices, you can consider using a powered usb-hub, instead of buying a new power supply. Some powered usb-hubs can also power your Pi without the need of the power supply unit, however, in this case you're bypassing the voltage protection and putting your Pi at a risk of damage in case of a power surge.


Power Supply

Power Supply

Micro-USB Cable

SD Card

An SD Card is needed to do anything with a Raspberry Pi. The SD Card contains the operating system used to run your Pi. The best and easiest way to start with your Pi is using NOOBS software, which your SD Card already comes installed with. Later on, if you want to install another Linux distro among the ones in NOOBS, you can easily download NOOBS or an individual distro from the official downloads page. But do not use any other SD Card with important data as the install process will delete these other files. Note: the included SD Card is a Class 10 card, the fastest available today.

To install one of the distros, just insert your SD Card, and power it up. NOOBS has a very easy installation process, you can just select the distro you want to install, and that distro's image will be installed on your card, while others will be erased to save space. Linux distros included are: Raspbian, Pidora, OpenELEC, RaspBMC, RISC OS, and Arch Linux. Of course, you need a display, keyboard, and mouse connected in order to complete the installation. however, an internet connection is not required at this point.

Getting Connected to Raspberry Pi

There are several ways to get connected to your Raspberry Pi, and you can find them below starting from the easiest to more complicated.

Using the HDMI cable and USB ports

This is the easiest and most user-friendly way to connect to your device. An HDMI Type-A to Type-A cable is already included in your kit, so all you need is to connect one end to your Pi's HDMI input, and other end to any HDMI-compatible screen. If you're connecting to an analog TV, use can use a single RCA cable to connect your Pi's RCA port to the monitor, however, the quality will not be as good as an HDMI connection.

Also, you need a USB keyboard and mouse for input; just connect both to the two USB-inputs on your Pi. Wireless keyboards and mice should also work as long as they're already paired. However, later on, if you want to use the WiFi adapter instead of an ethernet connection, you will need a usb hub as Raspberry Pi comes with only two USB ports; alternatively, you can use a wireless keyboard-mouse kit which works with a single USB dongle.

This method doesn't require any configuration, and everything should work in a plug-and-play way.

Using the TTL Console Cable

Using this method, you will be able to control your device from a terminal window, however, you will not be able to see the X (GUI) window.

Included cable has 3.3V logic levels so its safe to use, but beware using other TTL cables as they can damage your device. The big USB plug includes a USB-Serial conversion chip and Raspberry Pi uses its built-in serial port to allow access to other devices.

You need to use terminal emulation software with this method. If you're using a Mac, OSX already comes with terminal emulation software, so all you need is the USB drivers for the cable. If you're using Windows, you'll also need to install terminal emulation software.


TTL Console Cable

The TTL cable has four female connections that can be plugged directly onto the GPIO header of the Raspberry Pi. The four connections:

Red
is the 5V power. The important thing is, your Pi must be connected to one power source only, so either disconnect the micro-usb cable, or do not connect the red cable.
Black
is the ground, connect to GND.
White
is the transmitter, connect to TXD.
Green
is the receiver, connect to RXD.


How to connect TTL cable to your Pi

Mac

Download and install the TTL cable drivers for Mac OS X. After you've installed the driver, plug the cable, and enter this in the terminal window:

$ screen /dev/cu.[...] 115200

After "cu.", press tab and it should auto-complete devices name, then type 115200; the device name might be slightly different on your system, but it should start with "/dev/cu." (see: terminal screenshot)


Type "screen /dev/cu.[...] 115200" at the terminal window

The default username is "pi" and the password is "raspberry." At this point, you should be connected to your Pi through the console. (see: terminal screenshot)


Logged in to the Pi through TTL cable

Linux

Linux Kernels 2.4.31 and above already have the PL2303 USB driver for the Console Lead built-in, so you should not need to install any drivers. The connection process is the same as on Mac:

$ screen /dev/cu.[...] 115200

Windows

Note that Windows 8 is officially not supported at this point, however, for a work-around, see Troubleshooting for Windows 8 below. For earlier versions of Windows: you need to install a terminal emulation software; download and install PuTTY. Note that this is not an installer, but a portable executable file, so you can just run it. Then you need to install drivers for the TTL cable; download and install the PL2303 Windows Driver; unzip the file, run "PL2303_Prolific_DriverInstaller_v1.7.0.exe," and follow instructions to finish install. When you plug the cable in, Windows should automatically do a one-time install/update and detect the cable.

You need to know which COM port the TTL cable is connected to; for this, go to Device Manager, and you should see a COM port number with "Prolific USB-to-Serial" under Ports. Then start PuTTY, select "Serial" as the connection type, put the COM port you see in Device Manager under "Serial line," and enter 115200 under "Speed." Click "Open" to connect. The default username is "pi" and the password is "raspberry." (see: Login Window and After Logged in


Prolific Driver on Device Manager


PuTTY Configuration Window


PuTTY Login Window


Logged into Pi on PuTTY

Troubleshooting for Windows 8

To overcome the problem with Windows 8, you can use the old driver, v1.5.0, dowload it here. However, when you install this driver, Windows will also go ahead and update it without asking you, and you will end up with a non-functional device problem. To solve this problem, go to Device Manager, you should see a "!" symbol on "Prolific USB-to-Serial Comm Port (COMX)" under Ports, which means there is a problem with this device's driver. Right click on that device, click Properties, then click Driver on the tab menu, and finally click Roll Back Driver. This will delete the updated version of the driver, and roll back to the one you installed. At that point you should see a driver date of 2011, instead of 2013. Click "Ok" to exit this window. Now, the "!" symbol on the device should have disappeared, which means the device (TTL Cable) is known and working. Now you can start PuTTY, select "Serial," put the COM number you see on Device Manager, enter 115200 for the Speed, and click Open; you should have a console window which will ask you your username and password ("pi" and "raspberry" by default).


Device Non-functional under Device Manager


Windows auto-updates the driver to the newest but non-functioning one


Roll Back Driver


Driver rolled back to 2011 version


Device should be detected properly at this point

This method should solve the problem, and you should be able to connect to your Pi through the TTL cable, however, Windows can still update your driver from time to time, especially on restarts, and it may not give you the "Roll Back Driver" option anymore. If your device stops working, and a "!" symbol reappears on "Prolific USB-to-Serial Comm Port," then right click on the device, click "Uninstall," check "Delete the driver software" box, click Ok; now start the troubleshooting process again (install driver v1.5.0, plug cable, rollback the update) with selecting "Repair" option under installer.


Uninstall updated driver


Choose "Repair" when reinstalling

Troubleshooting for TXD and RXD cables

If when you're trying to connect through the console screen, the console freezes with the green cursor on the first line of the console, the problem mostly likely is that the RXD and TXD cables are not correctly connected. Some TTL cable manufacturers actually swap those two wires, so although the standard is White for TXD and Green for RXD, they may be manufactured in the opposite way. We try to get our TTL cables from the same suppliers, but that's not always possible. So if you experience a freezing console screen, just try swapping the white and green pins, and restart the Pi.

Using SSH connection

This connection type is ideal to control your device from anywhere, from the same room or from other side of the world. You canuse an SSH connection to connect to your Pi through the Internet. Note that for this method to work, your Pi must be connected to the internet through ethernet or WiFi; ethernet connection should be plug-and-play; for WiFi, see directions in this tutorial.

SSH (Secure Shell) is a unix tool that allows you to open a terminal session on your Pi using a host computer's command line. For security reasons, SSH is disabled by default, and if you're connecting a public network, you should either have set your passwords, or have SSH disabled. To enable SSH, type:

$ sudo raspi-config

in the command line and enter your password ("raspberry" by default). This will take you to the raspi-config utility, where you can change bunch of basic settings. Go to "SSH" option under "Advanced Options," hit return and select "Enable;" you should see an "SSH server enabled" message.


raspi-config utility; select "Advanced Options"


Select "SSH"


Select Enable


SSH server is enabled!

Finding Pi's IP Address

Next, we need to know what IP address Pi is using. If you're connected to your Pi with a display and keyboard, you can find this directly on Pi's terminal by typing:

$ sudo ifconfig

If you are not connected to your Pi with a display and keyboard, you need to use an IP-scanner utility to find the IP address. You can use and IP-scanner utility, but you can also find our suggestions under your operating system.

For Mac or Linux

On your host computer, first find your Raspberry Pi's IP address by using any IP-Scanner utility. We found IP Scanner app to be particularly useful (see: screenshot) because it detects the connected devices' names, and it's free for networks with up to 6 devices: .


IP_Scanner utility detects the IP addresses along with the device name

Once you know what your Pi's IP address is, type:

$ ssh [Your_Pi's_IP_Address] -l pi

in your terminal to connect to your Pi; "-l pi" tells ssh to use pi as the username, so terminal should prompt you to enter your password (see: screenshot). After you enter your password, your terminal prompt should turn to:

pi@raspberrypi ~ $

which means you are connected to your device, and you can control it from this very window (see: screenshot). Just type:

$ ls

to see contents of your Pi home folder.


Console asks you the password, as you've already supplied the username


Console window after log-in and ls

For Windows

Windows doesn't come with the required utilities, so you need to download and install the terminal emulator software PuTTY. Note that this is not an installer, but a portable executable file, so you can just run it.

To be able to start PuTTY console, first you need to detect your Pi's IP address on the network. For Windows, there are some third party software to scan your network for connected devices, and among many, we found this one useful: Advanced IP Scanner; you don't need an install, it can run as a portable exe file; after you run it, just click "Scan," and it should find your Pi with a manufacturer name of "Raspberry Pi Foundation" (see: screenshot). Of course your Pi should already be connected to the internet, and ethernet connection is a lot more easier at this point compared to WiFi, so if you can, just start with an ethernet connection.

Now that you know your Pi's IP address, run PuTTY and enter that address under "Host Name (or IP Address)," and make sure SSH is selected; click "Open." Only for the first time, you will get a security warning; if you are sure you have the correct IP Address, click "Yes" to continue. A console window should pop up and ask you for username and password. The default username and password is: "pi" and "raspberry." When you see the

pi@raspberrypi ~ $

prompt, greetings, now you're connected to your Raspberry Pi, and you can control it from this console window. Just type:

$ ls

to see contents of your Pi home folder.

One trick on using the PuTTY console is, when you want to copy and paste code from some other window, the usual key-bindings do not work; instead, just right click anywhere on the console window to paste.

With this method, you can connect to your Pi from anywhere, and control it; you can even start X window on the remote machine by typing:

$ startx

however, you won't be able to see the GUI window in the console.

Using VNC

If you want to be able to connect to your Pi remotely, or just don't want the extra clutter of an additional keyboard, mouse, and a display, but also just the console alone isn't enough for you, you also want to use the X window: using a VNC (Virtual Network Connection) is the perfect solution. For this method to work, we need to install some software both on the host computer and on your Pi, so until the setup is complete, you need access to your Pi with any of the above mentioned methods.

On your Pi

We need to install a VNC server so that our Pi can broadcast to the host computer. For our purposes, a lightweight VNC server, "tightvncserver," is enough. First, if you haven't done already, update the Pi:

$ sudo apt-get update

to get your OS's latest updates; then install tightvncserver:

$ sudo apt-get install tightvncserver

to install tightvncserver; enter "y" when prompted. Then we need to start the VNC server, by typing:

$ vncserver :1

For the first run only, it will ask you to create a password, which then you can use each time you want to start the server. Type and verify a password, no longer than 8 characters, and when prompted for a read-only password, say no. The server should already be running; and the next time you want to start the server, you can just type "vncserver :1" and put your password. Also, it is possible to set up so that VNC server starts automatically on every boot.


Get your Pi up-to-date


Install tightvncserver


Finally, start tightvncserver

On The Host Computer

Now, we need to install a VNC client on the host computer. If you're using a Mac, there's built-in support for a basic VNC client; just open Finder, select Go -> Connect to Server and type in your Pi's IP address. If you're on Windows, or want to install a dedicated VNC client, there are many options on VNC clients, and any of them should work fine, but we used and tested "RealVNC." Download and install RealVNC for your operating system. The first time you run VNC Viewer, it will ask you VNC Server address; put your Pi's current IP address, appending a ":1" for port; it should look like: "192.168.0.14:1". Click "Continue" on this and the following page. On Authentication page, enter the password you created in tightvncserver. The X window should come up and at this point, you should be able to use your Raspberry Pi's GUI as if you connected a mouse, keyboard, and display directly. You can move your mouse in and out of this window to switch control between your Pi and the host computer. (see: VNC screenshot)


X desktop on Pi, connected through Mac's VNC client

Troubleshooting

This works fine until your Pi reboots for any reason. After a reboot, either you need to start VNC server manually, or you need to set it up so that it starts automatically on every reboot. To make this work, we just need to create a simple config file. Log into your Pi console, either connecting with a display and keyboard, or through SSH, and you should be in your home directory, which is:

/home/pi

You can check that by typing:

$ pwd

for "Present Working Directory." The config directory is a hidden directory, and under linux, hidden files start with a ".". Type:

$ cd .config

to go to that dir. Inside the ".config" dir, type:

$ mkdir autostart

to create a new dir, then type:

$ cd autostart

Inside autostart dir, type:

$ nano tightvnc.desktop

to create a config file which will start tightvncserver on every boot. Modify the file as follows:

[Desktop Entry]

Type=Application

Name=TightVNC

Exec=vncserver :1

StartupNotify=false

Click ctrl+x and then "y" to save. Now your Pi is set up to start the VNC server on every boot, however, there is one caveat: this will start the server when the X window starts, so your Pi should also be set up to start X on boot. To do that, on terminal type:

$ sudo raspi-config

This will open a utility that is designed to tweak most used settings of your Pi. In that window, scroll down to "boot_behaviour", hit return, select Yes, then use left-right arrows to get to Finish, hit return, and hit return to reboot. Now your Pi should start directly to X on every boot and that should allow autostart of the VNC server.

Tip: if you want to set your VNC server to a specific screen size, you can use:

$ vncserver :1 -geometry 1440x900

either manually or by adding to the autostart script.

Internet Connection

Using an Ethernet Cable

The easiest way to connect your Raspberry Pi to the world is using the ethernet connection. Just plug one end of your ethernet cable to your modem, and the other end to your Pi, and the network LED's should start to flicker. If you're on your home network, no further configuration should be necessary. Although, if your modem's DHCP is turned off, you should log into your modem and enable it from the manufacturer's settings page.

Using the WiFi Adapter

Setting up WiFi requires that your router is broadcasting SSID. Make sure you have "Broadcast SSID" set up on your router! This will not work with "private" SSID setups. For setting up any connection other than with ethernet, you need access to your Pi; see above sections for how to connect to your Pi.

Using the X window

Raspbian has a utility for setting up your WiFi, called "WiFi Config," and it's on the desktop. Run that program and click "Scan," find your network, double-click, and enter your password in the pop-up window, click "Connect."

Run "WiFi Config" and double click on your connection; the IP address will appear at the bottom. You can simply open the browser to see if it's working.

Using the command line

Boot your Raspberry Pi without the WiFi adapter plugged in. After boot is completed and you're logged in, enter:

$ sudo nano /etc/network/interfaces

in the command line Modify the code as below:

auto lo


iface lo inet loopback

iface eth0 inet dhcp


allow-hotplug wlan0

auto wlan0


iface wlan0 inet dhcp

        wpa-ssid "ssid"

        wpa-psk "password"

Change the ssid and password with your details, keeping the double-quotes. SSID is your wireless network's name, and the password is the wireless password. When you're done, press ctrl+x, and press y then enter to save the modified file. Type:

$ sudo reboot

to reboot your Pi; when it does, it should automatically connect to the wireless network you defined.

To find your IP address, type:

$ sudo ifconfig

and under either eth0 or wlan0, depending on how you connected to the internet, you can find your current IP address. Type:

$ ping google.com

to check your connection.

To turn on/off your connection:

$ sudo [ifup|ifdown] [eth0|wlan0]

Other Handy Commands

Shut down Raspberry Pi:

$ sudo halt

Restart Raspberry Pi:

$ sudo reboot

Update Raspberry Pi's operating system:

$ sudo apt-get update

"Raspi-Config" utility to tweak the most used settings such as startup options, password, camera, and internationalization:

$ sudo raspi-config
 

What's News

newsletter

Copyright 2019 oddWires. All Rights Reserved.
 Sitemap | oddWires