In order to use Samsung Artik Cloud service, a "Generic MQTT server" library is required. The sequence of steps to onboard with Artik Cloud is outlined below.
Run mos
tool, install Mongoose OS and set up WiFi
Click on the device, generate device token
Open device configuration in the Web UI, click on Expert View, and set the following fields (use your specific device ID and token):
mqtt.enable=true
mqtt.server=api.artik.cloud:8883
mqtt.user=YOUR_DEVICE_ID
mqtt.pass=YOUR_DEVICE_TOKEN
mqtt.ssl_ca_cert=ca.pem
Open Device Files tab, click on init.js
file. Paste this code
that sends fake temperature/humidity data to the cloud:
load('api_config.js');
load('api_mqtt.js');
load('api_sys.js');
load('api_timer.js');
let sdid = Cfg.get('mqtt.user');
let topic = '/v1.1/messages/' + sdid;
Timer.set(1000, true, function() {
let data = {temperature:24, humidity:Sys.free_ram()};
let ok = MQTT.pub(topic, JSON.stringify(data), 1);
print('Published', ok, JSON.stringify(data));
}, null);
Click 'Save + Reboot' button
Click on CHARTS tab in Artik Cloud console. Add graph for DHT11 device, humidity - in reality, that reports free RAM.
The process above shows how to use Samsung Artik Cloud to authorise devices and report data via MQTT.
edit this doc