A Smarter World in Minutes


ARTIK opens a lot more doors in the application of the Internet of Things (IoT). Specifically for the ARTIK platform, Temboo created an IoT stack with live code generation. Creating everything from the browser, it makes development very convenient for developers. With ARTIK Cloud serving as the data exchange platform, any device can push data to the cloud.

Set up a weather station with ARTIK and send the data to ARTIK Cloud with dynamic code generation from the browser using Temboo.

Setting up the Environment

Prepare the following to create a SmartApp:

  • Samsung Account www.artik.cloud

  • Temboo Account www.temboo.com

  • ARTIK 5 or ARTIK 10 Development Board

  • PuTTY www.putty.org


  • TMP36 temperature sensor

  • Connecting wires

  • Breadboard

Step 1. Create the ARTIK Cloud Account

a. Navigate to ARTIK Cloud User Portal and sign in.

b. Hover on My ARTIK Cloud tab and click on Devices.

c. To connect your first device, start typing the "Test Automation Device" device type in the text field and select it from the dropdown list. Provide a name for it, then click Connect Device…

Figure 1 Creating a New Sami Device

Figure 1 Creating a New Sami Device

d. The new device will now be listed in the devices page.

e. Click the gear like icon on its right and a popup window will appear showing the device info.

f. Click Generate Device Token… Then take note of it together with the Device ID as this will be used in the code later.

Figure 2 Generating Device Token

Figure 2 Generating Device Token

g. The device is now ready.

Step 2. Setting Up the Library

a. Create the file temboo.conf in /etc/ld.so.conf.d containing the path below.


b. Run ldconfig from the command line to add the Temboo library directory to the system library search path.

Step 3. Generating Code from Temboo

a. Sign in to Temboo. https://temboo.com/

b. Go to https://temboo.com/library/Library/Utilities/HTTP/Post/ to start the configuration.

c. Turn on IOT Mode, then choose "Samsung ARTIK 10" in the list of devices and boards, and connect via "Onboard Ethernet and Wifi"

Figure 3 Temboo Settings

Figure 3 Temboo Settings

d. Expand to specify the sensor event trigger. Assign an Analog pin, for ARTIK 5 it can either be 0 or 1 and set the trigger if the value in the analog pin is greater than 0.

Figure 4 Choreo Trigger

Figure 4 Choreo Trigger

e. Enter ARTIK Cloud’s URL in the INPUT -> URL dialog. This is where the requests will be posted.


f. Expand the part for Optional Menu. Fill in the Debug, RequestBody, and RequestHeader fields. In the Debug field, set it to "true" to return HTTP debug logs.

g. Copy the code snippet below to the RequestBody field. Specify your ARTIK Cloud Device ID in the sdid field and make sure the data block matches the device field name and type in your device type manifest found in ARTIK Cloud’s developer portal. The value for temperature is just for testing purposes and can be changed later on.

	"sdid": "YOUR_ARTIK_Cloud_DEVICE_ID",
	"type": "message",
	"data": {
		"temp": 23

h. As for the RequestHeaders, copy the snippet below and put in your device token found in ARTIK Cloud’s user portal.

	"Content-Type": "application/json",
	"Authorization": "Bearer YOUR_ARTIK_Cloud_DEVICE_TOKENS"

i. Once done, click the Run button and head over to the ARTIK Cloud User Portal to verify if the data has been sent. See the data either from the Charts or Data Logs tab.

Figure 5 ARTIK Cloud Data Logs

Figure 5 ARTIK Cloud Data Logs

j. Once the Choreo is successfully executed, scroll down to the CODE section and download the auto-generated C code.

Step 4. Extending the Temboo Code

a. Temboo code is generated for ARTIK 10. If you are testing on an ARTIK 5 board, please modify the sysfs interface for the analog pin from 12d10000.adc to 126c0000.adc.

sprintf(fName, "/sys/devices/126c0000.adc/iio:device0/in_voltage%d_raw", pin);
sprintf(fName, "/sys/devices/126c0000.adc/iio:device0/in_voltage%d_raw", pin);

b. Set up the code to collect temperature data every 10 seconds and send it to ARTIK Cloud. Open the downloaded C code using vi. Look for the main() function and notice the while loop. Add sleep(10) to the end of the loop to make it run every 10 seconds, replacing the usleep(1000).

c. Convert the analog data gathered from the designated pin to its value in Celcius and eventually to Fahrenheit.

d. The runPost() function is the trigger to send data to ARTIK Cloud. Add the temperature in Fahrenheit as an extra argument as it will be the data to be sent.

while(currentRun < MAX_RUNS){
	int sensorVal = analogRead(inputPin);
	float voltage = sensorVal;
	voltage /= 1024.0;

	float temperatureC = (voltage * 1024 / 3.3) / 10000;
	float temperatureF = (temperatureC * 9.0 / 5.0) + 32.0;

	printf("current temperature is %f\n", temperatureF);

	runPost(&theSession, temperatureF); //


e. Notice that the runPost() function now has an extra argument in it.

void runPost(TembooSession* session, float temperature) {

f. Then modify the first "AddChoreoInput" to accept the new argument.

ChoreoInput RequestBodyIn;
RequestBodyIn.name = "RequestBody";
char requestBody[256]="";
sprintf(requestBody,"{\n	\"sdid\": \"[your device ID here]\",\n	\"type\": \"message\",\n	\"data\": {\n		\"temp\": %f \n	}\n}", temperature);
RequestBodyIn.value = requestBody;
printf("Request Body is %s", RequestBodyIn.value);
addChoreoInput(&choreo, &RequestBodyIn);

g. Save the code and proceed with wiring the circuit.

Step 5. Wiring Up the Circuit

a. Connect the TMP36 to the ARTIK board with its output pin connected to A0 on J24.

Figure 6 Connecting the Temperature Sensor

Figure 6 Connecting the Temperature Sensor

b. In the same manner, connect the PWR and GND to pins 3.3V and GND on J25 respectively.

Figure 7 Pin Connections on the ARTIK Board

Figure 7 Pin Connections on the ARTIK Board

Figure 8 Connecting the Sensor to the Board

Figure 8 Connecting the Sensor to the Board

Step 6. Running Your App

a. Copy the code to the ARTIK board to compile. Use scp command on PuTTY or pscp on Windows. Make sure that both files are in the same directory.

Figure 9 Transferring Files to ARTIK Using pscp

Figure 9 Transferring Files to ARTIK Using pscp

b. Run the first command to compile your code. Once done and there are no reported errors, run the program using the second command

[root@localhost ~]$ gcc -L/root/temboo_artik_library/lib -ltemboo -I/root/temboo_artik_library/include /home/post.c -o /home/gccPost
[root@localhost ~]$ /home/gccPost

c. Over at the ARTIK Cloud User Portal, check out the charts and see the graph as it is updated in real time. Vary the temperature around the sensor and see the graph move.

Figure 10 Real-time graph of gathered sensor data in ARTIK Cloud

Figure 10 Real-time graph of gathered sensor data in ARTIK Cloud