Click here to Skip to main content
13,629,039 members
Click here to Skip to main content
Add your own
alternative version

Stats

3.8K views
1 bookmarked
Posted 10 Nov 2017
Licenced CPOL

UP SQUARED Grove IoT Development Kit Getting Started Guide

, 10 Nov 2017
Rate this:
Please Sign up or sign in to vote.
Follow these steps to connect your board to Arduino Create and begin working with your development kit.

Editorial Note

This article is for our sponsors at CodeProject. These articles are intended to provide you with information on products and services that we consider useful and of value to developers

Follow these steps to connect your board to Arduino Create* and begin working with your development kit.

You’ll walk through the following basic steps:

  1. Make Board Connections Connect the Grove Pi+* board and the cables to power on your UP²* board.
  2. Connect to Arduino Create*
    Sign up on for an Arduino Create account and connect the UP² board to the Arduino Create Web Editor.
  3. Run the Blink Application
    Find and run a sample application to blink an LED.

Before you begin: Gather your materials

Gather your items from this kit:

You’ll also need the following, not included in the kit:

  • Ethernet cable and internet access
  • A host computer, connected to the Internet

Your prototyping environment

When you've completed the steps in this guide, your environment will be set up like this:

You'll be able to code your sketches, and upload and run them on your UP² board via the cloud from your host computer.

Step 1: Connect Your Board

In this step, you will:

  • Install the Grove Pi+* board
  • Connect your micro USB cable
  • Connect your Ethernet cable
  • Power up your board

Install the Grove Pi+* board

  1. On the UP²* board, locate the small white arrow. This indicates connector 1 on the board.


     
  2. Line up pin 1 on the Grove Pi+ board with connector 1 on the UP² board, and carefully press down so that the pins on the Grove Pi+ board slide neatly into the connectors.

Plug the Micro USB Cable into the UP²* Board

  1. On the UP² board, locate the USB 3.0 Micro B port. The micro USB cable plugs into the left side of this port.



     
  2. Plug the micro USB cable into the left side of the USB port on the UP² board.


     
  3. Connect the micro USB cable to your host computer.

    Note: Even though you might see lights turn on after you plug in the micro USB cable, this connection isn't enough to power your board reliably. The micro USB connection is used to set up the Arduino Create development environment. You'll connect the board to a power supply shortly.

Connect the Ethernet Cable to the UP²* Board AND to your Router

  1. Plug the Ethernet cable into the UP² board.


     
  2. Plug the other end of the Ethernet cable into your router, connecting it to the same network as your host computer.

    Note: Your host computer does not need to be on the same network as your UP² board.

Power up your board

  1. Plug in your UP² board to its power supply and plug the power supply into an electrical outlet.

    Note: If you need to turn off your board, you can do so by pressing the small white button next to the blue LED, or you can simply unplug the power cable.

Connections are complete!

Your board should look like this. You're ready for the next step.

Step 2: Make Board Connections

In this step, you will:

  • Sign up for Arduino Create*
  • Install the Arduino plugin on your host computer
  • Verify your board's connections
  • Upload the Arduino connector to your board
  • Name your board

Configure the UP2* Board

On your host computer, go to https://create.arduino.cc/getting-started/up2. Then click Login.

Note: If you don’t already have an Arduino Create account, follow the onscreen instructions to sign up. You'll need to activate your account and log into the site using your new account.

  • If this is your first time using Arduino Create, you’ll be asked to install the Arduino plugin. Follow the onscreen instructions to install the Arduino plugin.

    Note: If you get an error message saying We are not able to detect the installed plugin, try locating the Arduino Plugin icon in your system tray, right-click, then select Open plugin.

Verify your board's connection

  1. After installing the plugin, you’ll see a page asking you to double-check that your board is properly connected so the connector can be installed. Verify that it is still powered on and click Next.

    Note: If you've completed Step 1 in this guide, your board is already set.


Upload the Arduino* connector to your board

If you find yourself on this "Connecting your board to Arduino Create" screen for than 3 minutes, check your connections (Ethernet, micro USB, power) and try again. If that doesn’t work, try these troubleshooting tips:

  • Completely restart your UP² board by removing the power supply and the micro USB cable. Then power it back on. Wait a couple of minutes for it to boot, then try to connect to Arduino Create again.
  • If your host computer has Windows*, minimize all windows to make sure you haven’t missed a pop-up message asking you to install a driver.
  • Force a "hard refresh" on the Arduino web page. For example, if you’re on Chrome*:
    • For Windows, press Ctrl+Shift+R.
    • For macOS*, hold Shift and click the Reload button.

