Getting Started with AVR-IoT WG
This guide teaches you how to get started using the Microchip AVR-IoT WG development kit with Atmosphere. This includes creating your first project, programming the project’s firmware into your AVR-IoT WG, registering the device to Atmosphere, and having its data displayed on a dashboard.
This guide demonstrates a simple project that measures temperature and light data from the board, then sends it to the cloud over Wi-Fi.
Prerequisite: You should already have an Atmosphere account.
- Microchip AVR-IoT WG development kit
- 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.
Step 1 of 7: 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.
- Click the button. This displays a New Project window.
- 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 7: 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 two intervals to read embedded data, and to tell the interval to read the board’s temperature and ambient light sensors.
- Add the following elements to the canvas by clicking them in the Element Toolbox:
- Two interval elements: 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).
- MCP9808 element: The MCP9808 element reads temperature data. This is a temperature sensor that is onboard the AVR-IoT WG, and its element is imported in the Element Toolbox for AVR-IoT WG projects by default.
- 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 MCP9808 element and TEMT6000 elements will work as intended by default, so none of their properties need to be changed.
- Click the first interval element to view its properties. In its properties area, change the Time field to
5000. Then click the second interval element, and change its Time field to
500. This means the first interval will eventually run every five seconds, and the second will run every half second.
- Connect the first interval element to the MCP9808 element. This creates an event between them, which can be seen in either the interval element’s properties, or by clicking the connector’s button. The event added is within the
Intervaltrigger, with the MCP9808 ability
Read Ambient Temperature. This means that when the interval element is triggered (which is every five seconds), it will read the sensor’s ambient temperature data.
- Connect the second interval element to the TEMT6000 element, which also creates an event between them,
Read Ambient Light. This event will read the sensor’s ambient light data when the interval element triggers every half second.
That’s all for work in the Embedded tab. To this point, two intervals have been set that will run at five seconds and half a second respectively, and when run will read the ambient temperature and ambient light data from the AVR-IoT WG’s onboard sensors. The Embedded tab canvas should resemble the following image:
Step 3 of 7: Enable the Project’s Cloud Connectivity
The next aspect of building this sample project is enabling it for cloud connectivity. This is done on both the Embedded and Cloud tabs.
- While still in the Embedded tab, add two cloud event elements 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.
- Connect the MCP9808 element to the first cloud event element. This adds the
Send Eventevent to the
Ambient Temperature Readtrigger, which sends the ambient temperature data to Atmosphere when the temperature is read every five seconds.
- Connect the TEMT6000 element to the second cloud event element. This adds the
Send Eventevent to the
Ambient Light Readtrigger, which sends the ambient light data to Atmosphere when the light level is read every half a second.
- 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.
- Add two cloud storage elements to the canvas, and connect one to each cloud event element. This allows Atmosphere to 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 ambient temperature and ambient light data from the Embedded tab to the Cloud tab through two cloud event elements, where they’re connected to two cloud storage elements to store each dataset on Atmosphere.
The final canvas for each tab should resemble the following images:
Step 4 of 7: Compile the Project
Once the project is finished, it needs to be compiled. Compiling readies the entire project’s source code for deployment.
- From any tab, click the 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 7: 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:
- From the Embedded tab, click the button from the tab’s toolbar. This downloads a .hex file containing the project’s compiled firmware.
- 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 7: 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:
- Navigate to the Devices area, and click the 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.
- 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.
- 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.
Step 7 of 7: 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 glance to display light levels, and a data graph to chart the temperature reading. We’ll do this directly on the device’s console page, so click on the newly-added AVR-IoT WG to enter its console.
- To add a widget to the device’s dashboard, click the button on the right side of the screen. This displays the menu of available widgets. Select the data glance widget to add a data glance to the dashboard.
- Once on the dashboard, click the widget’s menu icon to display its menu, then click Settings.
- In the data glance’s settings, modify the following properties:
- Name: Give the widget a name, such as “AVR-IoT Light Levels.”
- Units: Enter
Luxfor its unit of measurement.
- Icon: Select an icon that represents the data, such as the
- Color: Give the widget a color that represents the data, such as orange or yellow.
- 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 ambient light data.
- Select Value: Select the ambient light dataset.
- When finished click Save. The data glance is then populated with the ambient light reading.
- Now add a data graph widget to add a graph to the dashboard, then go to its settings.
- Give the data graph a name (such as “AVR-IoT Temperature Reading”), then in its Data Source field click Select and choose the following configuration options for the widget:
- Cloud Storage: Select the cloud storage that is storing the temperature data.
- X-axis Value: Select the timestamp to go along the graph’s x-axis.
- Y-axis Value: Select the temperature dataset to go up the graph’s y-axis.
- When finished click Save. This populates the data graph plotting the temperature value as time progresses, which by default is set to the last ten minutes. If you’d like to adjust the graph’s timeline or its bounds, you can edit those properties from the data graph’s menu as well.
Congratulations, you just finished a complete AVR-IoT WG project with Atmosphere!
If you're interested in a slightly more advanced version of this project, try out the AVR-IoT WG Onboard Sensor Demo available in Studio's Demo Projects section. This demo is similar to the project used in this guide, but also includes setting a status condition for the ambient light value in the Cloud tab, that if the light value exceeds a set limit an alarming state is triggered.