Digi-Key IoT Studio Web and Mobile Applications have been discontinued by Digi-Key. The links and instructions in this guide may be outdated or invalid. For support and more information about the future of the Digi-Key IoT Studio application, please visit https://forum.digikey.com/t/dk-iot-studio-has-migrated/8463

Now that you can turn on the lights inside your home - you may be asking what else can you do? One popular feature people add to their smart-homes is environmental monitoring. Tracking your home's environmental data is useful for both short-term alerts (if the temperature in a room is too low, or the concentration of gas is too high) and long-term logging (logging data over a long period of time can help us detect abnormalities within the data).

You're going to use the Embedded Workspace to build firmware for obtaining precision temperature readings from inside your home using the Analog Devices FeatherWing. Then, you'll add the Bosch BME680 to obtain readings for the relative humidity and the gas level.

Then, you'll use the Application Workspace to enhance your mobile application by adding labels to display readings from the sensors inside your home. 

Finally, you'll switch to the Cloud Workspace to send data from your DK IoT App to DK IoT Studio's Cloud Storage.

Step-by-Step: Embedded Workspace

You'll begin by adding an interval element to your project. Digi-Key IoT uses interval elements to trigger connected elements. You can specify an interval in milliseconds. When the timer expires, it will trigger all elements connected to it.

  • From the element toolbox within IoT Studio's Embedded workspace, click the Interval element.
  • Move the Interval Element underneath the BLECharacteristic Element.

Elements for the BME680 or the Sensor FeatherWing are not within the default element toolbox - you'll have to manually add them from within the Element Library.

  • From the element toolbox within IoT Studio's Embedded workspace, click Add Element 
  • From the Element Library, search for the BME680.
  • Enable the BME680 library elements by clicking the toggle button.
  • From the bottom of the Element Library, click Save

You will also need to import the ADT7410 sensor library.

  • From the element library, search for the ADT7410FEATHERWING.
  • Enable the ADT7410FEATHERWING library.
  • From the bottom of the Element Library, click Save

The ADT7410 and BME680 sensors should now appear in your Element Toolbox under Imported. Let's add the ADT7410 temperature sensor to the workspace.

  • From the element toolbox within IoT Studio's Embedded workspace, click the ADT7410 Temperature Element to add it to the Workspace.
  • Move the ADT7410 element underneath the GPIO element.

Make a new connection between the Interval Element and the ADT7410 Element.

Every time the interval executes, the interval will trigger the ADT7410FeatherWing element to read the sensor's temperature in degrees Celsius.

Let's create a new BLE GATT Characteristic to read the temperature sensor's value.

  • From the element toolbox within IoT Studio's Embedded workspace, click the BLE GATT Characteristic Element to add it to the Workspace.
  • Click the BLECharacteristicCustom Element on the Embedded workspace to bring up its properties.
  • Change the element's name to BLECharacteristicTemp

Let's add a new event to write data to the BLE Characteristic each time the temperature is is read.

  • Click the ADT7410FeatherWing Element
  • Click Add Event
  • Add a connector between the ADT7410FeatherWing Element and the BLECharacteristicTemp Element.

The debug print element. This element will print the sensor value to the Huzzah debug UART console (on your computer). This is useful for checking if the sensors are operating correctly, independently of the BLE connection.

  • From the element toolbox within IoT Studio's Embedded workspace, click the Debug Print Element to add it to the Workspace.
  • From the Debug Print Element's properties, name the element DebugPrintTemp.

You can add a label to differentiate which value is being printed to the console:

  • Under Prepend Text, add the text Temperature (*C): 
    • The temperature reading in the UART terminal will look something like: Temperature (*C): 25.23

Make a new connection between the ADT7410FeatherWing element and the DebugPrintTemp Element.

To summarize - every time the interval's timer expires, the ADT7410 will read the temperature. Once the temperature is read from the sensor, it'll be sent to the BLECharacteristicTemp element and printed to the UART console. 

Next, re-do these steps, but for the BME680 sensor. 

  • From the element toolbox within IoT Studio's Embedded workspace, click the BME680 Element to add it to the Workspace.
  • Click the BME680 element to bring up the properties.
  • Change the I2C Address to 0x77
  • Change the trigger to Humidity Read
  • Add a connector from the Interval Element to the BME680 Element.
  • In the Interval Element's Properties, change the BME680's ability to Read Humidity (%RH)

Let's add some elements to receive and print the data from the sensor.

  • From the element toolbox within the IoT Studio Embedded workspace, click the BLE GATT Characteristic Element to add it to the Workspace.
  • Change the name of this element to BLECharacteristicHumid
  • From the element toolbox within IoT Studio's Embedded workspace, click the Debug Print Element to add it to the Workspace.
  • Change the name of this element to DebugPrintHumid
  • Modify the Prepend Text to Humidity (%RH)
  • Click the BME680 element to bring up its properties.
  • Under the Humidity Read trigger, click Add Event
  • Add a connector between the BME680 element and the BLE Characteristic Element
  • Add a connector between the BME680 Element and the Debug Print Element.

Next, let's read data from the BME680's gas sensor. This sensor will read its resistance in ohms.

  • From the element toolbox within IoT Studio's Embedded workspace, click the Interval Element to bring up its properties.
  • From the Interval Properties, click Add Event
  • Add a connector between the Interval Element and the BME680 Element.
  • Change the ability of the connector to Read Gas Resistance (Ohm)

Click the BME680 Element in the Embedded Workspace to bring up its properties.

Change the Trigger from Humidity Read to Gas Resistance Read.

You'll notice that there are no events defined for this trigger, but there are connectors from the BME to other elements. Those connectors are specific to the Read Humidity trigger. You'll be adding similar events for the Gas Resistance Read trigger.

Let's add some elements to receive and print the data from the sensor.

  • From the element toolbox within IoT Studio's Embedded workspace, click the BLE GATT Characteristic Element to add it to the Workspace.
  • Change the name of this element to BLECharacteristicGas
  • From the element toolbox within IoT Studio's Embedded workspace, click the Debug Print Element to add it to the Workspace.
  • Change the name of this element to DebugPrintGas
  • Modify the Prepend Text to Gas (ohms): 

Once the Elements are configured, make a connection between the BME680 Element and both elements.

Make sure your embedded workspace looks like the following before moving on.

Step-by-Step: Application Workspace

The Mobile Application allows you visually display the sensor values. You'll add label elements to the interface to display the values read from the sensors. 

Navigate to the Application Tab. The BLE Characteristics you created in the embedded tab may be cluttered. Move them around to organize your workspace.

With an organized workspace, you're ready to start programming the application's logic.

  • From the Element Toolbox, add an Interval Element.
  • Click the Interval Element in the Application Workspace.
  • From the Interval Element's Properties, click Add Event.
  • Connect the Interval Element to the BLECharacteristicTemp Element
  • Connect the Interval Element to the BLECharacteristicHumid and BLECharacteristicGas elements.

 

You'll want to add labels to display the values read by the BLE Characteristic Elements.

  • From the Element Toolbox, click the Label button three times to add three Label elements.
  • Rename the first label element to LabelTemp
  • Rename the second label element to LabelHumid
  • Rename the third label element to LabelGas

Let's add a connector between the BLE Characteristic Element and the Label Element. This will set the label's text to the value of data read by the BLE Characteristic.

  • Click the BLECharacteristicTemp element to bring up its properties.
  • Click Add Event
  • Add a connector between BLECharacteristicTemp and LabelTemp.

Next, you'll format the temperature to display on the label with its value and respective unit. The label's text can be formatted using Javascript.

  • Click the connector between the BLECharacteristic Element and the Label element to bring up its properties.
  • Under abilities, change the text to readData+"°C"
  • Add a connector between BLECharacteristicHumid and LabelHumid
  • Click the connector between BLECharacteristicHumid and LabelHumid to bring up the connector's properties.
  • Under abilities, change the text to readData+"%RH"

Finally, you'll set up the connection between the gas sensor reading and its label on the mobile application.

  • Make a connection between BLECharacteristicGas and LabelGas
  • Click the connector between BLECharacteristicGas and LabelGas to bring up the connector's properties.
  • Under abilities, change the text to readData/100+"Kohms"

Let's take a short break from configuring our application's logic and configure the application's design.

Click and drag LabelTemp underneath the thermometer icon.

  • Bring the humidity label to the front and move it underneath the % symbol icon
  • Bring the gas label to the front and move it underneath the gauge icon

Let's add some placeholder text to our interface and center the labels to format our text

  • Click LabelTemp to bring up the element's properties
  • Change the label's text to 25°C
  • Change the label's alignment to Center

Repeat this for the humidity and gas labels.

While data is will display on the application, this data is not stored. To store this data, you'll need to add Cloud elements to our Application Workspace. These elements will create mirrored elements in the Cloud Workspace.

  • From the Element Toolbox, click Cloud Event
  • Rename the Cloud Event to CloudEventTemp
  • Click BLECharacteristicTemp to bring up its properties.
  • Click Add Event.
  • Add a connector between BLECharacteristicTemp and CloudEvent
  • Create a new element named CloudEventHumid and connect it to BLECharacteristicHumidity 
  • Create a new Cloud Event element
  • Name the element CloudEventGas
  • Add a connector between BLECharacteristicGas and CloudEventGas
  • Click the gear element on the connector.
  • Change the value to readData/1000

You've programmed your mobile application to read values from BLE Characteristics and designed and interface to display these formatted values. Make sure your interface looks similar to the following screenshot before moving on.

Step-by-Step: Cloud Workspace

The Cloud tab is a workspace in DK IoT Studio for enabling an IoT project's connectivity over WiFi with cloud services (Digi-Key IoT Cloud or Amazon Web Services).

  • Click the Cloud Tab underneath your project's name to be brought to the Cloud Workspace.
  • Your cloud workspace should contain the three cloud events you created in the application workspace: CloudEventTemp, CloudEventHumid, CloudEventGas.

You may want to organize the elements in the Cloud Workspace.

You'll need somewhere to send this data. Luckily, Digi-Key IoT offers up to 10 megabytes of cloud storage per device. To add data to this cloud storage, use the Cloud Storage Element.

  • From the Cloud Element Toolbox, click the cloud storage element to add it to your Cloud Workspace.
  • On the Cloud Workspace, click CloudEventTemp. Then, click Add Event.
  • Make a connector between the CloudEventTemp and CloudStorage elements

While you could send raw data to the cloud storage element, it would be hard to discern which data is the temperature data and which is the gas data. To help identify which value is being sent to the cloud storage, you'll associate each value with some metadata (information about the data). 

 

Click the connector between the cloud event and the cloud storage.

Under the Add Data ability, change the value to {temperature:value}

Repeat the steps above to add connectors and labels for the humidity and gas values.

Code Usage

Compile the project. Then, upload the project to the Feather HUZZAH32.

  • Open the DK IoT Studio Mobile App on your device.
  • Tap the Devices tab on the sidebar
  • Add a new device to the devices page by tapping the + icon
  • Your IoT Home should appear as a device in range. Tap the IoT Home Project.
  • On the Configure WiFi Settings screen, tap CANCEL

The Application's interface should load and populate with values from the sensors.

Try breathing directly on the Sensor FeatherWing's ADT7410 sensor to increase its temperature or humidity. You should observe the values on the application view change.

This guide was first published on Dec 11, 2019. It was last updated on Mar 08, 2024.

This page (Monitoring your Home) was last updated on Mar 08, 2024.

Text editor powered by tinymce.