The best tools to make your project dreams come true

Login or Signup
USD


By ShawnHymel

Getting Started with Digi-Key IoT Studio

The Digi-Key IoT Studio is built on Atmosphere IoT, which is a graphical, web-based programming environment. It is designed to help you move data from embedded systems to your phone or to the Cloud as easily as possible. The Digi-Key IoT Studio contains a number of libraries to help you get started with a wide variety of embedded development boards and sensors.

This tutorial will guide you through the process of developing firmware for the ST SensorTile along with accompanying smartphone app and dashboard with Cloud storage. We will measure temperature with the SensorTile, send that information over to our smartphone via Bluetooth Low Energy (BLE), and then send it up to the Cloud storage in the IoT Studio (you get 10 MB for free per account).

If you would like to see this process in video format, please refer to the following:

 

Required Hardware

You will need the following parts to follow along with this guide: https://www.digikey.com/short/pf0cjn

Hardware Hookup

Do the following to prepare the SensorTile for programming:

  • Remove both jumpers from CN2 on the Nucleo board, which allows the ST-LINK portion of the Nucleo to program external targets.
  • Connect CN4 on the Nucleo to the SWD header on the SensorTile shield. Note the silkscreen dots that denote pin 1 on both headers. You can ignore pin 6 on the Nucleo side, as that’s the SWO pin, which is unconnected on the SensorTile.
  • Connect a USB mini cable to the Nucleo board to power the ST-LINK and upload new programs
  • Connect a USB micro cable to the SensorTile shield to power the SensorTile

The following diagram shows these connections:

Nucleo to SensorTile connections Fritzing

Part 1: The Firmware

The first part of the program we will create is the firmware that will run on the SensorTile. The firmware is in charge of sampling data from the temperature sensor and sending it to our phone over Bluetooth.

Navigate to https://www.digikey.com/en/iot-development-platform/ and sign in with your Digi-Key account. 

Once the studio loads, click on the Projects tab on the left side and click New Project. Search for SensorTile, and click Create

Create a new project in DigiKey IoT Studio

Click Info at the top right, and change the name of your project to something memorable. Click Close.

Configure project

In the Toolbox on the right side, click Interval to add it to the canvas. Click GPIOPin to add a GPIO element. You can click on the elements in the canvas to see their individual settings. We’ll leave the settings to their defaults for the moment. Hover over the right side of the Interval element, and drag a connector to GPIOPin.

Creating connections

This creates a trigger connection between the two elements. In this case, the Interval element will cause the GPIOPin to toggle PG12 every second. PG12 on the SensorTile is connected to the onboard LED, so the LED will flash, letting us know the program is working.

