The sample code establishes a secure MQTT session with ARTIK Cloud, sends one message, and ends the session.
- node
- npm
- Sign into My ARTIK Cloud
- On the device dashboard, click to connect a new device. Select the Demo Fire Sensor (from cloud.artik.sample.demofiresensor) and name your sensor SampleFireSensor (or any name you'd like).
- Click the Settings icon on the device you just added. Get the device ID and device token. If the token does not already exist, click "GENERATE DEVICE TOKEN…" to get one.
- Run the command to install packages:
npm install
- Prepare source files. Rename template_config.json to config.json. Then copy the device ID and device token obtained before to config.json file.
%> node app.js
Here is the sample response:
publishing data: {"temp":214}
publish path: /v1.1/messages/<redacted>
Use browser to see your data in realtime https://artik.cloud/my/data
Have you visited ARTIK Cloud data visualization tool?
Select your device from the charts to view your device data in realtime. Run the application multiple times in your terminal, which sends a few random values. Here's a screenshot:
If you are not familiar with ARTIK Cloud, we have extensive documentation at https://developer.artik.cloud/documentation
The full ARTIK Cloud API specification can be found at https://developer.artik.cloud/documentation/api-reference/
Peek into advanced sample applications at https://developer.artik.cloud/documentation/samples/
To create and manage your services and devices on ARTIK Cloud, visit the Developer Dashboard at https://developer.artik.cloud
Licensed under the Apache License. See LICENSE.
Copyright (c) 2016 Samsung Electronics Co., Ltd.