- 0. Introduction
- 1. Altair SmartWorks Project and Device Registration
- 2. How to use libraries in Arduino
- 3. Code implemented on Arduino to test the library
- 4. Checking Data is collected in Altair SmartWorks
- 5. From here on: Enhancing the project
This easy tutorial familiarizes you with the Altair SmartWorks send stream library
Using this library you can send lists of key-value pairs to Altair SmartWorks by simply calling a predetermined method
In this tutorial you will learn how to:
- Structure the data you want to send to be compatible with the Altair SmartWorks library
- Send the data to Altair SmartWorks using the send stream method
- 1 x Arduino Yun
Music to listen: The Mamas and the Papas - California Dreaming
If youre registered in Altair SmartWorks, you have a default device already created for you.
Check your control panel and see what it looks like.
Basically you need the device id_developer that might be something like defaultDevice@myusername.
But if you want, you can create a new device and use it in this example.
Now, go to your control panel “My account menu” and check your Apikey.
Its a big alphanumeric token like:
You need this number to complete the example.
Arduino libraries allow the sketches to have extra funcionality. Arduino has many libraries that are already established and come with the IDE. However, it's also possible to write your own libraries or use libraries written by others. Each library has a header file which describes each method and a source file, which elaborates the code. To read more about Arduino libraries or writing a library see Arduino-Libraries
In this tutorial we will use a library created to send streams to Altair SmartWorks.
To use the library, first download it here. Once you have downloaded the library you must decompress it and then copy it into the arduino/libraries file. Now you should be able to use the library in any sketch you create.
The method used to send streams to Altair SmartWorks is the method "send". It has 4 parameters that you need to define in order to send a stream correctly.
The first parameter is a two-dimensional array. The number of rows of this array is up to you, but the number of columns must be two (one column for the key, one column for the value).
The second parameter is the number of rows or elements that the array has. You could find this number by dividing sizeof(array) / sizeof(array).
The third parameter is your Apikey which you need to identify your Altair SmartWorks account.
The fourth parameter is your device id_developer which specifies which of your registered devices you are using.
This is the Arduino Yun code to test the send method. Note that some values should be replaced by your own values.
If you get here, your device must be sending streams to Altair SmartWorks
Its time to test our control panel and check if we have new streams.
Go to “Data management” → “Data streams” and you will see your data.
- menu option
- new data
Now you know how to use the Altair SmartWorks library with an Arduino Yun device to send data to Altair SmartWorks. But you can enhance this project in many ways:
- Try to send dynamic data using the Altair SmartWorks library