Note that if you would like to add an external sensor or part to the SensorTile, you can click Add Element at the bottom of the Toolbox. You should see a list of available elements that are supported in the Digi-Key IoT Studio. If you would like to create your own element, you will need to follow this guide (https://www.digikey.com/eewiki/pages/viewpage.action?pageId=85295477) to code your own .eel file.

From the Toolbox, click the LPS22HBPressure element to add it to the canvas. Click on the Interval element to bring up its settings. Find and click on the Add Event button. This will ask you to click on a destination element, so click on the LPS22HBPressure element. You should see a connection wire appear from Interval to LPS22HBPressure. Because we want to read temperature, you will need to change the Read Pressure ability under Triggers to Read Temperature.

Reading sensor data in DigiKey IoT Studio

Click anywhere on the blank canvas to bring up the Toolbox. Click on BLE GATT Characteristic to add it to the canvas. Click on its element in the canvas to bring up its settings. Change the name to something like BLE_Temp, and change the Read Data Type, Write Data Type, and Notify Data Type to Floating Point (32-bit). This will allow us to send the floating point values (instead of strings) over the Bluetooth connection.

Configure BLE settings

Click on the LPS22HBPressure element in the canvas to bring up its settings. Under Triggers, change the type from Pressure Read to Temperature Read. This will allow us to configure a trigger that fires whenever the temperature data is read. Next, click Add Event and click on the BLE_Temp element. This should create a connection between the sensor and the BLE elements.

Configure temperature reading in sensor

We are done with the firmware! We could download this to our SensorTile, but let’s develop the other applications first.

Part 2: Phone App

Click on the Application tab at the top of the canvas. Add an Interval element to the canvas and connect it to the BLE_Temp element that should already be on the canvas. 

Create phone app in DigiKey IoT Studio

Add a Label element to the canvas and change its name to TemperatureLabel. Change the visible Text to Temperature, and center it in the middle of the view on the left side app editor.

Add labels to phone app

Add another Label element and change its name to TempValue. Delete the Text field, as we will fill that out dynamically from the BLE_Temp element. Center the view element and move it below the Temperature text on the app viewer on the left. Make a connection between the BLE_Temp and TempValue elements.

Change label data

Since we want to send this data to the Internet to be stored on a server, we’ll need to add a CloudEvent element. Connect the BLE_Temp element to the CloudEvent element. We don’t want to view the long floating point value (with a dozen decimal places), so click on the BLE_Temp element and add the following code snippet to the TempValue trigger in settings:

parseFloat(readData).toFixed(2)

This will convert the string received from the BLE characteristic to a floating point value and then back to a string rounded to 2 decimal places. Your app should now look like the following:

Convert floating point format

Save your work by clicking the Save button at the top of the screen, and let’s continue to the cloud side.

Part 3: Cloud App

We can create backend code that runs on Digi-Key’s servers. This allows us to parse and interpret data that we might receive from our devices. Note that in our case, we need the phone app to receive the BLE-only data from the SensorTile and send it to the Internet. If you are using another board that has a WiFi or Ethernet connection (e.g. an ESP32-based development board), then you would not need to pass data through your smartphone.

In the Cloud tab, you should see the CloudEvent element already in the canvas. This acts as the other end of the pip from the CloudEvent element we added in the phone app. Add a CloudStorage element and give it a memorable name, like TemperatureStorage (we will need this name when making our dashboard). Connect the CloudEvent to the CloudStorage.

Saving data in the Cloud

Save your work.

Part 4: Program and Run

Click the Compile button at the top of the screen to compile your programs. Once that’s done, head back to the firmware tab and click the Program Firmware button. For some microcontrollers, the IoT Studio is capable of programming them directly. For our SensorTile, we will rely on copying a .bin file to the Nucleo board, which will then program the SensorTile.

Download bin file

Open a file explorer on your computer and find the downloaded project (likely named something like Atmosphere_Project.bin). Copy it to the drive associated with your Nucleo board.

Copy bin file to Nucleo drive

Once the program has been uploaded, make sure that the SensorTile is toggling its LED once per second. Install the Digi-Key IoT Studio app on your phone (App Store or Google Play).  Open it and sign in to your account. Click on the devices tab and click Add New Device at the top-right of the screen. Make sure you have Bluetooth enabled on your phone.

You should see your SensorTile project appear, so click it, and let your phone provision the Bluetooth connection (it might take a few minutes). You should see the view we created appear with the temperature (in Celsius) being reported. If you do not see the numerical value, back out of the page and click the View Page icon to refresh the page.

Viewing temperature data on IoT Studio phone app

Note that while we are viewing the sensor data in real time, it is also being sent up to our cloud storage.

Part 5: Dashboards

The IoT Studio lets us create several different dashboards. We can make 1 overall dashboard that allows us to view data from many different devices, and we can also make a dashboard for each individual device. To start, click on the Dashboard tab on the left side. Click on the gear icon to view widgets, and add a Gauge Widget

Give it a name, like Temperature Gauge. At the bottom, under Data Source, click Select.

Creating a dashboard in DigiKey IoT Studio

Click on your SensorTile project and click on TemperatureStorage. Data from the app is being sent to the storage bin and tagged with this name. For the Value, click on value (Number) to display the temperature data.

Creating a gauge widget

You should see a gauge widget appear on your dashboard. If your app and SensorTile are running, the gauge should be updated with the most recent temperature reading (in Celsius).

Gauge widget

Add a Data Graph widget, give it a new name, add a data source, and select your project. Select TemperatureStorage for the data source. For X-Axis Value, click on Server Timestamp (Date), and for Y-Axis Value, select value (Number). Confirm your settings.

Temperature graph

Save the widget settings, and you should see a graph appear next to the gauge. Try breathing on or touching the SensorTile to increase the temperature. You should see the gauge and graph change to reflect the temperature. Note that the SensorTile itself seems to run a little warm, so the ambient temperature reading might not be the most accurate.

Temperature graph widget

If you go to the Devices tab, you can click on your SensorTile project and set up a separate dashboard unique to that device. Here is an example of a Temperature Gauge added to the My SensorTile Temperature project dashboard:

Separate gauge widget in device dashboard

Click on Storage to get an overview of the devices using your Cloud storage and how much space you have remaining.

DigiKey IoT Studio storage overview

Resources and Going Further

Hopefully, this guide has helped you see how the Digi-Key IoT Studio can make your development time for IoT devices much easier and shorter. If you need to quickly get data from an embedded device to your phone or Cloud, the IoT Studio is a great starting place.

If you would like to dive deeper into the IoT Studio, these resources can help.

Key Parts and Components

Add all Digi-Key Parts to Cart
  • AE9929-ND
  • 497-15881-ND
  • 497-16719-ND
  • AE10419-ND