5 Replies Latest reply on Jun 20, 2017 5:50 PM by msiemering RSS
    msiemering Newbie

    Arduino Uno with HDC1008-Sensor: Thingworx receives no data

    I have tried for many hours to send data from the Arduino with HDC1008-Sensor (Temperature, Humidity) but at last i dont get any further. I tried to adjust the Weather App with Arduino Uno Project. The Thing is a Generic Thing and the properties (Temp, Humid) are from type Number.


    I have created one Service:


    The adjusted Code for the Arduino:

    #include <HDC100X.h>
    #include <Wire.h>
    #include <SPI.h>
    #include <WiFi101.h>

    //How many values you will be pushing to ThingWorx
    #define propertyCount 2

    // Enter a MAC address and IP address for your controller below.
    // The IP address will be dependent on your local Network:

    char server[] = "";

    char ssid[] = "xxxxxx";          //  your network SSID (name)
    char pass[] = "xxxxxx";   // your network password
    int status = WL_IDLE_STATUS;
    WiFiClient client;

    //ThingWorx App key which replaces login credentials)
    char appKey[] = "d9e8e9de-f548-43e0-aeaa-2b9c6847c7dc";
    // ThingWorx Thing name for which you want to set properties values
    char thingName[] = "SteamSensor2";
    //Interval of time at which you want the properties values to be sent to TWX server
    int timeBetweenRefresh = 5000;
    // ThingWorx service that will set values for the properties you need
    // See the documentation for this tutorial for more information
    char serviceName[] = "SetTempAndHumid";

    //Initialize Properties Names and Values Arrays
    char* propertyNames[] = {"Temp", "Humid"};
    double propertyValues[propertyCount];

    // last time you connected to the server, in milliseconds
    unsigned long lastConnectionTime = 0;
    // state of the connection last time through the main loop
    boolean lastConnected = false;

    //Initialize an HTU21D library object to read
    // temperature and humidity data from your connected sensor
    HDC100X hdc(0x43);

    void setup() {
      // start serial port:
      while (!Serial) {
        ; // wait for serial port to connect. Needed for Leonardo only
      //initialize HTU21D object to read values from sensors

       Serial.println("Attempting to connect to WPA network...");
      Serial.print("SSID: ");

      status = WiFi.begin(ssid, pass);
      if ( status != WL_CONNECTED) {
        Serial.println("Couldn't get a wifi connection");
        // don't do anything else:
      else {
        Serial.println("Connected to wifi");
        Serial.println("\nStarting connection...");
        // if you get a connection, report back via serial:
        if (client.connect(server, 80)) {

    void loop() {

      // Aquire sensor values
      propertyValues[0] = hdc.getTemp();
      propertyValues[1] = hdc.getHumi();

      // wait the established interval of time before
      // reading values from the sensor
      // and sending them to the TWX server again
      // delay(timeBetweenRefresh);
      if (millis() - lastConnectionTime > timeBetweenRefresh) {
        updateValues(propertyValues, client, server, appKey, thingName, serviceName, propertyNames);

    void updateValues(double values[] , WiFiClient &client, char server[], char appKey[], char thingName[], char serviceName[], char* sensorNames[])
      //build the String with the data that you will send
      //through REST calls to your TWX server
      char data[80];
      strcpy(data, "?appKey=");
      strcat(data, appKey);
      strcat(data, "&method=post&x-thingworx-session=true");
      // if you get a connection, report back via serial:
      if (client.connected()) {
        // send the HTTP POST request:
        client.print("POST /Thingworx/Things/");
        for (int idx = 0; idx < propertyCount; idx++)
        client.println(" HTTP/1.1");
        client.print("Host: ");
        client.println("Content-Type: text/html");

        lastConnectionTime = millis();
        // print the request out
        Serial.print("POST /Thingworx/Things/");
        for (int idx = 0; idx < propertyCount; idx++)
        Serial.println(" HTTP/1.1");
        Serial.print("Host: ");
        Serial.println("Content-Type: text/html");

      else {
        // kf you didn't get a connection to the server:
        Serial.println("the connection could not be established");



    The generated Serial-Output:

    Attempting to connect to WPA network...
    SSID: xxxx
    Connected to wifi

    Starting connection...
    POST /Thingworx/Things/SteamSensor2/Services/SetTempAndHumid?appKey=d9e8e9de-f548-43e0-aeaa-2b9c6847c7dc&method=post&x-thingworx-session=true<&Temp=24.45&Humid=32.41> HTTP/1.1
    Content-Type: text/html


    And I tried the HTTP-Request Manual what ended up like this:




    I think that the Arduino has established a Connection to my local ThingWorx Server, but I have not found any proof for this like a log-file.


    Because of the "Unable To Convert From Java.lang.String to NUMBER"-Advice I changed the Base-Type of the Properties to String, but the message was still the same.

    Next I added to the Service "parseFloat", but there is still the same Problem.

      • Re: Arduino Uno with HDC1008-Sensor: Thingworx receives no data
        supandey Collaborator

        Marius, first thing would be to check for the Thing's (from which you have shared the screenshot above) isConnected property once connected you'll see following highlighted value changed to true


        Otherwise you can also navigate to the \\ThingworxStorage\logs and check for the applicationlog.log  the other option would be to check from the ThingWorx > Composer > Monitoring > RemoteThings

          • Re: Arduino Uno with HDC1008-Sensor: Thingworx receives no data
            msiemering Newbie

            Excuse me for my late reaction.


            I have a "Generic Thing" (described in the Tutorial) so I do not have the isConected Property and can not see the Thing in Monitoring->Remote Things.


            The Application Log Shows the same error as described at the top of this discussion ("Unable To Convert..."):

            BoundConnectedThings= 0, UnBoundConnectedThings= 0

            2017-06-01 02:55:16.952+0200 [L: ERROR] [O: c.t.w.BaseService] [I: ] [U: Administrator] [S: ] [T: http-nio-80-exec-6] [context: com.thingworx.webservices.context.HttpExecutionContext@45945dd9][message: Unable To Convert From java.lang.String to NUMBER]
            2017-06-01 02:55:18.393+0200 [L: ERROR] [O: c.t.w.BaseService] [I: ] [U: Administrator] [S: ] [T: http-nio-80-exec-2] [context: com.thingworx.webservices.context.HttpExecutionContext@2fd149e][message: Unable To Convert From java.lang.String to NUMBER]
            2017-06-01 02:55:18.896+0200 [L: ERROR] [O: c.t.w.BaseService] [I: ] [U: Administrator] [S: ] [T: http-nio-80-exec-1] [context: com.thingworx.webservices.context.HttpExecutionContext@305c76f1][message: Unable To Convert From java.lang.String to NUMBER]
            2017-06-01 02:55:19.079+0200 [L: ERROR] [O: c.t.w.BaseService] [I: ] [U: Administrator] [S: ] [T: http-nio-80-exec-7] [context: com.thingworx.webservices.context.HttpExecutionContext@645bf386][message: Unable To Convert From java.lang.String to NUMBER]
            2017-06-01 02:55:19.289+0200 [L: ERROR] [O: c.t.w.BaseService] [I: ] [U: Administrator] [S: ] [T: http-nio-80-exec-8] [context: com.thingworx.webservices.context.HttpExecutionContext@461806f5][message: Unable To Convert From java.lang.String to NUMBER]
            2017-06-01 02:59:41.911+0200 [L: ERROR] [O: c.t.w.BaseService] [I: ] [U: Administrator] [S: ] [T: http-nio-80-exec-6] [context: com.thingworx.webservices.context.HttpExecutionContext@2f5bca3e][message: Unable To Convert From java.lang.String to NUMBER]
            2017-06-01 02:59:43.927+0200 [L: ERROR] [O: c.t.w.BaseService] [I: ] [U: Administrator] [S: ] [T: http-nio-80-exec-2] [context: com.thingworx.webservices.context.HttpExecutionContext@746997df][message: Unable To Convert From java.lang.String to NUMBER]
            2017-06-01 02:59:44.847+0200 [L: ERROR] [O: c.t.w.BaseService] [I: ] [U: Administrator] [S: ] [T: http-nio-80-exec-9] [context: com.thingworx.webservices.context.HttpExecutionContext@50d76f0f][message: Unable To Convert From java.lang.String to NUMBER]
            2017-06-01 03:19:47.065+0200 [L: WARN] [O: c.t.s.s.p.PlatformSubsystem] [I: ] [U: SuperUser] [S: ] [T: pool-6-thread-1]  Thingworx System Metrics

              • Re: Arduino Uno with HDC1008-Sensor: Thingworx receives no data
                supandey Collaborator

                When connecting your VirtualThing (which is running via your Arduino) you'd need a corresponding Thing created out of RemoteThing Template in ThingWorx Composer which will have required properties to bind and get data from Arduino. So I think instead of creating a Thing with GenericThing Template you should create one which is of type RemoteThing template. With remote thing you can see the property whether or not it's connected.


                However since you appear to be not using any ThingWorx EDGE SDK, and rather just attempting to send the data over you may not see isConnected property as true. But you will see values being updated once there's successful connection.


                There has been quite a few discussions around this you can try checking Arduino REST call Example ThingWorx and also DeliveringArduinoDataToThingworx.pdf if you haven't already.

                  • Re: Arduino Uno with HDC1008-Sensor: Thingworx receives no data
                    msiemering Newbie

                    The discussion you have linked (Arduino REST call Example ThingWorx) was my starting point. I adjusted the code to be able to connect with WiFi.


                    I tried the code I have posted at the top with a Remote Thing and ThingWorx got data (Property Values) but only once in 10 tries. So there ist no constant connection and also I can not find any proof in log files that the data was received.

                    But I have a theoretically question: Would it be possible to change the the value of the "lastConnection" Property manually through the code?

                    Tomorrow I will work on the linked PDF-File. My aim is to send constantly data to ThingWorx.



                    • Re: Arduino Uno with HDC1008-Sensor: Thingworx receives no data
                      msiemering Newbie

                      While trying to do the tutorial out of your pdf file the actual problem is "terminated compilation" because of "no such file or directory" of "SRAM.h"