Creating a Monitoring Solution

This guide demonstrates how to set up an Atmosphere project that measures device data and initiates a device status change if the data value reaches a certain condition. The project created in this guide is a useful starting point in understanding how to easily develop a monitoring application in Atmosphere, while also serving as an exercise in using several cloud elements together to form a cohesive solution.

In the guide you’ll build an application that reads ambient light data from a development board’s light sensor, and when the light value exceeds a set limit, changes the device’s status in the cloud and Atmosphere sends a notification informing you the limit has been exceeded.

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 AVR-IoT Light Monitor Demo. This demo comes with the complete project intact, and also automatically includes a configured dashboard widget once the device is registered. Simply open the project to check it out and get started.

Hardware Requirements

For the purposes of this guide we choose the AVR-IoT WG as our end device of choice, but any Atmosphere-supported hardware could be used to build this type of project. Likewise we’ve selected the ambient light sensor on the board due to its ease of use with demonstrating value changes, but you can substitute this with a sensor of your choice.

Software Requirements

  • Atmosphere IoT Agent. The Atmosphere IoT Agent is a local application that runs in the system tray and acts as an intermediary between the computer’s connectivity protocol drivers and the browser running Atmosphere, and is used here to assist in programming the device and connecting it to Atmosphere. While the agent is running, a device with Atmosphere firmware installed on it can be registered to Atmosphere directly without the assistance from an additional connection like BLE or Wi-Fi if it’s connected to your computer. You can download the Atmosphere IoT Agent from its downloads page.

The project in this guide doesn’t use Studio’s Application tab to build an app interface and since the AVR-IoT will be registered to Atmosphere directly via a UART connection with your computer, the Atmosphere IoT app is not required here. However if you’ve elected to use a development board other than the AVR-IoT, note you may require the app and have different programming instructions than what is detailed below.

Step 1 of 8: 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 AVR-IoT WG 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 8: Create the Project’s Embedded Firmware and Cloud Connectivity

The first aspect of building this project is adding elements to the Embedded tab to create the project’s embedded firmware and enable its ability to send data to the cloud. This involves setting an interval to read embedded data, and to tell the interval to read the board’s ambient light sensor. The light sensor data will then be sent to a cloud event element, which sends the data to Atmosphere.

  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).
    • Vishay TEMT6000 Element TEMT6000 element: The TEMT6000 element reads ambient light data. This is an ambient light sensor that is onboard the AVR-IoT WG, and its element is imported in the Element Toolbox for AVR-IoT WG projects by default.

      Both the interval and TEMT6000 elements will work as intended by default, so none of their properties need to be changed.
  2. Connect the interval element to the TEMT6000 element. This adds 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, with the TEMT6000 ability Read Ambient Light. This means that when the interval element is triggered (which is every second), it will read the sensor’s ambient light data.
  3. Add a Cloud Event Element cloud event element to the canvas. The cloud event element is a coupled element between the Embedded and Cloud tabs that enables a project’s data to be sent to Atmosphere.
  4. Connect the TEMT6000 element to the cloud event element. This adds an event under the TEMT6000 element’s Ambient Light Read trigger with the Send Event ability, which sends the ambient light data to Atmosphere when the light level is read every half a second.
  5. 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 elements are displayed on the canvas. Then add a Cloud Storage Element cloud storage element to the canvas, and connect the cloud event element to it. By default, this adds an event within the cloud event’s Event Received trigger using the Add Data ability. This allows Atmosphere to add (and store) data sent to it from the connected cloud event element.
  6. Within the Add Data event, modify the event’s Value field to "{"Light Data": value}, which will label the ambient light dataset when displayed in the cloud.

That’s all for work in the Embedded tab. To this point, an interval has been set that will run every second, and when run will read the ambient light data from the AVR-IoT WG’s onboard TEMT6000 sensor. The light data will then be sent via the cloud event element to Atmosphere, where it’s connected to a cloud storage element to store the data.

The Embedded and Cloud canvases should resemble the following images:

Embedded Cloud
Monitor Guide Embedded Tab Monitor Guide Cloud Tab

