Oracle by Example brandingSet Up a Raspberry Pi for Connecting to Oracle IoT Cloud Service

section 0Before You Begin

This 15-minute tutorial shows you how to configure a Raspberry Pi device so that you can install Oracle Internet of Things (IoT) Cloud Service software on it.


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; 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.

What Do You Need?

  • A computer running Windows OS, 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
  • Raspberry Pi Model B Revision 2 or Model B+, power supply, Ethernet cable. (This tutorial has been tested with a Raspberry Pi Model B+. It should work equally well with earlier and later models (Model B or Raspberry Pi 2-3)
  • 32 GB SD memory card
  • Download and install the Raspbian image (make a note of the SHA-1 checksum for the zip file that you downloaded, locate the checksum in the Raspbian part of the page)
  • Download and install the SD Association Formatter tool
  • Download and install Win32DiskImager

section 1Create 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.

  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.
  3. In the Option Setting dialog box, select FULL (Overwrite) for Format Type and ON for Format Size Adjustment, and then click OK.
  4. To start the SD Formatter tool, click Format.
  5. Description of the illustration fmtsd_04.png
    Description of the illustration fmtsd_04.png
  6. To format the SD memory card, click OK.
  7. When the format is complete, you are now ready to install the Raspbian image in the SD memory card, now click OK to close the dialog box.
  8. Open an unzip tool and extract the contents of the Raspbian zip file. The extracted file has the suffix .img.
  9. Start the Win32DiskImager application. Make sure that the device address is the same as the mount point for the SD memory card.
  10. Click the Folder button, navigate to the location of the image file, and click Write.
  11. Description of the illustration dnld_05.png
    Description of the illustration dnld_05.png
  12. Click Yes to confirm that you want to overwrite the contents of the SD memory card.
  13. When the Write Successful message is displayed, click OK.
  14. Close the Win32DiskImager and remove the SD memory card from the computer. You are now ready to boot and configure the Raspberry Pi.

section 2Set up the Raspberry Pi to Allow SSH Connections

To set up the Raspberry Pi, you configure Raspbian to allow SSH connections by using a USB keyboard, mouse and an HDMI monitor in the Raspbian graphical user interface (GUI).

  1. Insert the SD memory card into the Raspberry Pi, to start to set up the physical connections for the Raspberry Pi.
  2. Connect the USB keyboard and USB mouse.
  3. Connect the HDMI cable for the monitor.
  4. Connect the Ethernet cable.
  5. Plug in the power cable.

    The connections look like this for a Raspberry Pi Model B+:

    Description of kbd_01.jpg follows
    Description of the illustration kbd_01.png
  6. Wait until the Rasperry Pi starts.
  7. To configure the Raspberry Pi, click the terminal icon to open a terminal window.
    Description of int_01.png follows
    Description of the illustration int_01.png
  8. In the terminal window, enter the following command to open the Raspberry Pi configuration file:
    sudo raspi-config
  9. The raspi-config configuration screen appears. Select Advanced Options, and then select Expand Filesystem and press Enter to expand the file system and use all of the SD memory card storage.
    Description of kbd_02.png follows
    Description of the illustration kbd_02.png
  10. Select Interfacing Options and press Enter.
  11. Select SSH and press Enter.
  12. Select Enable and press Enter then Enter again.

    Note: After enabling SSH, go through the same steps to enable SPI and I2C

  13. Select Finish and press Enter.
  14. Select Yes and press Enter to reboot the Raspberry Pi.

section 3Configure 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.

  1. To open the command prompt window, click the terminal icon.

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

    The export statements look something like the following:

    Description of int_04.png follows
    Description of the illustration int_04.png
  4. To save the file press Ctrl + O and then press Enter. To close nano and return to the prompt press Ctrl + X and then press Enter.
  5. Enter the following to activate your proxy settings:
    source .profile
  6. 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.

    Description of int_06.png follows
    Description of the illustration int_06.png
  7. To obtain software needed (it takes several minutes to obtain all the software), enter the following (all on one line):
    apt-get install wget curl git build-essential ant binutils avahi-daemon
  8. Enter the following command to reboot the Raspberry Pi:

more informationWant to Learn More?