Name your board

  1. Give your board a name, such as up2.

Now you’re ready for the next step, running your first program.

Note: Your board connects to the Arduino Create development environment over the Internet. If you disconnect your board and move it to another location, it should reconnect to the Arduino Create environment. If you are using proxy settings, you will need to go through this setup process again if move your board to a network that doesn’t have a proxy.

Step 3: Run the Blink Application

In this step, you will:

  • Connect an LED
  • Open the sample Blink application
  • Modify the sketch for your board
  • Upload your sketch using Arduino Create*
  • Dig into the code

Connect an LED

  1. Locate the Grove* Green LED in your Grove kit and use a Grove* Cable to connect it to D4 on your Grove Pi+* board. It’s ok to leave your board on when plugging in the LED.

    Note: You may need to first plug the LED into the terminals on the Grove LED module; if so, be sure to connect the longer wire to the positive terminal.

Open the Sample Blink application

  1. If it's not open already, open the Arduino Web Editor.
  2. Open the Blink example made specifically for this kit. You can find it in Examples > FROM LIBRARIES > UP SQUARED GROVE IOT DEV KIT > Blink.

    Note: Each example contains a link to the corresponding readme in GitHub* for instructions on how to set up and run that example. Here’s what it looks like for the Blink example:

Upload your Sketch Using Arduino Create*

Note: When you click Upload button, you're uploading and running the sketch on your target device. To compile your sketch without uploading and running it, click the Verify button to the left of the Upload icon.

  1. Choose your board, "via Cloud".


  2. Click the Upload icon to upload and run the sketch.

Your sketch is running!

  1. You can confirm that your sketch is running because the log at the bottom of the screen gives you a Process ID (PID). For example:


     
  2. You should see the LED flashing.

  • You have connected the LED to the right connector on the Grove Pi+ board (D4).
  • Make sure the board you have selected is the one that says via Cloud.
  • Your board is still connected. You can see this in the My Devices page https://create.arduino.cc/devices. It should say ONLINE. If it isn’t, check the network connections. If all else fails and your board continues OFFLINE, go through the setup process again, starting at Create an account and install the Arduino plugin.
  • Make sure the LED is plugged in the right way (the longer wire should be connected to the positive terminal). Try another LED if you have one.

Stopping and Starting Sketches

Now that your sketch is running, we’ll show you how to stop it.

  1. Go to the My Devices page by clicking the menu icon in the upper left and clicking My Devices. Alternatively, you can go to https://create.arduino.cc/devices.
  2. Click ‘1 SKETCHES RUNNING’.


You should now see the name of the sketch that you ran to blink the LED, for example ‘Blink’. Click on ‘RUNNING’.

You should now see ‘STOPPED’.

Digging into the code

You may have seen some lines in the code that you don’t recognize. Before we dive in, there are a couple of concepts to understand:

  • MRAA* (mraa.io) – pronounced ‘em rah’ is the hardware abstraction layer in Arduino Create for Linux*-based platforms. It is an open source project, and it supports multiple boards and programming languages. Using MRAA allows you to initialize and work with pins on a board with an easy-to-understand API.
  • Platform – The way that MRAA abstracts the hardware is through a pin mapping at the user space level. So when you use MRAA, you need to set your platform so the mapping is done correctly for your specific board. In this case, the platform is the UP² board, but MRAA supports over a dozen boards. You can see a complete list of the pin mapping here: https://github.com/intel-iot-devkit/up-squared-grove-IoT-dev-kit-arduino-create/blob/master/extras/pin-mapping.md

    MRAA supports GPIO, I2C, PWM, SPI, and UART. There is also a very useful library written on top of MRAA which is an abstraction for individual sensors. It’s called UPM and you can read about it at https://upm.mraa.io/. UPM is supported in Arduino Create for platforms using MRAA.
  • Sub-platform – When using MRAA, you have the option to define a sub-platform. A sub-platform operates with the same APIs as the platform, but you are required to add an offset of 512 to all pins. Note that you can only have one sub-platform for each application using MRAA . The most common reason to use a sub-platform is to expand the I/O capabilities of a platform. In this guide, the Grove Pi+ board provides easy to use connectors for the Grove sensors, a handy addition to the UP² board. On the Grove Pi+ board is an ATMEL ATMEGA 328, which gets programmed by MRAA with a Firmata* sketch when you try to run it as a sub-platform. The Firmata sketch running on the ATMEGA acts as sort of a slave, interpreting commands from the platform (MRAA application running on the UP² board) and passing data back and forth between the I/Os and the platform. The sub-platform is controlled via I2C (though it can also be done over serial).

