Spresense Header CodeSpresense Header Code

Edge computing with low power consumption

The Spresense development board enables edge solutions with high computing ability and low power consumption.

Spresense Arduino Library Getting Started Guide

This section helps you set up the environment on your computer to:

  1. Install the Spresense Arduino Library.

  2. Set up your computer to run Spresense Arduino Library sketches.

  3. Run a sample application on the Spresense board to test the setup.

1. Supported Operating Systems

The Spresense Arduino Library runs on the following operating systems:

  • Windows 8/8.1/10

  • 64bit version Linux Ubuntu 16.04

  • Mac OS X 10.12 Sierra

2. Prerequisites

  1. Download and install the Arduino IDE for your operating system:

  2. Download and install the USB-to-serial drivers that correspond to your operating system from the following links:

For Windows 10, please download v10.1.3 from the above URL and install it. If you use the latest driver (v10.1.4), a problem that transmission data have been lost may occur when the serial terminal is opened.

Installing extra drivers is not necessary for 64bit Linux Ubuntu.

2.1. Linux USB serial port configuration

  • 64bit Linux Ubuntu requires the user to be a member of the dialout group.

    1. Add user to dialout groups.

      $ sudo usermod -a -G dialout $USER
    2. Logout and login again to use the new settings.

    3. Connect the Spresense board to the PC via the USB cable.

You must set up the USB port to be able to upload the built image to the Spresense board.

3. Install Spresense Arduino Library

There are two installation methods to choose from:

We recommend installing through the Arduino IDE Board Manager for ease of use. If you are unable to complete installation through this method, you can still install the library using the manual install method.

3.1. Installation through Arduino IDE Board Manager

The following steps will describe how to install the Spresense Arduino Library into the Arduino IDE using the Board Manager.

  1. Start Arduino IDE.

  2. Open the preferences in [File→Preferences].

    tutorial arduino open preferences
    Figure 1. Open preferences
  3. Copy and paste https://github.com/sonydevworld/spresense-arduino-compatible/releases/download/generic/package_spresense_index.json into the field called Additional Boards Managers URLs:

    tutorial arduino preferences add bm url
    Figure 2. Copy this https://github.com/sonydevworld/spresense-arduino-compatible/releases/download/generic/package_spresense_index.json URL and paste it into the Additional Boards Manager URLs field.
  4. Open the Boards Manager [Tools→Board→Boards Manager].

    tutorial arduino open boardmanager
    Figure 3. Open the Boards Manager.
  5. Search for Spresense. Once found in the list, select it and click install. If the package list fails to download, a possible reason is your network connection uses a proxy. To set the proxy, navigate to [File → Preferences → Network].

    The Spresense board package size is above 150 MB. Please be aware of the impact to your network usage limits and charges.
    tutorial arduino boardmanager spresense install
    Figure 4. Search for Spresense, select it and click install.
  6. The Spresense Arduino Library is now installed.

3.2. Manual installation

  1. Download the manual installation board package zip file manual-install-spresense-arduino-"OPERATING_SYSTEM"-latest.zip for your platform from:

  2. Follow the installation instructions for the respective PC platform:

  3. Start Arduino IDE.

  4. Open the preferences in [File→Preferences].

  5. In the Arduino IDE Preferences dialog box, set https://github.com/sonydevworld/spresense-arduino-compatible/releases/download/generic/package_spresense_index.json in the field called Additional Boards Managers URLs: and close the dialog box. This is to prevent the Arduino Boards Manager UI from removing the Spresense board listing.

3.2.1. Install Spresense Arduino Library for Windows

The following steps assume you have installed WinZip on your PC.

Use "Expand All (T)" option if you are using Windows Explorer.
  1. If you have not started the Arduino IDE for the first time, start the application and close it. Check that a folder called %userprofile%/AppData/Local/Arduino15 exists.

  2. Right-click on the ZIP file, open the menu to select Extract> Extract to folder and navigate to %userprofile%/AppData/Local/.

  3. The board package is now installed.

3.2.2. Install Spresense Arduino Library for Linux

The following steps assume you have a 64-bit Ubuntu PC and you have stored the downloaded file manual-install-spresense-arduino-linux-latest.zip at ~/Downloads.

  1. If you have not started the Arduino IDE for the first time, start the application and close it. Check that a folder called ~/.arduino15/ exists.

  2. Open the terminal and navigate to the folder where you have stored manual-install-spresense-arduino-linux-latest.zip.

  3. Extract the contents to ~/Downloads.

    $ cd ~/Downloads
    $ unzip manual-install-spresense-arduino-linux-latest.zip
    $ rm -rf ~/.arduino15/packages/SPRESENSE
    $ cp -rfv ~/Downloads/Arduino15/* ~/.arduino15/
    $ rm -rf ~/Downloads/Arduino15
  4. The board package is now installed.

3.2.3. Install Spresense Arduino Library for Mac OS X

The following steps assume you have stored the downloaded file manual-install-spresense-arduino-macosx-latest.zip at ~/Downloads.

  1. If you have not started the Arduino IDE for the first time, start the application and close it. Check that a folder called ~/Library/Arduino15 exists.

  2. Open the terminal and navigate to the folder where you have stored manual-install-spresense-arduino-macosx-latest.zip.

  3. Extract the contents to ~/Library/.

    $ cd ~/Downloads
    $ unzip manual-install-spresense-arduino-macosx-latest.zip -d ~/Library/
  4. The board package is now installed.

4. Setting up the environment

4.1. Identify the serial port used by Spresense board

Connect your PC to the Spresense main board USB connector and check that the power LED turns on. The serial port driver may install at this point if it has not done so already.

spresense musb connect
Figure 5. Connection to the Spresense main board USB connector with power LED on

4.1.1. Windows

To find the serial COM port used by the Spresense board in Windows:
  1. Open the Device Manager.

  2. Expand Ports (COM & LPT), look for the Silicon Labs CP21x USB to UART Bridge device.

tutorial arduino windows device manager find port
Figure 6. Device Manager displays the serial COM port where COM9 is the COM port in this example

4.1.2. Linux

To find the serial COM port of the Spresense board in Ubuntu/Linux.

Open a terminal and type:

$ dmesg | grep "cp21.*attached"
[12220.625979] usb 1-1: cp210x converter now attached to ttyUSB0

In this example the COM port is ttyUSB0.

4.1.3. Mac OS X

To find the serial COM port of the Spresense board in Mac OS X.
  1. Open a terminal and type:

ls /dev/{tty,cu}.*
/dev/cu.SLAB_USBtoUART  /dev/tty.SLAB_USBtoUART

In this example the COM port is cu.SLAB_USBtoUART.

4.2. Install Bootloader

  1. Select the Spresense board in the [Tools→Boards→Spresense] menu.

    tutorial arduino board spresense
    Figure 7. Select the Spresense board
  2. Select the serial port used by Spresense from the menu [Tools→Port]. If there is more than one port see Identify the serial port used by Spresense board for more info.

    tutorial arduino select port
    Figure 8. Select port, this example shows how it looks like in Windows.
  3. If you are using the Spresense board for the first time, or if you are using an updated version of the Spresense Arduino Library, update the boot loader by selecting [Tools→Programmer→Spresense Firmware Updater].

    tutorial arduino select programmer
    Figure 9. Select correct programmer to be able to flash the firmware/boot loader.
  4. Then select [Tools→Programmer→Burn Bootloader].

    tutorial arduino burn bootloader
    Figure 10. Burn bootloader.
  5. Review and accept the EULA by following the dialog.

    tutorial arduino eula dialog
    Figure 11. Accept EULA to load the bootloader binaries.
  6. Once the upload completes, this is how it should look like:

    tutorial arduino fw upload done
    Figure 12. Burn bootloader.

4.3. Build your first sketch to verify installation

  1. You have now finished setting up the board. To verify the setup is correct, copy and paste the following example LED test code into a new sketch:

    void setup() {
        pinMode(LED0, OUTPUT);
        pinMode(LED1, OUTPUT);
        pinMode(LED2, OUTPUT);
        pinMode(LED3, OUTPUT);
    }
    
    void loop() {
        digitalWrite(LED0, HIGH);
        delay(100);
        digitalWrite(LED1, HIGH);
        delay(100);
        digitalWrite(LED2, HIGH);
        delay(100);
        digitalWrite(LED3, HIGH);
        delay(1000);
    
        digitalWrite(LED0, LOW);
        delay(100);
        digitalWrite(LED1, LOW);
        delay(100);
        digitalWrite(LED2, LOW);
        delay(100);
        digitalWrite(LED3, LOW);
        delay(1000);
    }
  2. Build and upload the LED test sketch by clicking Upload.

    tutorial arduino upload
    Figure 13. Click Upload.
  3. Wait for the upload to complete.

    tutorial arduino upload example sketch done
    Figure 14. Uploading finished without errors.
  4. Your sketch should run automatically. When the LEDs on the main board are flashing, congratulations! Your setup is now complete!

    • If the LEDs doesn’t flash, press the board reset button or open the serial monitor to start the sketch.

    • You may increase the baud rate to shorten the transfer/upload time. This may not always work depending on what hardware you use (PC, cables etc). A recommendation is to start at the default value and increase the baud rate to test if the transfer still works.

      tutorial arduino select baudrate
      Figure 15. This picture shows the highest possible baud rate. Not guaranteed to work on every setup.

5. Explore further!

Now that you have set up your development environment, you can proceed to run example sketches to explore the features on the board or head over to Spresense Arduino Library Developer Guide to read more.

Spresense specific examples are available from the Arduino IDE at File > Examples > Spresense and on spresense-sketches GitHub repository. You can also run example sketches that work with Arduino Uno though be aware of the hardware differences. Spresense Hardware comparison section contains details of these differences.