Samsung Artik Cloud: Quick Start Guide

  • Tutorial
The theme of the Internet of Things platforms is now in the “hype” wave, which is confirmed by the Gartner curve of the main technological trends : since 2016, the “Internet of Things Platforms” on the chart have replaced the “Internet of Things”.


Today we will talk about what Samsung offers, and, first of all, about Samsung Artik Cloud.

Content:

  • Features Samsung Artik Cloud as an Internet of Things platform.
  • Learning to work with Artik Cloud in practice:
    • Create a new device type,
    • Data simulation
    • Retrieving data from the cloud using the REST API.


Features Samsung Artik Cloud as an Internet of Things platform.


Under the platform of the Internet of things, as a rule, they understand some ready-made integrated solution of several components that helps to accelerate the process of bringing an IoT product to the market.

What components should ideally have such a platform? According to the author of the article “5 Things To Know About The IoT Platform Ecosystem” from IoT Analytics, the platform should consist of 8 functional components:
Table. 1.


At the moment, not all IoT platforms have these components. As a rule, a focus is made on some of them: for example, Amazon AWS is not an ordinary database in which a permanent virtual Shadow of a device is created, IBM Bluemix has the ability to use the Watson analytics service, and in PTC ThingWorx you can easily create a graphical interface applications.

In 2016, Samsung launched the Artik family, which currently includes:

  • Software platform - Artik Cloud - this material is dedicated to it,

  • Hardware platform - Artik microcomputers.


An interesting point: Samsung releases under one name both a software platform and a hardware solution, and at different levels: from the smallest and most computationally weak Artik 0, to powerful and productive Artik 7.
Another interesting point: recently, in 2017, the company Samsung has announced the unification of several technologies under the common name SmartThings Cloud: Samsung Connect (specialized routers of Smart Home), SmartThings (home automation solutions) and the Artik family. In this case, all existing functionality will be saved.

The official website of the product is located here .

If we consider Samsung Artik Cloud from the point of view of the list of functional components (see Table 1), we get the following:
Table 2
Of the key components at the moment there is no analytics and machine learning component. But this year, Samsung announced the opening of an additional 4 new scientific centers of artificial intelligence around the world. So there is every reason to believe that work in this area is included in the strategic plans of the company.

Benefits


Affordable pricing


Everything is simple here. You can send up to 100,000 messages per month for free. Unlike other similar services, you do not need to attach a bank card before using it. She will not be required of you at all. You will have to pay only if you decide to use Artik Cloud in a real task where the number of messages per day and per month is critical - in this case, the cost of 1 million messages will be $ 15.

That is why Artik Cloud is great for teaching students: if you use it only in class, the chances of running out of quotas are very small.

Several different APIs


At the moment, you can interact with Artik Cloud in four ways at once:

  • REST API
  • Websockets
  • MQTT
  • Coap

Noteworthy is the support of two protocols at once, which are widely used on the Internet of things: MQTT and CoAP.

Limitations


Beta stage


Artik Cloud is still a young product (it appeared in 2016). Some features are still in beta. For example, in a device simulator you cannot work with more than one device.

Incomplete documentation


Documentation is evolving. For example, the REST API is now very well documented, and the documentation of the MQTT API needs to be improved.

Learning to work with Artik Cloud in practice


And now we suggest you create a virtual device - a GPS tracker that will generate random data. Then we will access this data from the computer.

Account creation


We go to the site https://my.artik.cloud/
There are several registration options. The easiest way is to use an existing Google account. Spam will not be sent! Verified by personal experience.



Create a new device type


You will be taken to the user page https://artik.cloud/ .

Here you can add devices to your system, watch logs, set interaction rules. Now, almost nothing can be done on it, since the devices and sensors we need are not among the proposed options. Go to the developer page right
away : https://developer.artik.cloud/
Create a new device type.



Next, you need to come up with a name and a unique identifier - you will need it if you later want to share your virtual device with the community.



You will be prompted to create a “manifest” that defines the device’s fields.



You will see the manifest creation window open on the first tab: Device Fields. Since we are making an example for a GPS tracker, create two fields for latitude and longitude. I called them lat (latitude) and long (longitude).



You can set:

  • Field names (in our case - lat and long ),
  • Units (there are already standard units for this).

Click the Next button. You do not need to specify “Device Actions” in this example, so immediately after that, proceed to activate the manifest.

Device creation


Now you can create a new type of device by returning to https://my.artik.cloud . Click + Add Another Device ...



Device simulation


Let's try an interesting function - data simulation. It is useful for testing.

At the rectangle that indicates the device, click "...", and then click Simulate Device Data.



A window will appear in which you can set the simulation parameters for each field. For example, the interval of the output of values, boundaries, distribution (in our case, random).



After that, you can click on the Start Simulation button.



Data began to appear. You can see them on the chart. To do this, open the Charts tab in the top menu.



You will see in real time the values ​​of longitude and latitude in the range you specify:



This schedule is quite convenient to use. It can be scaled, twisted back history, change the type of chart. As you can see in the screenshot, you can also make bar and dot charts:
If you want to see metadata, it is convenient to use the Data Logs tab. Here you will see the generation date, date of receipt and internal representation of the data - this is the familiar JSON format.



Receive data from the cloud


Let's try to get our simulated data out of the Cloud. We will use the REST API - this is logical, because we will write code for receiving data in JavaScript.

Click on the device name in the menu.



In the window that opens, you will see various device keys, of which two are important: Device ID and Device Token. When accessed from outside, these keys work as login and password. You will need them very soon.



How do I know which request to send? There is a very convenient developer tool for this - the API console . It allows you to watch and learn examples of various API requests. Let's look at the GET (Get Last Normalized Messages) request:



To fulfill such a request, it is necessary to specify which device we are accessing ( sdids - here we need to substitute the device identifier obtained in the previous step), the fields of interest to us ( fieldPresense ), and how many values ​​we want to get ( count ).

Fill in the fields and click Try it! You will receive information sufficient to make a request:



  • Call is the address to which the request will be sent,
  • Request Headers - headers that must be sent along with the request,
  • 200 - response code.


Javascript code


Here is a sample JavaScript code that will receive a message from the cloud and display it.

varxmlhttp=newXMLHttpRequest();
varcall = "https://api.artik.cloud/v1.1/messages/last?count=1&fieldPresence=lat&sdids=084d34b198d84f1688b3b7b3fe420fcf";
xmlhttp.open('GET',call,true);
xmlhttp.setRequestHeader("Content-Type","application/json");
xmlhttp.setRequestHeader("Authorization","Bearer fc851ddb484842788daa19569b326951");
xmlhttp.onreadystatechange=function(){
	if(xmlhttp.status==200){
		alert(xmlhttp.responseText);
	}
};

Of course, the varcall line and the Bearer authorization parameter need to be replaced with your own, obtained in the last step.

The result of the work of this code in the Mozilla browser:
This is a JSON string in which, among other things, there are the required lat and long coordinates . It remains only to parse the string using the JSON parser, and you have the data!

Based on this example, you can easily label a geographic map using the Yandex.Maps API.



Conclusion


So what have we implemented? A simple example: creating a device in the cloud, simulating its data and receiving this data on your computer.

Outside the brackets are:

  • Sending data to the cloud through the REST API,
  • Interaction with the cloud through other interfaces, such as MQTT,
  • Actions (Device Actions),
  • Rules (Rules Engine).

Those who are interested to continue, these issues can be studied independently, using the official documentation .

Posted by Tatyana Volkova
Employee at Samsung Research Center
Manager and author of the curriculum for the IoT Samsung Academy project