Step 3 of 8: Enable the Device’s Status Abilities

The next aspect of building this project is enabling it to have its status changed, while also adding in the ability to receive a system notification when the status changes. This is done using a condition element to check a value and determine an outcome, alongside the cloud meta, cloud notification, and cloud register elements.

  1. Add the following elements to the canvas:
    • Condition Element Condition element: The condition element evaluates boolean operations sent to it.
    • Cloud Meta Element Cloud meta element: cloud meta element changes the meta information of a device on Atmosphere, such as a device’s status.
    • Cloud Notification Element Cloud notification element: The cloud notification element sends you system notifications.
    • Cloud Register Element Cloud register element: The cloud register element triggers events upon a device’s registration or removal on Atmosphere.
  2. Connect the cloud event element to the condition element. By default, this adds an event within the cloud event’s Event Received trigger using the condition element’s Check ability. This evaluates the data being sent to the condition element. Within the Check event in the connector between the elements, modify the event’s Value field to value > 200, which will check whenever the value sent to it from the cloud event is greater than 200.
  3. Connect the cloud register element to the cloud meta element. Within the connector between the two elements, add an event within the cloud register’s Registered trigger using the cloud meta’s Set Status to Good ability. Normally when a device is registered to Atmosphere, it doesn’t receive a status so it arrives with a default state of “none.” Using the cloud register element alongside the cloud meta element, the status will be set to “good” when the AVR-IoT is registered.
  4. Connect the condition element to the cloud meta element. Within the connector between the two elements, add an event within the condition’s Condition True trigger using the cloud meta’s Set Status to Critical ability. This will set the device’s status to “critical” whenever the condition – the light value being greater than 200 – is evaluated and true.
  5. Still within the connector between the condition and cloud meta elements, select the Condition False trigger. Add an event within the trigger, this time using the Set Status to Good ability. This will set the device’s status to “good” whenever the condition is evaluated and is false, or whenever the light value remains below 200. 200 lux is a good value for demonstrating this capability, as common environments regularly measure around 80-120 lux. This allows the condition to remain false until the sensor records a much brighter reading (which we’ll be prompting later on in the guide).
  6. Last, connect the condition element to the cloud notification element. Within the connector between the two elements, create an event within the condition’s Condition True trigger using the cloud notification’s Send ability. Then modify the event’s Message field to "Light value exceeded the set limit". Now whenever the condition is true, Atmosphere will send you a system notification with that message. The condition element should have the following events included within its triggers:
Condition True Condition False
Monitor Guide Condition True Monitor Guide Condition False

That’s all for creating the project! With the added cloud element capabilities, the project will set the AVR-IoT’s status to “good” once it’s registered to Atmosphere, and when connected will start measuring light data from its onboard sensor once per second. If the light reading remains under 200, the status remains the same, and if it exceeds 200 the status is changed to “critical” and a notification message is sent.

The final Cloud tab canvas should resemble the following image:

Monitor Guide Cloud Tab

Step 4 of 8: 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 5 of 8: Program Firmware into the Device

With the project compiled, your AVR-IoT WG can be programmed with the project’s embedded firmware.

Prior to programming, ensure the device is connected to the computer via USB. It should display as a mass storage device. Then you can program your board:

  1. From the Embedded tab, click the Program Firmware button from the tab’s toolbar. This downloads a .hex file containing the project’s compiled firmware.
  2. Locate the downloaded file on your computer, and move it into the AVR-IoT WG device. This initiates programming of the AVR-IoT WG, which is represented by a series of blinking LEDs and then it will reboot.

The blue LED will then turn on, followed by the yellow LED. This indicates the device is programmed, and can now be connected to Atmosphere.

Step 6 of 8: Register the Device

With firmware installed, the device can now be recognized and connected to Atmosphere. Prior to connecting a device, ensure your Atmosphere IoT Agent is running in your system tray. This is needed to check your computer’s communication ports for a device it recognizes, which will find the AVR-IoT WG.

To register the AVR-IoT WG:

  1. Navigate to the Devices area, and click the Register Device Add 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.
  2. The list of available devices appears. Select the AVR-IoT WG you just programmed and click Register. This brings you to the Wi-Fi settings screen.
    • If the device doesn’t show up, try restarting the agent in your system tray. If you do so, refresh your browser and try adding a device again.
  3. Configure your Wi-Fi network settings to connect the device. When Wi-Fi settings are entered, the AVR-IoT WG will connect to Atmosphere over Wi-Fi and remain connected as long as the Wi-Fi connection is maintained.

The device is now registered to Atmosphere and is displayed on the page. Unlike a typical device registered to Atmosphere, the device displays with a status thanks to the cloud register element.

Monitor Guide Device Good

Step 7 of 8: View Device Data

Now that the device’s data is sent to Atmosphere, let’s view it through one of the many dashboard widgets available. In this guide we’ll use a data gauge to display the light level. We’ll do this directly on the device’s console page, so click on the newly-added AVR-IoT WG to enter its console.

If you're following along the guide using the pre-built AVR-IoT Light Monitor Demo, the dashboard's data gauge widget is already configured for the registered device. It may take up to a minute once you enter the device page for its configuration and data to populate.

  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 Gauge data gauge widget to add a gauge to the dashboard.
  2. In the data gauge’s settings, modify the following properties:
    • Name: Give the widget a name, such as “AVR-IoT Light Data.”
    • Prefix: Give the widget a prefix label for the gauge, such as “Light.”
    • Units: Enter lux for its unit of measurement.
    • Min: Set the minimum value to 0.
    • Max: Set the maximum value to 600.
    • Number of Splits: Set the number of split increments for the gauge to 6.
    • Middle Segment Start: Set the start value of the middle segment to 200.
    • Middle Segment End: Set the end value of the middle segment to 500.
    • Segment Colors: Select colors for each of the three segments on the gauge. Choose whichever color you think will be most appropriate for each segment.
  3. In the Data Source field, click Select, then choose the following configuration options for the widget:
    • Select Cloud Storage: Click the cloud storage that is storing the light data.
    • Select Value Select the Light Data dataset.
  4. When finished click Save.

The light sensor value is then displayed on the data gauge widget. If you’re in a space with average light, the light sensor should record a reading around 100 lux. If you’re in a bright area you may want to cover the board to ensure the sensor reading remains low.

Monitor Guide Dashboard Good

Step 8 of 8: Prompt a Status Change and Notification

With the device registered and sending data to Atmosphere, it’s time to initiate its status change. With a light sensor this is easy to demonstrate, so we’ll end up feeding it some light to force the sensor reading high to produce the status change and receive the notification.

  1. Return back to the Devices area, where the AVR-IoT is still displayed with a “good” status.
  2. Shine a bright light onto the AVR-IoT. This can be done using a phone, flashlight, desk lap, etc. Keep the light shining on the AVR-IoT until its next reading. If it’s bright enough (greater than 200 lux) it will prompt a status change. Monitor Guide Dashboard Critical
  3. Exit the AVR-IoT’s console and return back to the Devices area. With a light reading beyond 200, the AVR-IoT now displays as “critical.” Monitor Guide Device Critical
  4. When the status changes, a system notification appears on the sidebar notification icon. Click the notification icon to expand the sidebar’s Notifications menu, where is displays the message added from the cloud notification element. Monitor Guide Notification
  5. When you remove the bright light from the AVR-IoT, its status returns to “good” upon its next reading.

That’s it! With some simple cloud element usage, you’ve been able to create a complete monitoring application with Atmosphere that modifies device status and sends a notification.

What’s Next

Now that you’ve created a project with monitoring and status capabilities, it’s recommended you try this with additional sensors as well. The light sensor is a great example for demonstrating how a monitoring application is built due to how easily the light reading can change, but these steps can just as well be applied to other sensors such as temperature, humidity, vibration, acceleration, and more.

Likewise, with an understanding on setting device status and sending notifications, you can further explore the range of cloud abilities and logic that can be made using Atmosphere to create more complex and precise monitoring applications.