Getting Started with NUCLEO-L476RG

This guide teaches you how to get started using the NUCLEO-L476RG with Atmosphere. This includes creating your first project, programming the project’s firmware into the NUCLEO-L476RG, registering the device to Atmosphere, and having its data displayed on a dashboard.

In the guide you’ll build a simple project that reads temperature data once a second, displays that data on the mobile app, and then sends the readings to the cloud.

Prerequisite: You should already have an Atmosphere account.

If you'd like to see the complete demo before attempting this guide, it's available in Atmosphere Studio's Demo Projects section as the NUCLEO-L476RG Temperature Demo. Simply open the project to check it out and get started.

Hardware Requirements

The NUCLEO-L476RG doesn’t have built-in connectivity, so connecting the STMicroelectronics X-NUCLEO-IDB05A1 Bluetooth Low Energy shield to it enables it for BLE and allows it to connect to Atmosphere. The BLE shield contains the SPBTLE-RF BlueNRG-MS RF module, which is supported in Atmosphere through a dedicated BlueNRG element, located within Atmosphere Studio’s Element Library.

Likewise, the NUCLEO-L476RG doesn’t include any onboard sensors, so we’re pairing it with the STMicroelectronics X-NUCLEO-IKS01A3 motion and environmental sensor shield to read sensor data from it. Each of this shield’s sensors contains a dedicated element for it as well, which are also located within the Studio Element Library.

Software Requirements

  • Atmosphere IoT app. The mobile app is used here to register your device, and display and run the project’s interface. You can download the Atmosphere IoT app from its downloads page or through the Apple App Store or Google Play Store.
  • Ensure Bluetooth is enabled on the mobile device you’ll use to interact with the NUCLEO-L476RG.

Step 1 of 9: Create a New Project

Navigate to Atmosphere Studio from the side menu. When you visit Studio for the first time in a session, you are brought to the Studio Projects screen.

  1. Click the New Project button. This displays a New Project window.
  2. Select the NUCLEO-L476RG project type and give the project a name, then click Create.

This opens a new project in Studio.

This guide walks through the step-by-step process to perform actions in Studio, but doesn't cover the in-depth aspects of Studio itself. To learn more about using Studio, its areas and features, and Studio elements, visit the Atmosphere Studio section.

Step 2 of 9: Import Elements from the Element Library

Prior to building the project, the proper elements have to be added into Studio’s Element Toolbox. The project involves integrating the BlueNRG element and the STTS751 temperature sensor from the sensor shield, neither of which are native to NUCLEO-L476RG projects. So we’ll add them through the Studio Embedded tab’s Element Library.

  1. From the Embedded tab, click the New Project Add Element button located in the bottom of the Element Toolbox. This opens the Element Library, which includes numerous elements for sensors and other devices that can be incorporated into a project. Nucleo Guide Element Library
  2. In the Element Library, locate the BlueNRG element in the table and turn on its enable switch by clicking it to import it into the Element Toolbox.
  3. Next, locate the X-NUCLEO-IKS01A3 sensor shield element(s), specifically the STTS751 temperature sensor and enable it. If you’d like to add the other sensors from the shield, you could do so as well. When done click Save, and the elements are added into the Embedded tab’s toolbox.

Step 3 of 9: Create the Project’s Embedded Firmware