Now to the code…

#define LED_BUILTIN 516

Since the Grove Pi+ board is a sub-platform of the UP² board, we need to offset the pin numbers by 512. Since the LED is connected to D4, the pin number we need to use is 4 plus the offset of 512, which is 516.

Digital pins and analog pins both start at zero. For example, Analog pin 0 (A0) corresponds to 512, and Digital pin 4 (D4) corresponds to 516.

mraa_add_subplatform(MRAA_GROVEPI, "0");

This line adds the Grove Pi+ board as a sub-platform.

The rest of the code uses the standard Arduino APIs.

Next Steps

Now that your board is connected to Arduino Create, continue on to the tutorials.

All our tutorials are located in github at https://github.com/intel-iot-devkit/up-squared-grove-IoT-dev-kit-arduino-create/tree/master/examples and can be accessed in the IDE in Examples > FROM LIBRARIES > UP SQUARED GROVE IOT DEV KIT

These tutorials generally fall into four categories:

If you’re not sure where to start, we recommend learning the basics about sensors with the GroveRotaryAngle tutorial.

OpenCV Setup

In this example, you'll learn how to download, build (compile) and install the OpenCV* 3.3.0 libraries.

Graphical User Interface (GUI) Installation

For UP2 kit, because the Ubuntu 16.04 operating system (included with the kit) does not include a Graphical User Interface (GUI), you'll need to install a GUI in order to view the results of image or video streams processed by OpenCV*.

sudo apt-get install --no-install-recommends ubuntu-desktop

--no-install-recommends includes required dependencies only. You can see the full list at https://packages.ubuntu.com/xenial/ubuntu-desktop

Reboot your system to complete the GUI install

reboot

This example continues on GitHub: https://github.com/intel-iot-devkit/up-squared-grove-IoT-dev-kit-arduino-create/tree/master/examples/OpenCV-Setup

OpenCV People Counter

In this tutorial, you’ll learn how to:

  1. Setup OpenCV 3.3.0 on Ubuntu 16.04 LTS
  2. Build a people counter application from source code in Arduino Create IDE.
  3. Run the people counter application from the command prompt on your Ubuntu* desktop.

This code sample continues on GitHub: https://github.com/intel-iot-devkit/up-squared-grove-IoT-dev-kit-arduino-create/tree/master/examples/OpenCV-PeopleCounter

Grove* LCD Dislpay

This example uses the Grove* LCD UPM library. It prints the value of the analog input from the Grove Rotary Angle Sensor to the display.

This example continues on GitHub: https://github.com/intel-iot-devkit/up-squared-grove-IoT-dev-kit-arduino-create/tree/master/examples/GroveLCD

Grove Rotary Angle Sensor

In this example, you’ll learn how to:

  1. Stop a sketch that is running
  2. Set up a serial monitor
  3. Read analog input data from a sensor
  4. Use the analog input to control a digital output

You’ll use the serial monitor to see the raw data coming from the sensor. You’ll be able to control the rate of an LED blinking using the input from a rotary angle sensor.

This code sample is also available on GitHub: https://github.com/intel-iot-devkit/up-squared-grove-IoT-dev-kit-arduino-create/tree/master/examples/GroveRotaryAngle

Gather your materials

You’ll need the following to complete this tutorial:

Stop running sketches

