Developer World Spresense
日本語 中文
Table of Contents

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.1/10

  • 64bit version Linux Ubuntu 16.04 or later

  • Mac OS X 10.12 Sierra or later

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:

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.

2.2. macOS High Sierra (10.13) or later

On High Sierra (10.13) and later, the installation of the driver may be blocked.

Please allow this driver from System Preferences Security & Privacy pane.

See Apple Technical Note TN2459 "User-Approved Kernel Extension Loading" for more information.

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 the following URL into the field called Additional Boards Managers URLs:

    tutorial arduino preferences add bm url
    Figure 2. Copy this 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 the following URL 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

Extracting manual-install-spresense-arduino-windows-latest.zip may cause an error, the file path name is too long. Therefore, the procedure described here extracts the zip file to a folder with a short path name such as c:\temp.

  1. Create c:\temp folder and unzip manual-install-spresense-arduino-windows-latest.zip to the folder.

    The packages folder and a package_spresense_index.json file will be under an Arduino15 folder.

    diag 79be46362fa940a8fc33c3d7698ee185
  2. Copy these files to Arduino IDE installation folder.

    Open %userprofile%\AppData\Local\Arduino15 folder and copy packages and package_spresense_index.json to the folder.

    diag 968ac09f7961ee1972a323fa732abbdb

    In case of Arduino IDE installed from Microsoft Store, the destination folder is different.
    Open %userprofile%\Documents\ArduinoData folder and copy packages and package_spresense_index.json to the folder.

    diag 3fc8f6bcefddda32ad8d79ad44d756a7
  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.2. Install Bootloader

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

    tutorial arduino board spresense
    Figure 6. 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 7. 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 8. Select correct programmer to be able to flash the firmware/boot loader.
  4. Then select [Tools→Programmer→Burn Bootloader].

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

    tutorial arduino eula dialog
    Figure 10. 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 11. 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 12. Click Upload.
  3. Wait for the upload to complete.

    tutorial arduino upload example sketch done
    Figure 13. 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 14. 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.

6. Appendix

6.1. Check USB serial driver connection

This section shows how to verify the USB serial driver connection for different platforms.

6.1.1. Check USB serial driver connection on Windows

  1. Open Device Manager

  2. Check the COM port number of the Spresense board.

tutorial arduino windows device manager find port
Figure 15. Device manager

6.1.2. Check USB serial driver connection on Ubuntu 64bit

Locate the COM port used to connect the Spresense board.

  1. Open the terminal.

  2. Enter the following command.

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

    In this example ttyUSB0 is the COM port.

6.1.3. Check USB serial driver connection on Mac OS X

Locate the COM port used to connect the Spresense board.

  1. Open the terminal.

  2. Enter the following command.

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

    In this example the COM port for CU command is cu.SLAB_USBtoUART or for tty command tty.SLAB_USBtoUART.