The first aspect of building this sample project is adding elements to the Embedded tab to create the project’s embedded firmware. This involves setting an interval to read embedded data, and to tell the interval to read the sensor shield’s temperature sensor.

  1. Add the following elements to the canvas by clicking them in the Element Toolbox:
    • Interval Element Interval element: The interval element sets the project to run at the time set in the element’s properties, which by default is set to once per second (1000 ms).
    • BlueNRG Element BlueNRG element: The BlueNRG element enables the project with BLE connectivity. As a standalone protocol element, it doesn’t need to be connected to any other element; if it’s included in the project it will work properly so long as the BLE shield is connected to the NUCLEO-L476RG.

      When the BlueNRG element is added to the canvas, notice that Bluetooth Low Energy elements (BLE GATT characteristic and BLE connection) are then included into the toolbox. By adding a connectivity aspect to the project -- since the NUCLEO-L476RG doesn't natively contain a connection option -- these elements are now accessible for use.

    • STTS751 Element STTS751 element: The STTS751 element reads the temperature sensor data from the X-NUCLEO-IKS01A3 sensor shield.

    Each of these elements will work as intended by default, so none of their properties need to be changed.

  2. Connect the interval element to the STTS751 element. This creates an event between them, which can be seen in either the interval element’s properties, or by clicking the connector’s Configuration Button button. The event added is within the Interval trigger. In the STTS751 element’s ability field within the event, set the ability to Read Temperature (°C). This means that when the interval element is triggered (which is every second), it will read the temperature value.
  3. Add a BLE Characteristic Element BLE characteristic element to the canvas, which creates a GATT characteristic to use in your project. This element is a coupled element that bridges the project between the Embedded tab and Application tab, meaning it’s included on both tabs. Select the BLE characteristic element, and within its properties change the Read Data Type and Write Data Type fields to Floating Point (32-bit). This allows the element to read and write a floating point value, which is the temperature value that will eventually be sent through it.
  4. Connect the STTS751 element to the BLE characteristic element, which ties the value of the temperature sensor to the Application tab. This creates an event between the two elements in the Temperature Read trigger, with the ability Set Value. This sets a value for the project’s interface after it reads the raw temperature sensor data.

That wraps up the first aspect of the project within the Embedded tab. To this point, an interval has been set that will run once per second after the project opens, and when run will read the temperature data from the sensor shield’s temperature sensor. That data will then be sent from the BLE characteristic to the mobile app via the Application tab.

The Embedded tab canvas should resemble the following image:

Nucleo Guide Embedded Tab

Step 4 of 9: Create the Project’s Interface

The second aspect of building this sample project is adding elements to the Application tab to create the project’s visual component.

Click the Application tab to move to the application area of the project. Notice how the Element Toolbox has changed, and that the coupled BLE characteristic element is displayed on the canvas.

  1. Click the App Builder button in the Application tab’s toolbar to display the app builder. This area creates the visual interface for your project. By default this uses the smallest display size supported for an interface (320x560), but you can add an interface size by clicking the add display button. Use the display size that fits best with your mobile device.
  2. Add an Interval Element interval element to the canvas, and connect it to the existing BLE characteristic element. This creates the trigger event Read, which reads the value of the BLE characteristic element sent from the Embedded tab every time the interval triggers.
  3. Add a Label Element label element to the canvas. The label element displays text on a project’s interface. Notice when the label is added to the canvas, a corresponding interface component is added to the app builder. The label component can be moved around on the interface wherever you like.
  4. Connect the BLE characteristic element to the label element. This creates an event between the two elements of Set Text under the Read trigger, which sets the text to the value of the label when the BLE characteristic is read. This correlates the set value from the BLE characteristic element in the Embedded tab to the label on the interface. Within the Set Text event, modify the Text field to "Temperature: " + readData.toFixed(2) + "°C". This argument reads the temperature data and truncates the value to two decimal places, and also appends the Celsius unit to the end of the value.

This is all that needs to be done for the project’s interface, simply using a label to display a text value. To this point, an interval has been set that will read the BLE characteristic value once per second, which will display the read the temperature value on the interface label.

The Application tab’s canvas should resemble the following image:

Nucleo Guide Application Canvas

Step 5 of 9: Enable the Project’s Cloud Connectivity

The last aspect of building this sample project is enabling it for cloud connectivity. This is done on both the Application and Cloud tabs.

  1. While still in the Application tab, add a Cloud Event Element cloud event element to the canvas. The cloud event element is a coupled element between the Application and Cloud tabs that enables a project’s data to be sent to Atmosphere.
  2. Connect the BLE characteristic element to the cloud event element. This adds the Send Event event to the Read trigger, which sends the set value data to Atmosphere when the BLE characteristic is read.
  3. Click the Cloud tab to move to the cloud area of the project. Notice how the Element Toolbox has changed, and that the coupled cloud event element is displayed on the canvas.
  4. Add a Cloud Storage Element cloud storage element to the canvas, and connect the existing cloud event element to it. By default, this creates an event using the Add Data ability within the cloud event’s Event Received trigger, which allows Atmosphere to add (and store) data sent to it from the connected cloud event element.

