Showing results for 
Search instead for 
Did you mean: 
Showing results for 
Search instead for 
Did you mean: 

Unable to connect remote thing to thingworkx

Level 1

Unable to connect remote thing to thingworkx

I'm trying to connect my Intel Galileo Gen 2 board to thingworkx. I'm following the tutorial  Weather Application with Intel Galileo | ThingWorx  . In the example, they have used the HTU21D sensor . As it wasn't available where I live, I'm performing the tutorial  using  a BMP180 sensor. I'm using it to sense temperature and pressure.

I have modified the code given for HTU21D , as follow for BMP180:

Note: For security reasons in have modified my API KEY and MAC address.

include <twApi.h>

#include <twLogger.h>

#include <twOSPort.h>

#include <SFE_BMP180.h>

#include <Ethernet.h>

#include <stdio.h>

#include <string.h>

#include <Wire.h>

SFE_BMP180 tp;

/* Mac address of the network adapter */

byte mac[] = {0x98, 0x4F, 0xEE, 0x01, 0xCB, 0xE9  };

/* Name of your thing */

char * thingName = "myTestTempPress";

/* IP/hostname of your TWX server */

char * serverName = "";

/* port */

int port = 443;

/* API key */

char * apiKey = "d9c81d35-5a28-49b0-9ddf-e9193eda3b66";

/* refresh rate */

int timeBetweenRefresh = 1000;

/* Hold all the properties */

struct  {

  double Temperature;

  double Pressure;



  void sendPropertyUpdate() {

  /* Create the property list */

propertyList * proplist = twApi_CreatePropertyList("Temperature",twPrimitive_CreateFromNumber(properties.Temperature), 0);

  if (!proplist) {

  TW_LOG(TW_ERROR,"sendPropertyUpdate: Error allocating property list");



  twApi_AddPropertyToList(proplist,"Pressure",twPrimitive_CreateFromNumber(properties.Pressure), 0);

  twApi_PushProperties(TW_THING, thingName, proplist, -1, FALSE);



void dataCollectionTask()


  char status;

  status = tp.startTemperature();

  status = tp.getTemperature(properties.Temperature);

  status = tp.startPressure(3);

  status = tp.getPressure(properties.Pressure, properties.Temperature);



  Serial.print(" Temperature:");

  Serial.print(properties.Temperature, 1);


  Serial.print(" Pressure:");

  Serial.print(properties.Pressure, 1);



  /* Update the properties on the server */




* Property Handler Callbacks


enum msgCodeEnum propertyHandler(const char * entityName, const char * propertyName,  twInfoTable ** value, char isWrite, void * userdata) {

  char * asterisk = "*";

  if (!propertyName) propertyName = asterisk;

  TW_LOG(TW_TRACE,"propertyHandler - Function called for Entity %s, Property %s", entityName, propertyName);

  if (value) {

      /* Property Reads */

      if (strcmp(propertyName, "Temperature") == 0) *value = twInfoTable_CreateFromNumber(propertyName, properties.Temperature);

      else if (strcmp(propertyName, "Pressure") == 0) *value = twInfoTable_CreateFromNumber(propertyName, properties.Pressure);  

      else return TWX_NOT_FOUND;

    return TWX_SUCCESS;


  else {

    TW_LOG(TW_ERROR,"propertyHandler - NULL pointer for value");

    return TWX_BAD_REQUEST;



void setup() {

  int err=0;

  /* Open serial connection */


  /* Wait for someone to launch the console */


  /* Setup the ethernet connection */

  Serial.println("Attempting to start Ethernet2");

  if (Ethernet.begin(mac) == 0) {

    Serial.println("Failed to configure Ethernet using DHCP");


  else {

    Serial.println("Sucess getting dhcp address");


  /* start adapter */

  system("ifup eth0");

  /* wait for it to start */


  Serial.print("Galileo IP address: ");


  system("telnetd -l /bin/sh");

  Serial.println("BMP180 Example!");


  Serial.print("Initialize TWX: ");

  err = twApi_Initialize(serverName, port, TW_URI, apiKey, NULL, MESSAGE_CHUNK_SIZE, MESSAGE_CHUNK_SIZE, TRUE);

  if (err) {

    Serial.println("Error initializing the API");


  /* Allow self signed certs */


  /* Regsiter our properties */

   twApi_RegisterProperty(TW_THING, thingName, "Temperature", TW_NUMBER, NULL, "ALWAYS", 0, propertyHandler,NULL);

   twApi_RegisterProperty(TW_THING, thingName, "Pressure", TW_NUMBER, NULL, "ALWAYS", 0, propertyHandler,NULL);

  /* Bind our thing */


  /* Connect to server */


    Serial.println("sucessefully connected to TWX!");



void loop() {

  // put your main code here, to run repeatedly:





Every time when I burn the code to my board  the serial monitor waits for a while after printing "Initialize TWX:" and then start printing the temperature and pressure 0 without giving any information regarding the connection! ( In tutorial they have shown a message"successfully connected to TWX!"  when device is connected ) I have attached the screenshot of Serial Monitor and the original as well as modified code .

Please let me know where I'm going wrong  and quick response to this issue will be really appreciated as I have to give a demo to my fellow classmates on the day after tomorrow on IOT and ThingWorx.