Setting Up a Raspberry Pi Device to Run Oracle IoT Cloud Service Client Software


Options



Before You Begin

Purpose

In this tutorial, you will learn how to configure a Raspberry Pi device so that you can install Oracle Internet of Things (IoT) Cloud Service software on it.

Time to Complete

Approximately 45 minutes

Background

Intelligent devices are becoming an ever more important and ubiquitous part of our everyday lives. Mobile phones represented the first wave of smaller personal computers. And now, as the price of electronics and processing power continues to fall, there is an intersection between sensors and other electromechanical devices and computers that live on the edge of the Internet: close to the source of the data, processing the data locally and sending just what is required to other computers to consume. This wave of machine-to-machine (M2M) technology, or more broadly, the Internet of Things (IoT), is rapidly shaping the future of computing.

Oracle IoT Cloud Service enables you to manage very large numbers of devices and provides communication services between devices and enterprise applications. On a lower level, the Oracle IoT Cloud Service Gateway component runs on certain types of devices, enabling you to manage devices that cannot communicate directly with the Oracle IoT Cloud Service. Similarly, the Oracle IoT Cloud Service Client Software Library component can run on devices that do communicate directly with the Oracle IoT Cloud Service.

The Raspberry Pi is a computer that is about the size of a deck of cards, yet it is capable of running a Linux distribution on its ARM11 processor. The Raspberry Pi also supports USB, Ethernet, audio, HDMI, and RCA video output. But most importantly, the Raspberry Pi provides a 26-pin or 40-pin header that connects the computer to the outside world, through general-purpose input/output (GPIO) pins that can drive LEDs, read switches and other electronic signals, and connect to a wealth of inter-integrated circuit (I2C) devices, universal asynchronous receiver/transmitter (UART) devices, and more.

This tutorial assumes that you are using a Windows 7 system. If you have a system that is running native Linux, the steps may be easier, because your system may be able to access the Raspberry Pi device directly.

Scenario

In this tutorial, you will:

  1. Format an SD card

  2. Install a bootable operating system image on the SD card

  3. Insert the SD card in your Raspberry Pi, then configure the Raspberry Pi to connect to your host system and to the Internet

Context

After completing this tutorial, you'll want to move on to the following tutorials:

What Do You Need?

Before starting this tutorial, download the Raspbian Jessy zip file, and download and install the following software:

  • SD Association Formatter tool
  • SHA-1 checksum verifier tool
  • Win32DiskImager

Also, sign in to Oracle Cloud and note the time zone of your data center, which is displayed on your My Services dashboard. The time zone of the Raspberry Pi must match the time zone of the data center.

Data center time zone
Description of this image

Creating a Bootable Image for the Raspberry Pi

In order to boot, the Raspberry Pi requires a bootable Linux image on an SD memory card. There is no hard drive for the computer. Instead, the 32 GB card stores the image that the computer runs when it is powered on. This SD memory card also acts as the storage for other applications that are loaded onto the card.

Formatting the SD Memory Card with the SD Formatter Tool

  1. Insert the SD memory card into your computer or connect it to your computer by using an SD card peripheral.

  2. Start the SD Formatter tool and click Option.

    SD Formatter tool
    Description of this image
  3. In the Option Setting dialog box, select FULL (Overwrite) for Format Type and ON for Format Size Adjustment, and then click OK.

    SD Formatter options
    Description of this image
  4. Click Format to start the SD Formatter tool.

    Running SD Formatter
    Description of this image
  5. Click OK to format the SD memory card.

    SD Formatter dialog
    Description of this image

    A dialog box displays the progress of the format.

    SD Formatter progress
    Description of this image
  6. When the format is complete, click OK to close the dialog box.

    SD Formatter completion dialog
    Description of this image
  7. Click Exit to close the SD Formatter tool.

    Exit the SDFormatter Tool 
    Description of this image

You are now ready to install the Raspbian Jessie image in the SD memory card. Leave the card in the computer.