That’s all for creating the project! With the added cloud connectivity, the project will send the temperature value from the Embedded tab to the Application tab, which then uses a cloud event to send it to the Cloud tab, where it’s connected to a cloud storage element to store the data on Atmosphere.

The final canvas for each tab should resemble the following images:

Embedded Application Cloud
Nucleo Guide Embedded Tab Nucleo Guide Application Tab Nucleo Guide Cloud Tab

Step 6 of 9: Compile the Project

Once the project is finished, it needs to be compiled. Compiling readies the entire project’s source code for deployment.

  1. From any tab, click the Compile button in the project options menu on the top-right of the screen. You’ll see a loading message on the screen indicating compiling has started, and will receive a notification when the project is compiled.

Step 7 of 9: Program Firmware into the Device

With the project compiled, your NUCLEO-L476RG can be programmed with the project’s embedded firmware.

Prior to programming a device, ensure you have the following configuration:

  • The jumpers on CN2 should populated, connecting the ST-Link to the rest of the Nucleo board.

With the initial setup finished, complete the remaining setup configuration steps:

  • The NUCLEO-L476RG is plugged into your computer.
  • The project to be programmed has been compiled.

With setup complete, you can program your board:

  1. While the Embedded tab is active, click the Program Firmware button from the tab’s toolbar. This will download the .bin file.
  2. Locate the downloaded file on your computer, and move it into the NUCLEO-L476RG’s mounted drive.
  3. After around five seconds of programming, the board will remount itself and your project will begin running on the NUCLEO-L476RG.

If your NUCLEO-L476RG is not appearing as a mounted drive on your computer, it's possible you need to install the proper drivers from STMicroelectronics in order for the board to mount. See NUCLEO-L476RG Hardware Specifics for information on accessing and installing these drivers.

Step 8 of 9: Register the Device

With firmware installed, the device can now be recognized and connected to Atmosphere. From here, open the Atmosphere IoT app on your mobile device. We’ll use the mobile app to both register the device, and eventually view the label data on the project’s interface.

To register the NUCLEO-L476RG:

  1. Navigate to the Devices area, and click the Register Device button in the top-right of the screen to display the Add Device window. When the window opens it automatically starts scanning for available devices within range.
    • Ensure your NUCLEO-L476RG is within range from the device you are attempting to register from, otherwise it may not appear.
  2. The list of available devices appears. Select your device you just programmed and click Register.

The device is now registered to Atmosphere and added to the Devices area. The app interface you created is displayed on the screen, with device data immediately shown on it.

Step 9 of 9: View Device Data

Now that the device’s data is sent to Atmosphere, let’s view it through one of the many device dashboard widgets available. In this guide we’ll use a data glance widget to display temperature data.

We’ll do this directly on the device’s console page, so click on the newly-added NUCLEO-L476RG to enter its console.

  1. To add a widget to the device’s dashboard, click the Configuration button on the right side of the screen. This displays the menu of available widgets. Select the Data Glance data glance widget to add a data glance to the dashboard.
  2. Once on the dashboard, click the widget’s Menu menu icon to display its menu, then click Settings.
  3. In the data glance’s settings, modify the following properties:
    • Name: Give the widget a name, such as “Nucleo Temperature Data”
    • Units: Enter °C for its unit of measurement.
    • Icon: Select an icon that represents the data, such as the Temperature icon.
    • Color: Give the widget a color that represents the data.
  4. In the Data Source field, click Select, then choose the following configuration options for the widget:
    • Select Cloud Storage: Click the cloud storage (TempStorage, or whatever you named your cloud storage) that is storing the STTS751 element’s data.
    • Select Value: Select the temperature dataset (TempEvent, or whatever you named your cloud event).
  5. When finished click Save. The data glance is then populated with the temperature value, which updates every ten seconds.

NUCLEO-L476RG Demo Dashboard

Congratulations, you just finished a complete NUCLEO-L476RG project with Atmosphere!