Filter results by

Prototype and deploy your device

If you want to make devices for ARTIK cloud services, this article describes the high-level steps needed to start your development process. It includes prototyping workflows and best practices for productization.

We focus on the big picture here. To fill in the details, read the following articles:

Basic steps for prototyping

Our example device prototype is a flame sensor.

Prototype your device

See Your first IoT device for a detailed walkthrough of these steps.

Step 1: Know your device data

What type of data will your device send to ARTIK cloud services? This determines the data field(s) that you include in the Manifest (Step 2) and that can be used with Rules or external applications. These fields define what is essential to the device and its feature set.

For our flame sensor, we choose a Boolean data field to indicate whether fire is detected. Each message from this device to ARTIK cloud services includes this data.

Prototype your device

Step 2: Create a device type

Log into the Device Dashboard and follow the instructions to create a device type called "Flame Sensor".

Our Manifest will look like this:

Prototype your device

Step 3: Onboard the physical device

Onboarding devices is the process of obtaining device credentials and loading them on physical devices.

  1. Sign into My ARTIK Cloud.
  2. Click to connect a new device. Choose the "Flame Sensor" device type created in Step 2 and give it a personalized name like "My flame sensor".
  3. Get the device ID and token. These are the device credentials.
  4. Write the device credentials into the code running on the physical device. Example code snippet:
var device_id = "<YOUR DEVICE ID>";
var device_token = "<YOUR DEVICE TOKEN>";

See Step 3 of Your first IoT device for more detailed code.

Note that we are manually onboarding our prototype. This How To guide explains how you can programmatically onboard physical devices in production.

Step 4: Make API calls to send data

The code running on the device can now make the REST API call to POST data messages using the credentials (device ID/token). Each message makes an HTTP request like the following:

headers: {"Authorization": "bearer <YOUR DEVICE TOKEN>"}, 
body: {"sdid": "<YOUR DEVICE TOKEN>",
     "data": {"onFire": onFireReading}

Step 5: Testing

Start your device. In the Charts tab at My ARTIK Cloud, you should see the data being sent to ARTIK cloud services (e.g. onFire) in near real-time.

Add Actions to the device

Some devices not only send data to ARTIK cloud services but also act on commands (Actions) from ARTIK cloud services. The simple smart light below is an example.

Prototype your device

This section enhances the high-level steps in the previous section.

See An IoT remote control for a detailed walkthrough of these steps.

Enhance device Manifest

After defining the data fields in Step 3, follow these instructions to define device Actions in the Manifest.

Prototype your device

Receive and act on Actions

Use REST only

This is the simplest method. At Step 4, enhance the code running on the device:

  1. Periodically make REST API calls to GET Actions and then act on Actions.
  2. Send a message to ARTIK cloud services after acting on an Action. The message contains the latest state.

Item 2 is a must-have. Failure to implement it causes inconsistency between the device state at ARTIK cloud services and the state on the physical device.

Use persistent connections

Using the REST API is best for learning or when there are no other options. In practice, we recommend establishing a persistent connection between a device and ARTIK cloud services so that the device can receive Actions in near real-time.

  1. Establish device channel WebSocket (a persistent connection).
  2. Listen to the Actions from the channel and then act on Actions.
  3. Send a message to ARTIK cloud services to report the latest state.

See An IoT remote control for a detailed walkthrough of the above steps, using an example smart light.

Enhance testing

Modify Step 5 as follows:

  1. Click "Send action to device" at My ARTIK Cloud and choose an Action. Prototype your device
  2. Your physical device should turn on/off and then return the latest state.
  3. Visit the Charts tab at My ARTIK Cloud to see the latest data (e.g. state) in near real-time.

From prototyping to production

Choose communication protocols

We focused on REST for prototyping because it is simple. ARTIK cloud services offer a number of protocols for your devices to communicate: REST, WebSocket, MQTT, and CoAP. Read their corresponding documentation and choose the protocol that best suits your needs.

Choose onboarding methods

We manually loaded our device credentials to a physical device, but there are many ways to onboard physical devices, aimed at different scenarios.

Cloud Connector option

If you are also building a cloud for your devices, consider using a Cloud Connector. This uses the cloud, rather than the device, as a data source.