Extracting and Confirming the Raspbian Jessie Image

  1. Make a note of the SHA-1 checksum for the zip file that you downloaded. To do this, return to the http://www.raspberrypi.org/downloads/raspbian page and locate the checksum in the Raspbian Jessie part of the page.

    locate checksum
    Description of this image
  2. Open a command window in the directory where you downloaded the zip file and run the sha1sum.exe command on the Raspbian zip file.

    Running sha1sum.exe
    Description of this image

    Note: If the SHA-1 checksum does not match the checksum listed on the download page, try downloading the zip file again.

  3. Open an unzip tool and extract the contents of the Raspbian zip file. You can leave the file in the Downloads directory.

    The extracted file has the suffix.img.

  4. Start the Win32DiskImager application. Make sure that the device address is the same as the mount point for the SD memory card.

    Win32DiskImager application
    Description of this image
  5. Click the folder button, navigate to the location of the image file, and click Write.

    Win32DiskImager Write button
    Description of this image
  6. Click Yes to confirm that you want to overwrite the contents of the SD memory card.

    Win32DiskImager confirmation dialog
    Description of this image

    A progress meter is displayed.

    Win32DiskImager progress meter
    Description of this image
  7. When the Write Successful message is displayed, click OK.

    Win32DiskImager completion dialog
    Description of this image
  8. Click Exit to close the Win32DiskImager.

    Exiting Win32DiskImager
    Description of this image
  9. Remove the SD memory card from the computer.

You are now ready to boot and configure the Raspberry Pi.

Setting up the Raspberry Pi to Allow SSH Connections

To set up the Raspberry Pi, you configure Raspbian to allow SSH connections either by using a USB/TTY cable or by using a USB keyboard and an HDMI monitor. To ensure that the Raspberry Pi always has the same IP address, you configure the Raspberry Pi to use a static IP address.

Note: If you want to connect your Raspberry Pi to your network by using both wireless (WLAN) and wired (ETH0) options, choose a different fixed IP address for each connection type. Do not use the same IP address.

Option 1: Configuring SSH by Using a USB/TTY Cable

Important: You must install the PL2303HX.A drivers before you plug the USB cable into your PC.

  1. Download and unzip the PL2303HX.A driver software.

    Note: The Prolific drivers will not work with Windows 8.

  2. Double-click the PL2303_Prolific_DriverInstaller_v1.9.0.exe file to launch the installer and click Next on the Welcome page.

    Driver installer start page
    Description of this image
  3. When the InstallShield Wizard displays a success message, click Finish.

    Driver installer completion page
    Description of this image
  4. Attach the connector of the USB/TTL cable to the Raspberry Pi Model B as follows:

    • Red on the farthest right (closest to the edge of the board) pin of the GPIO header
    • Black on the third pin from the right
    • White on the fourth pin from the right
    • Green on the fifth pin from the right
    Raspberry Pi Model B connections
    Description of this image

    On the Model B+, the attachments look like this:

    • Red on the farthest right (closest to the edge of the board) pin of the GPIO header
    • Black on the fourth pin from the right
    • White on the fifth pin from the right
    • Green on the sixth pin from the right
    Raspberry Pi Model B+ connections
    Description of this image
  5. Insert the SD memory card into the Raspberry Pi.

  6. Connect the Ethernet cable to the Raspberry Pi and to your network.

  7. Plug the USB end of the cable into your PC.

    Note: The USB cable will power the Raspberry Pi. Do not plug in the micro-USB power cable at the same time. The Raspberry Pi should be powered by only one source at a time.

  8. Open an Explorer window, right-click Computer and select Properties.

    Computer menu Properties selection
    Description of this image
  9. In the Control Panel dialog box, click Device Manager.

    Control Panel menu
    Description of this image
  10. Scroll to Ports, expand Ports, and make a note of the port number for the Prolific USB-to-Serial Comm Port connection.

    Device Manager ports
    Description of this image

    Note: If you don't see the Prolific USB-to-Serial Comm Port connection, try rebooting your PC.

  11. Start putty.exe and specify the following, then click Open.

    • Select Serial as the connection type.

    • Enter the COM port number that you noted in step 10.

    • Enter 115200 for the speed.

    PuTTY Configuration dialog box
    Description of this image
  12. In the PuTTY window, enter pi as the login name and raspberry as the password.

    PuTTY login to Raspberry Pi
    Description of this image

    Note: You may have to press the Enter key to establish the initial connection.

  13. Enter sudo raspi-config.

    Running raspi-config
    Description of this image
  14. Select Expand Filesystem (setup option 1) and press Enter to expand the file system and use all of the SD memory card storage.

    Expand Filesystem selection
    Description of this image
  15. Press Enter to close the confirmation screen.

    Expand Filesystem confirmation
    Description of this image
  16. Press the up or down arrow key to select Internationalisation Options (setup option 4) and press Enter.

    Internationalisation Options selection
    Description of this image
  17. Press the up or down arrow key to select Change Timezone (internationalisation option I2) and press Enter.

    Change Timezone selection
    Description of this image
  18. Press the up or down arrow key to select the geographic area where your data center is located (not necessarily the one where you are located) and press Enter.

    Geographic area selection
    Description of this image
  19. Press the up or down arrow key to select the time zone of your data center and press Enter.

    Time zone selection
    Description of this image
  20. Press the up or down arrow key to select Advanced Options (setup option 8) and press Enter.

    Advanced Options selection
    Description of this image
  21. Press the up or down arrow key to select SSH (advanced option A4) and press Enter.

    SSH selection
    Description of this image
  22. Press the left or right arrow key to select Enable and press Enter.

    Enabling SSH
    Description of this image
  23. Press Enter to close the confirmation screen.

    Completing SSH
    Description of this image
  24. Press the left or right arrow key to select Finish and press Enter.

    Finishing configuration
    Description of this image
  25. Press the left or right arrow key to select Yes and press Enter to reboot the Raspberry Pi.

    Confirming reboot
    Description of this image

    The Raspberry Pi reboots.

    Reboot completion
    Description of this image
  26. Enter pi as the login and raspberry as the password.

    PuTTY login to Raspberry Pi
    Description of this image
  27. Enter ifconfig -a.

    Running ifconfig
    Description of this image

    Make a note of the IP address that your network provided for the Raspberry Pi.

    ifconfig display
    Description of this image
  28. Unplug the USB cable from the PC and disconnect the leads from the Raspberry Pi.

  29. Plug the power cable into the Raspberry Pi.

  30. Exit the PuTTY window.

From now on you will need only the power and Ethernet connection on the Raspberry Pi to access it using PuTTY.

Now, follow the instructions in the next section, "Connecting to the Raspberry Pi with the Secure Shell."

Connecting to the Raspberry Pi with the Secure Shell

  1. Start putty.exe and specify the following.

    • Enter the IP address in the IP address field.

    • EnterRaspberry SSHin the Saved Sessions field.

    • Click Save.

      Saving PuTTY session
      Description of this image
  2. Click Open.

    Opening PuTTY session
    Description of this image
  3. Click Yes to accept the security alert.

    Accepting security alert
    Description of this image
  4. Enterpias the Login value andraspberryas the password.value.

    Raspberry Pi login
    Description of this image

Option 2: Setting the Raspberry Pi for a GUI Login

To set up the Raspberry Pi for a GUI login, you need a USB keyboard and an HDMI monitor, so that you can use the Raspbian graphical user interface.

  1. Set up the physical connections for the Raspberry Pi:

    • Insert the SD memory card into the Raspberry Pi, pin-side up.
    • Connect the USB keyboard and USB mouse.
    • Connect the HDMI cable for the monitor.
    • Connect the Ethernet cable.
    • Plug in the power cable.

    For a Raspberry Pi Model B Revision 2, the connections look like this:

    Raspberry Pi Model B connections
    Description of this image

    For a Raspberry Pi Model B+, the connections look like this:

    Raspberry Pi Model B+ connections
    Description of this image
  2. After a few moments, the monitor displays text, logging you in automatically as the user pi, and the Raspberry Pi GUI appears. In the top left corner are icons for several programs, including a web browser, a file manager, and a terminal window.

    Raspberry Pi GUI display
    Description of this image
  3. To configure the Raspberry Pi, you open a terminal window. Click the terminal icon to open a command prompt window.

    Selecting terminal window
    Description of this image

    The command prompt window looks like this.

    Terminal window
    Description of this image
  4. In the command prompt window, enter the following command to open the raspberry Pi configuration file:

     sudo raspi-config

    Note: nano is a simple text editor. If you prefer, you can use vi or another editor. You can also configure from the Menu button. Click Menu > Preferences > Raspberry Pi Configuration.

  5. Theraspi-config configuration screen appears. Select Expand Filesystem (setup option 1) and press Enter to expand the file system and use all of the SD memory card storage.

    Expand Filesystem selection
    Description of this image
  6. Press Enter to close the confirmation screen.

    Expand Filesystem confirmation
    Description of this image
  7. Press the up or down arrow key to select Internationalisation Options (setup option 4) and press Enter.

    Internationalisation Options selection
    Description of this image
  8. Press the up or down arrow key to select Change Timezone (internationalisation option I2) and press Enter.

    Change Timezone selection
    Description of this image
  9. Press the up or down arrow key to select the geographic area of your Oracle Cloud data center (not necessarily your own geographic area) and press Enter.

    Geographic area selection
    Description of this image
  10. Press the up or down arrow key to select the time zone of your data center and press Enter.

    Time zone selection
    Description of this image
  11. If you are not in Great Britain, select Internationalisation Options again and press Enter, then select Change Locale and follow the prompts to set your locale.

    You may also want to select Change Keyboard Layout and follow the prompts to identify your keyboard properly.

  12. Press the up or down arrow key to select Advanced Options and press Enter.

    Advanced Options selection
    Description of this image
  13. Press the up or down arrow key to select SSH (advanced option A4) and press Enter.

    SSH selection
    Description of this image
  14. Press the left or right arrow key to select Enable and press Enter.

    Enabling SSH
    Description of this image
  15. Press Enter.

    Completing SSH
    Description of this image
    Note: After enabling SSH, go through the same steps to enable SPI and I2C (options A6 and A7)
  16. Press the left or right arrow key to select Finish and press Enter.

    Completing configuration
    Description of this image
  17. Press the left or right arrow key to select Yes and press Enter to reboot the Raspberry Pi.

    Rebooting Raspberry Pi
    Description of this image

    The Raspberry Pi reboots.