This tutorial assumes you have already set up your board to work with Arduino Create*. If you haven’t done that, go back to the Getting Started section

  1. Make sure to stop any running sketches before proceeding with this tutorial. The hardware abstractions layer (MRAA*) locks the hardware pins it is using, so if you try to run a different sketch using those same pins while the previous sketch is still running, it may not work.
  2. To stop running sketches, go to the My Devices page by clicking the menu icon in the upper left and clicking My Devices. Alternatively, you can go to https://create.arduino.cc/devices.
  3. Click 1 SKETCHES RUNNING.

  4. You should now see the name of the sketch that you ran to blink the LED, for example ‘Blink’. Click RUNNING.

  5. You should now see STOPPED.

Connect hardware

  1. Plug in the Grove LED to D4 on the Grove Pi+ board.

  2. Plug the Grove Rotary Angle Sensor into A0.

Get the code

  1. Open the GroveRotaryAngle example. You can find it in Examples > FROM LIBRARIES > UP SQUARED GROVE IOT DEV KIT > GroveRotaryAngle.

  2. Before you upload the example sketch to your board, make sure to open the Monitor in Arduino Create. This example outputs the raw analog data values out to the serial monitor.

  3. Upload the example sketch by clicking the Upload icon in the upper right of the editor. You should see the analog reading in the Monitor. You should also see the LED blink. If you turn the knob on the rotary angle sensor, you can change the rate of the blinking.

    If this isn't working:
  • Double check your connections. Grove LED to D4 and Grove Rotary Angle Sensor to A0.
  • Double-check that you have stopped any other running sketches on the My Devices page (https://create.arduino.cc/devices). Once there, if you see an "N Sketches Running" message, click Running and Stop any sketches.
  • If you’ve tried stopping your sketch, but it still doesn’t work, try restarting your UP² board.

How it works

You’ll notice that in the code, 512 corresponds to A0 on the Grove Pi+* board, while 516 corresponds to D4. The code doesn’t use 0 or 4 to because you’re required to add an offset of 512 to any pin on the Grove Pi+ board.

Why? Under the covers, MRAA (the hardware abstraction library in Arduino) is using the Grove Pi+ board as a sub-platform! So this line to add MRAA_GROVEPI as the sub-platform is required.

mraa_add_subplatform(MRAA_GROVEPI, "0");

Whenever you use a sub-platform in MRAA, you need to add an offset of 512 to whatever pin you are using. For example, if you’re setting the pin mode of a GPIO pin 4, normally your code would look like this:

pinMode(4, OUTPUT);

but with a sub-platform, your code would look like this:

pinMode(516, OUTPUT);

Digital pins and analog pins both start at zero. Therefore, Analog pin 0 (A0) corresponds to 512, and Digital pin 4 (D4) corresponds to 516.

If you’re still unclear how this works, go back to the Blink LED example and read this section about MRAA and sub-platforms.

The serial monitor is started in the setup() function.

DebugSerial.begin(115200);

Data can then be sent using:

DebugSerial.println(sensorValue);

For more detailed information on how to use the serial monitor, see the Serial Monitor tutorial.

Connect to the Amazon Web Services (AWS)* Cloud

What you'll learn

  • How to set up an AWS account and Thing
  • How to create a certificate for your Thing
  • How to enter the certificate in the SECRETS tab
  • How to verify the connection in AWS

Set up AWS portal

Go to AWS IOT console and register or sign in.

This example continues in GitHub: https://github.com/intel-iot-devkit/up-squared-grove-IoT-dev-kit-arduino-create/tree/master/examples/MqttPubAWS

MQTT with Microsoft Azure* in Arduino Create

What you'll learn

  • How to set up an IoT Hub
  • How to get the credentials for your device and enter them into the SECRETS tab
  • How to view your data using the Device Explorer

Create an account

If you don't have a Microsoft Azure* account, sign up for a free trial: https://azure.microsoft.com/en-us/free/

Create an IoT Hub

You need an IoT Hub to enable communication between Azure and your device. The easiest way to create an IoT Hub is through the Azure portal. Follow the steps in https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-create-through-portal.

The portal is located at https://portal.azure.com

This example is continued on GitHub*: https://github.com/intel-iot-devkit/up-squared-grove-IoT-dev-kit-arduino-create/tree/master/examples/MqttPubAzure

Running Linux* Processes

This tutorial walks you through running Linux* processes using the Process class. It gets the Arduino* ascii art logo from the network, and prints it over serial. It also gets and prints the CPU info.

What you'll learn

  • How to pass parameters to your processes
  • How to spawn processes using the Process class

This code sample continues on GitHub: https://github.com/intel-iot-devkit/up-squared-grove-IoT-dev-kit-arduino-create/tree/master/examples/Process

Serial Monitor

What you’ll learn

In this example, you’ll learn how to set up a serial monitor. You’ll use built-in functions to set up, transmit, and receive data over serial, which is very useful for debugging.

This code sample is also available on GitHub: https://github.com/intel-iot-devkit/up-squared-grove-IoT-dev-kit-arduino-create/tree/master/examples/SerialMonitor/DebugSerial

Also, another serial monitor example is provided as well: https://github.com/intel-iot-devkit/up-squared-grove-IoT-dev-kit-arduino-create/tree/master/examples/SerialMonitor/Serial

Gather your materials

You’ll need the following to complete this tutorial:

Set up your environment

This tutorial assumes you have already set up your board to work with Arduino Create*. If you haven’t done that, return to the Getting Started section.

The Monitor in Arduino Create can be used to receive or send messages to and from your board.

There are two methods you can use for serial communication, depending on how you are connected to your board. If you are connected to your board over the USB cable, use the Serial method. If you’re connected to your board via Cloud, then use the DebugSerial method. DebugSerial is just like Serial, so you can just replace Serial with DebugSerial in all instances.

Get the code

  1. Create a new sketch and enter the following code:
    int incomingByte = 0;   // for incoming serial data
    void setup() {
            DebugSerial.begin(115200);     // opens serial port, sets data rate to 115200 bps
    }
    void loop() {
            // send data only when you receive data:
            if (DebugSerial.available() > 0) {
                    // read the incoming byte:
                    incomingByte = DebugSerial.read();
                    // say what you got:
                    DebugSerial.print("I received: ");
                    DebugSerial.println(incomingByte, DEC);
            }
    }
  2. Before you upload the example sketch to your board, make sure to open the Monitor in Arduino Create.
  3. If you enter hello into the Monitor after uploading the sketch, you will see the following:

How it works

DebugSerial behaves like Serial https://www.arduino.cc/en/Reference/Serial. In general, here is how to use it:

  1. Initialize in the setup() method, using a baud of 115200:

    DebugSerial.begin(115200);

  2. To print messages from the board, use either:

    DebugSerial.println(“message”);

  3. Or:

    DebugSerial.print(“message);

  4. To listen to messages:

    DebugSerial.read()

System Calls

What you’ll learn

In this example you’ll learn how to make system calls from Arduino sketches.

System calls are helpful to run commands like you would from a command prompt. You can use system calls to run scripts, configure the system, copy files, etc. It is important to note that when running a command from an Arduino sketch, the command is run as the root user.

This code sample is also available on GitHub: https://github.com/intel-iot-devkit/up-squared-grove-IoT-dev-kit-arduino-create/tree/master/examples/SystemCalls

Gather your materials

You’ll need the following to complete this tutorial:

Get the code

  1. Create a new sketch and enter the following code:
    /* check the Monitor to see IP Address */  
    void setup() {
       system("ip a");
       system("whoami");
    }
      void loop() {
       printf("hello there");
       delay(5000);
    }
  2. Before you upload your example sketch to your board, make sure to open the Monitor in Arduino Create.
  3. After uploading your sketch, you should see the results of the ifconfig command in the Monitor. These results contain your board’s IP address, as shown below.

How it works

This example uses the built-in C++ system() library. Here are two places you can find more information on this library:

Alternatively, you can use Process, the built-in Arduino library, which can be found at: https://www.arduino.cc/en/Tutorial/Process.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Intel Corporation
United States United States
You may know us for our processors. But we do so much more. Intel invents at the boundaries of technology to make amazing experiences possible for business and society, and for every person on Earth.

Harnessing the capability of the cloud, the ubiquity of the Internet of Things, the latest advances in memory and programmable solutions, and the promise of always-on 5G connectivity, Intel is disrupting industries and solving global challenges. Leading on policy, diversity, inclusion, education and sustainability, we create value for our stockholders, customers and society.
Group type: Organisation

44 members


You may also be interested in...

Pro
Pro

Comments and Discussions

 
-- There are no messages in this forum --
Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web04-2016 | 2.8.180712.1 | Last Updated 10 Nov 2017
Article Copyright 2017 by Intel Corporation
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid