Sending temperature and humidity from Arduino MKR1000 to Artik Cloud
Things used in this project
Story
Background
This article describe how to use REST for sending data from Arduino MKR1000 and DHT sensor to Artik Cloud
Prerequisites
You must have basic knowledge about programming Arduino MKR1000. Also you need Artik Cloud (Samsung) account. For Arduino IDE, libraries WiFi101 and ArduinoJSON are required. In this article we are not going through step-by-step tutorial for Artik Cloud. If you are not familiar with Artik Cloud, please review this article with video tutorial for instructions.
Artik Cloud
First step is creating device type (manifest) for DHT sensor at developer dashboard. We have two values : temperature and humidity, and manifest is very simple. You can choose any name for device type, but note it for next step when device will be created. We should create manifest with two field for each value. After finishing all steps you would have device type as shown on next image :
Next is creating Artik Cloud device. Log on into your dashboard with your devices. Create new device for device type you created in first step. After device has been created, click on settings gear and generate token. From this dialog you need to copy-paste device ID and device token into Arduino code.
Code explanation
For sending data to Artik Cloud HTPPS REST API is used. That’s why we need <WiFi101> library for Arduino IDE. Another helper library is <ArduinoJSON>. According Artik documentation, when REST API is used, data must be sent in JSON format. Here is example :
{
"sdid": "4697f11336c540a69ffd6f445061215e",
"type": "message",
"data": { "temp" : 22, "humid" : 55}
}
For more information about Artik Cloud REST API you can find here.
Code modification
You have to make some modification in attached code. All changes are to provide your credentials for WiFi and device ID and token. Find these lines and provide your data:
String AuthorizationData = "Authorization: Bearer <YOUR DEVICE TOKEN>";
...
char ssid[] = "SSID"; // your network SSID (name)
char pass[] = "PASSWORD";
...
root["sdid"] = "<YOUR DEVICE ID>";