Configuring the Raspberry Pi for Internet Access

If you are behind a firewall, you need to specify the proxy through which you access the Internet. In addition, you need to specify some other Linux configuration settings.

Note: You can also perform these steps using PuTTY.

  1. Click the terminal icon to open the command prompt window.

    If you are not behind a firewall, skip to step 6.

  2. Become root, go to root's home directory, and open a text editor for editing the.profile file:

    sudo su
    cd
    nano .profile
  3. Edit the.profile file to add the following settings:

    export ftp_proxy=http://my-proxy:my-port
    export http_proxy=http://my-proxy:my-port
    export https_proxy=http://my-proxy:my-port
    

    Theexportstatements look something like the following.

    Editing profile
    Description of this image

    Press Ctrl + O and then press Enter to save the file. Press Ctrl + X and then press Enter to close nano and return to the prompt.

  4. Enter the following to activate your proxy settings:

    source .profile
  5. Enter the following to ensure that your Raspberry Pi software is up to date.

    apt-get update; apt-get upgrade

    It takes several minutes to perform all the updates. You may be asked for confirmation on some packages.

    Running apt-get
    Description of this image
  6. Enter the following (all on one line) to obtain software needed to use and run the Gateway:

    apt-get install wget curl git build-essential ant binutils avahi-daemon

    It takes several minutes to obtain all the software.

  7. Enter the following command to reboot the Raspberry Pi:

    reboot

(Optional) Obtaining a Static IP Address for the Raspberry Pi

You may need to obtain a static IP address for your Raspberry Pi. In that case, follow these steps.

  1. After the system reboots, open a terminal window and enter the following command to determine your IP address:

    ifconfig

    Your IP address is displayed in the inet addr field.

    ifconfig output
    Description of this image
  2. Use the nano tool to specify your IP address in your /etc/hosts file.

    sudo nano /etc/hosts
    Editing /etc/hosts file
    Description of this image

    Press Ctrl + O and then press Enter to save the file. Press Ctrl + X and then press Enter to close nano and return to the prompt.

    If you prefer, you can specify another name for your device instead of the default name raspberrypi. If you do, use nano to edit your /etc/hostname file to specify the new name.

  3. Use the nano tool to edit the /etc/network/interfaces file, using the information supplied by the ifconfig command you ran in step 1.

    sudo nano /etc/network/interfaces

    Comment out the iface eth0 inet dhcp line by placing a # symbol at the beginning of the line.

    Below that, add the following lines:

    auto eth0
    iface eth0 inet static

    Use your network settings to add the IP, network, netmask, broadcast, and gateway addresses. For example:

    address 192.0.2.10
    network 192.0.2.0
    netmask 255.255.252.0
    broadcast 192.0.2.255
    gateway 192.0.2.1

    If you are behind a firewall, add the DNS server information needed. The result will look something like this.

    Editing /etc/network/interfaces file
    Description of this image

    Press Ctrl + O and then press Enter to write the file. Press Ctrl + X and then press Enter to close nano and return to the prompt.

Want to Learn More?