Make an IoT Weather Station with ARTIK, Temboo and SAMI

If you follow the SAMI blog, you’ll remember Dan Gross’ tutorial to Make an IoT Weather Station with SAMI using off-the-shelf sensors and hardware together with Samsung SAMIIO. In round 2 of the Weather Station series, we are moving our development platform to ARTIK 10. We’ll also use the Temboo software library that comes preloaded on ARTIK.

Hardware components

  • ARTIK 10 development board with a network connection
  • Temperature sensor (TMP36)
  • Breadboard with wiring

SAMI device ID and token

Please follow the “Connect to SAMI” instructions in the previous IoT Weather Station blog to connect your device to SAMI. Be sure to keep a copy your device ID and device token, obtained from the SAMI User Portal.

Software tools: Temboo

Temboo is a cloud-based code generation platform with 2000+ processes for APIs, databases and more, reimagining programming for software and hardware developers. Temboo has been working with Samsung to bring all of the flexible programming features of its IoT software stack to the ARTIK platform. A Temboo library comes preloaded on every ARTIK 10 device.

If you haven’t worked with Temboo’s tools before, please take a look at its Getting Started guide.

Demo video

Let’s start coding

By using Temboo’s online tools, we can come up with a skeleton application in minutes.

  1. Start by logging in to Temboo. If you don’t have an account, you can create one at for free.
  2. Go to the Utilities -> HTTP -> Post Choreo in the Temboo Library.
  3. Select “Samsung ARTIK 10” and “Onboard Ethernet and WiFi” from the dropdown menus, then turn on “IoT Mode”.

  4. Since we want the temperature sensor’s analog output to trigger the Choreo, we will enable the “Is this Choreo triggered by a sensor event?” option, and set to trigger if the output on Pin 7 > 0.

    This step will generate the analogRead() function in the Temboo code window, so we do not need to write the code on our own. We will change the application logic later to collect sensor data at a fixed time interval.

  5. In the INPUT -> URL dialog, enter SAMI’s URL:

  6. Click OPTIONAL INPUT, enter “true” in the “Debug” field, and then enter the RequestBody and RequestHeaders details.

    Here is an example of RequestBody. We’ve hardcoded the temperature data for testing purposes. We’ll change that later. Be sure to set the “sdid” field to the device ID from your SAMI device info.t

    	"sdid": "YOUR_SAMI_DEVICE_ID",
    	"type": "message",   "data": {	
    		"temperature": 29.2   

    Here’s an example of the RequestHeaders format. Replace “YOUR_SAMI_DEVICE_TOKENS” with the device token you retrieved from the SAMI User Portal:

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

    tIf you have questions about how to format these fields, please check the SAMI documentation on sending and receiving data and authentication.When you have entered this information, you should have something like this:t

  7. Now, click the button to see if you can execute your code without errors. At the same time, log into the SAMI User Portal to verify the hard-coded temperature data has been successfully sent to SAMI. You should be able to see the collected temperature data under the “DATA LOGS” tab .

  8. Once you are able to execute your Choreo successfully, scroll down to the CODE section and download the auto-generated C code.
  9. Copy the code to your ARTIK board – you’ll further customize and compile it there.

If you have questions regarding these steps, please re-visit “UPLOADING TO THE ARTIK BOARD” on this page.

Extending the Temboo code

Let’s set up the code to collect temperature data every 10 seconds, and send it to SAMI. Remember that we are now working on the code we downloaded, and are not making these modifications in Temboo.

  1. Look for the main() function in Temboo code. In main(), there is a while loop. Add sleep(10) to the end of the loop to make it run every 10 seconds. (You may find usleep(1000) there already. Replace it.)
  2. The temperature sensor data we collected is analog data; we need to convert it to Fahrenheit values.

    We’ll modify the existing main while loop…t

    while(currentRun < MAX_RUNS) {  
    	if (analogRead(inputPin) > 0) {

    t…and extend it to read the input pin, convert the voltage to temperature in F, and then send the real-time temperature to SAMI.t

    while(currentRun < MAX_RUNS){
        int sensorVal = analogRead(inputPin);    
    	float voltage = sensorVal;   
    	voltage /= 1024.0;    
    	float temperatureC = (voltage - 0.5) * 10;
        float temperatureF = (temperatureC * 9.0 / 5.0) + 32.0;
        printf("current temperature is %fn", temperatureF);
    	runPost(&theSession, temperatureF); //    

    tYou’ll notice that “runPost” now has an extra argument in it: temperature. We’ll need to modify the function to accommodate that. Add:t

    void runPost(TembooSession* session, float temperature) {

    tThen modify the first “AddChoreoInput” to accept the new argument:t

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

Save your file, then zip it up along with TembooAccount.h and SCP it over to the ARTIK.

Wire it up

TMP 36 temperature sensor has 3 pins, with the middle pin for analog temperature data. Here is what the wiring looks like:

Here are the ARTIK 10 pin assignments. You’ll be using GND, 5V, and GPIO 7.


Recompile and run your application. If you go back to the SAMI User Portal, you will be able to see the streamed temperature data in real-time.

Pretty cool, right? We’re sure you’re already thinking of ways to expand on this idea. We can’t wait to see your ideas!

Download the source for this demo here.