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[] = "192.168.2.105";
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:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
//initialize HTU21D object to read values from sensors
hdc.begin(HDC100X_TEMP_HUMI,HDC100X_14BIT,HDC100X_14BIT,DISABLE);
Serial.println("Attempting to connect to WPA network...");
Serial.print("SSID: ");
Serial.println(ssid);
status = WiFi.begin(ssid, pass);
if ( status != WL_CONNECTED) {
Serial.println("Couldn't get a wifi connection");
// don't do anything else:
while(true);
}
else {
Serial.println("Connected to wifi");
Serial.println("\nStarting connection...");
// if you get a connection, report back via serial:
if (client.connect(server, 80)) {
Serial.println("connected1");
}
}
}
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()) {
Serial.println("connected2");
// send the HTTP POST request:
client.print("POST /Thingworx/Things/");
client.print(thingName);
client.print("/Services/");
client.print(serviceName);
client.print(data);
client.print("<");
for (int idx = 0; idx < propertyCount; idx++)
{
client.print("&");
client.print(propertyNames[idx]);
client.print("=");
client.print(propertyValues[idx]);
}
client.print(">");
client.println(" HTTP/1.1");
client.print("Host: ");
client.println(server);
client.println("Content-Type: text/html");
client.println();
//client.stop();
lastConnectionTime = millis();
// print the request out
Serial.print("POST /Thingworx/Things/");
Serial.print(thingName);
Serial.print("/Services/");
Serial.print(serviceName);
Serial.print(data);
Serial.print("<");
for (int idx = 0; idx < propertyCount; idx++)
{
Serial.print("&");
Serial.print(propertyNames[idx]);
Serial.print("=");
Serial.print(propertyValues[idx]);
}
Serial.print(">");
Serial.println(" HTTP/1.1");
Serial.print("Host: ");
Serial.println(server);
Serial.println("Content-Type: text/html");
Serial.println();
}
else {
// kf you didn't get a connection to the server:
Serial.println("the connection could not be established");
client.stop();
}
}
The generated Serial-Output:
Attempting to connect to WPA network...
SSID: xxxx
Connected to wifi
Starting connection...
connected1
connected2
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
Host: 192.168.2.105
Content-Type: text/html
And I tried the HTTP-Request Manual what ended up like this:

for: http://192.168.2.105/Thingworx/Things/SteamSensor2/Services/SetTempAndHumid?appKey=d9e8e9de-f548-43e0-aeaa-2b9c6847c7dc&method=post&x-thingworx-session=true<&Temp=24.40&Humid=32.21>
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.

