This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TM4C129X - Amazon Web Services(AWS)/Ubidots IoT API

Other Parts Discussed in Thread: EK-TM4C1294XL, CC3200

Hello


I have recently purchased the TM4C129X board. Wanted to know if it can work with Amazon Web Services API or Ubidots API. I tried to create an embedded C program for uploading a value(an integer) to the ubidots cloud, using the Ubidots-C API, but couldn't build the program in Code Composer Studio.

Any help would be greatly appreciated

Thanks & Regards

Yash Bhan

  • Hello Yash,

    TI doesn't currently have an API or examples for TM4C products to support access to the Amazon or Ubidots IoT cloud services nor do we have any experience in doing so. Perhaps some diligent searching of the web and support forums for those servers will yield some productive hints and or code. If you get it figured out we would love to have you re-post here so we can all benefit from it.
  • Hello Chuck

    Thank you for the reply. Ubidots has a C language based API, 'Ubidots-C', The Github link for the project is github.com/.../ubidots-c.
    I tried compiling the same on GCC and ARM compiler (through CCS). The code compiled successfully with GCC, but it failed for ARM compiler(CCS). Wanted to know if there is any way out for this.

    Also wanted to know if there are any other cloud services available that could be used with this board(i.e TM4C129X). Basically, we want to grab a value from a sensor and upload it on a cloud server via the board.


    Again, any help would be greatly appreciated.

    Thanks & Regards
    Yash Bhan

  • I think a TM4C, and other Cortex M4, are representing the minimum of resources and performance for the kind of application(s) you think of.

    Having had a brief look at the ubidots C-API, basic HTTP is surely doable, choosing a proper TCP/IP stack. IMHO forget about HTTPS.

    I tried compiling the same on GCC and ARM compiler (through CCS). The code compiled successfully with GCC, but it failed for ARM compiler(CCS). Wanted to know if there is any way out for this.

    AFAIK, the CCS default toolchain is also GCC based (needing more than single-vendor support, I don't use CCS). It is probably helpful if you can post a log of the build errors here.

  • While compiling the code on CCS, i get the following error:

    **** Build of configuration Debug for project ubidots ****
    
    "C:\\ti\\ccsv5\\utils\\bin\\gmake" -k all 
    'Building file: ../ubidots.c'
    'Invoking: ARM Compiler'
    "C:/ti/ccsv5/tools/compiler/arm_5.0.4/bin/armcl" -mv7M4 --code_state=16 --float_support=FPv4SPD16 --abi=eabi -me -g --include_path="C:/ti/ccsv5/tools/compiler/arm_5.0.4/include" --include_path="F:/CCS_workspace/include" --diag_warning=225 --display_error_number --diag_wrap=off --preproc_with_compile --preproc_dependency="ubidots.pp"  "../ubidots.c"
    "F:\CCS_workspace\include\curl\curlbuild.h", line 122: fatal error #5: could not open source file "windows.h"
    1 fatal error detected in the compilation of "../ubidots.c".
    Compilation terminated.
    gmake: *** [ubidots.obj] Error 1
    
    >> Compilation failure
    'Building file: ../ubirequest.c'
    'Invoking: ARM Compiler'
    "C:/ti/ccsv5/tools/compiler/arm_5.0.4/bin/armcl" -mv7M4 --code_state=16 --float_support=FPv4SPD16 --abi=eabi -me -g --include_path="C:/ti/ccsv5/tools/compiler/arm_5.0.4/include" --include_path="F:/CCS_workspace/include" --diag_warning=225 --display_error_number --diag_wrap=off --preproc_with_compile --preproc_dependency="ubirequest.pp"  "../ubirequest.c"
    "F:\CCS_workspace\include\curl\curlbuild.h", line 122: fatal error #5: could not open source file "windows.h"
    
    1 fatal error detected in the compilation of "../ubirequest.c".
    >> Compilation failure
    Compilation terminated.
    gmake: *** [ubirequest.obj] Error 1
    gmake: Target `all' not remade because of errors.
    
    **** Build Finished ****
  • Im using the sample code available at the ubidots-c github repo.

    Code:

    /*
     * Ubidots C client.
     *
     * Copyright (c) 2013 Ubidots.
     */
    
    #include <stdlib.h>
    #include <string.h>
    #include <time.h>
    #include <curl/curl.h>
    #include <jansson.h>
    #include "ubidots.h"
    #include "ubirequest.c"
    
    /**
     * Save a value to Ubidots.
     * @arg client       Pointer to UbidotsClient
     * @arg variable_id  The ID of the variable to save to
     * @arg value        The value to save
     * @arg timestamp    Timestamp (millesconds since epoch). Pass TIMESTAMP_NOW
     *                   to have the timestamp automatically calculated.
     * @return Zero upon success, Non-zero upon error.
     */
    int ubidots_save_value(UbidotsClient *client, char *variable_id, double value, long long timestamp) {
      char url[80];
      char json_data[80];
    
      if (timestamp == TIMESTAMP_NOW)
        timestamp = (long long)time(NULL) * 1000;
    
      sprintf(url, "%s/variables/%s/values", client->base_url, variable_id);
      sprintf(json_data, "{\"value\": %g, \"timestamp\": %lld}", value, timestamp);
    
      return ubi_request("POST", url, client->token, json_data, NULL);
    }
    
    
    /**
     * Initialize a Ubidots session. This is most likely the first Ubidots
     * library function you will call.
     * @arg api_key  Your API key for the Ubidots API.
     * @return Upon success, a pointer to a UbidotsClient. Upon error, NULL.
     */
    UbidotsClient* ubidots_init(char *api_key) {
      return ubidots_init_with_base_url(api_key, DEFAULT_BASE_URL);
    }
    
    
    UbidotsClient* ubidots_init_with_base_url(char *api_key, char *base_url) {
      // Perform an API request to generate a new token for the given API key.
      char url[80];
      char token_hack[80];
      int rc;
      json_t *j_root, *j_token;
      
      sprintf(url, "%s/auth/token", base_url);
      sprintf(token_hack, "/%s", api_key);
      
      rc = ubi_request("POST", url, token_hack, "", &j_root);
      
      if (rc)
        return NULL;
      
      j_token = json_object_get(j_root, "token");
    
      // Allocate and set fields of struct
      UbidotsClient *client = malloc(sizeof(UbidotsClient));  
    
      strncpy(client->base_url, base_url, STRLEN_BASE_URL);
      strncpy(client->api_key, api_key, STRLEN_API_KEY);
      strncpy(client->token, json_string_value(j_token), STRLEN_TOKEN);
    
      json_decref(j_root);
    
      return client;
    }
    
    
    /**
     * End a ubidots session. After calling this function with UbidotsClient* client,
     * no more functions may be called with it.
     */
    void ubidots_cleanup(UbidotsClient *client) {
      free(client);
    }
    
    
    int main() {
    	char API_KEY[] = "4eab4440fe98e0eb5ab432691f80fbc3434b76f4";
    	char VARIABLE_ID[] = "57d7ba927625425b779a7340";
         UbidotsClient *client = ubidots_init(API_KEY);
    
         //while ( keepGoing() ) {
           double value = 10; //getValue();
           ubidots_save_value(client, VARIABLE_ID, value, TIMESTAMP_NOW);
         //}
      
         ubidots_cleanup(client);
    
         return 0;
       }
    
    

    I just want to send a value(10) to ubidots cloud server. while compiling with GCC, im not getting any error and the binary is getting generated succesfully, but when compiling with CCS, im getting errors as shown in the build error log above.

    Is there any sample program that demonstrates how to send data to Cloud (AWS /Ubidots) using REST api via the board.

    Thanks & Regards

    Yash Bhan 

  • I'm not much in IoT projects, for several reasons.

    "F:\CCS_workspace\include\curl\curlbuild.h", line 122: fatal error #5: could not open source file "windows.h"

    Well, there is no "windows.h" here for the TM4C, for obvious reasons.

    I think you need to get / make a "matching" build of the curl library, not one based on the Windows OS (or Linux). Or perhaps change the curl sources "in place".

    I'm afraid you won't find too much of this competence here in a "hardcore bare-metal" forum ...

  • Hello Yash,

    Unfortunately, I don't think we will be much help with the Udibot-C API.

    In regard to suggested cloud servers, the default application that comes with the TM4C129 connected launchpads and the crypto connected launchpads use Exosite cloud server. In fact, these default applications upload data from the internal temp sensor. It should be fairly easy to modify the code to use your sensor rather than the internal temp sensor. The quick start guide can give you details on how to set up an account which can be used for development. Commercial accounts may be a different story so you would want to reach out to Exosite to discuss use case specific support.
  • Hello Chuck

    Thank you for the reply. I will try setting up the board with the exosite cloud server. However, i don't have the default application("qs_iot") in the tivaware software which was bundled with the board, the said app is bundled with the board with model no: EK-TM4C1294XL, whereas, i have model DK-TM4C129X. Both the boards have the same MCU. Wanted to know if i could flash the default cloud application("qs_iot"), on this board(DK-TM4C129X)?

    Thanks & Regards
    Yash Bhan

  • Hello

    Thank you so much for the reply. Will try to find if there is a way to build the curl library for the appropriate platform(ARM).

    Thanks & Regards
    Yash Bhan
  • Hello Yash,

    I had missed which development board you were using. Sorry about that. 

    To use on the DK-Tm4C129 board, you may need to re-map some of the IO to use LEDs on the DK. Other than that, it should mostly work and, if nothing else give you a baseline for your own development showing how to interface with the Exosite cloud server. 

  • see my blog, for sample IoT project using EK-TM4C1294XL.

    - kel
  • Hello Chuck,

    Thank you for the reply.
    Was able to execute the qs-iot app on the DK-TM4C129X, as you said, had to re-map certain pins.
    Am able to connect to exosite via the board and upload data
    Thank you so much for the support!

    Thanks & Regards
    Yash Bhan
  • There is an example program AWS but for TI Simplelink WiFi CC3200 LP.

    processors.wiki.ti.com/.../AWS_IoT_Development

    - kel