BNO005 Orientation data to Mqtt on huzzah feather

I am having an issue publishing some sensor data from a true orientation sensor to and MQTT topic
The hardware I am using is a Huzzah Feather running the Arduino ide and a BNO055, both of which are from Adafruit.

I managed to get Temperature and humidity data from a DHT22 to publish from the feather to the following topics DHT/temp and DHT/hum by creating the following script.

#include "DHT.h"
#include <PubSubClient.h>
#include <ESP8266WiFi.h>

#define WIFI_AP "EE-Hub-FwT6"
#define WIFI_PASSWORD "MAPS-set-valid"

#define TOKEN "ESP8266_DEMO_TOKEN"

// DHT
#define DHTPIN 2
#define DHTTYPE DHT22

char thingsboardServer[] = "192.168.1.106";

WiFiClient wifiClient;

// Initialize DHT sensor.
DHT dht(DHTPIN, DHTTYPE);

PubSubClient client(wifiClient);

int status = WL_IDLE_STATUS;
unsigned long lastSend;

void setup()
{
Serial.begin(115200);
dht.begin();
delay(10);
InitWiFi();
client.setServer( thingsboardServer, 1883 );
lastSend = 0;
}

void loop()
{
if ( !client.connected() ) {
reconnect();
}

if ( millis() - lastSend > 1000 ) { // Update and send only after 1 seconds
getAndSendTemperatureAndHumidityData();
lastSend = millis();
}

client.loop();
}

void getAndSendTemperatureAndHumidityData()
{
Serial.println("Collecting temperature data.");

// Reading temperature or humidity takes about 250 milliseconds!
float h = dht.readHumidity();
// Read temperature as Celsius (the default)
float t = dht.readTemperature();

// Check if any reads failed and exit early (to try again).
if (isnan(h) || isnan(t)) {
Serial.println("Failed to read from DHT sensor!");
return;
}

Serial.print("Humidity: ");
Serial.print(h);
Serial.print(" %\t");
Serial.print("Temperature: ");
Serial.print(t);
Serial.print(" *C ");

String temperature = String(t);
String humidity = String(h);

// Just debug messages
Serial.print( "Sending temperature and humidity : [" );
Serial.print( temperature ); Serial.print( "," );
Serial.print( humidity );
Serial.print( "] -> " );

// Prepare a JSON payload string
String payload1 = temperature;
String payload2 = humidity;

// Send payload
char temp[100];
payload1.toCharArray( temp, 100 );
client.publish("DHT22/temp", temp );
Serial.println(temp);
char hum[100];
payload2.toCharArray( hum, 100);
client.publish("DHT22/hum", hum);
Serial.println(hum);

}

void InitWiFi()
{
Serial.println("Connecting to AP ...");
// attempt to connect to WiFi network

WiFi.begin(WIFI_AP, WIFI_PASSWORD);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("Connected to AP");
}

void reconnect() {
// Loop until we're reconnected
while (!client.connected()) {
status = WiFi.status();
if ( status != WL_CONNECTED) {
WiFi.begin(WIFI_AP, WIFI_PASSWORD);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("Connected to AP");
}
Serial.print("Connecting to ThingsBoard node ...");
// Attempt to connect (clientId, username, password)
if ( client.connect("ESP8266 Device", TOKEN, NULL) ) {
Serial.println( "[DONE]" );
} else {
Serial.print( "[FAILED] [ rc = " );
Serial.print( client.state() );
Serial.println( " : retrying in 5 seconds]" );
// Wait 5 seconds before retrying
delay( 5000 );
}
}
}

This code works fine and I am able to pass the payload to an MQTT node in node red and apply the conditional logic I need for my project….

HOWEVER
When I try to splice the “Create a JSON payload” statement and the client.publish lines with the Raw Data sketch for the bno055 get errors regarding data types.
I have included the BNO055 sketch below unmodified. Could someone help please.

BNO055 rawdata sketch unmodified

#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BNO055.h>
#include <utility/imumaths.h>

/* This driver reads raw data from the BNO055

Connections

Connect SCL to analog 5
Connect SDA to analog 4
Connect VDD to 3.3V DC
Connect GROUND to common ground

History

2015/MAR/03 - First release (KTOWN)
*/

/* Set the delay between fresh samples */
#define BNO055_SAMPLERATE_DELAY_MS (100)

Adafruit_BNO055 bno = Adafruit_BNO055();

//
/*
Arduino setup function (automatically called at startup)
*/
/
/
void setup(void)
{
Serial.begin(9600);
Serial.println("Orientation Sensor Raw Data Test"); Serial.println("");

/* Initialise the sensor /
if(!bno.begin())
{
/
There was a problem detecting the BNO055 ... check your connections */
Serial.print("Ooops, no BNO055 detected ... Check your wiring or I2C ADDR!");
while(1);
}

delay(1000);

/* Display the current temperature */
int8_t temp = bno.getTemp();
Serial.print("Current Temperature: ");
Serial.print(temp);
Serial.println(" C");
Serial.println("");

bno.setExtCrystalUse(true);

Serial.println("Calibration status values: 0=uncalibrated, 3=fully calibrated");
}

//
/*
Arduino loop function, called once 'setup' is complete (your own code
should go here)
*/
/
/
void loop(void)
{
// Possible vector values can be:
// - VECTOR_ACCELEROMETER - m/s^2
// - VECTOR_MAGNETOMETER - uT
// - VECTOR_GYROSCOPE - rad/s
// - VECTOR_EULER - degrees
// - VECTOR_LINEARACCEL - m/s^2
// - VECTOR_GRAVITY - m/s^2
imu::Vector<3> euler = bno.getVector(Adafruit_BNO055::VECTOR_EULER);

/* Display the floating point data */
Serial.print("X: ");
Serial.print(euler.x());
Serial.print(" Y: ");
Serial.print(euler.y());
Serial.print(" Z: ");
Serial.print(euler.z());
Serial.print("\t\t");

/*
// Quaternion data
imu::Quaternion quat = bno.getQuat();
Serial.print("qW: ");
Serial.print(quat.w(), 4);
Serial.print(" qX: ");
Serial.print(quat.x(), 4);
Serial.print(" qY: ");
Serial.print(quat.y(), 4);
Serial.print(" qZ: ");
Serial.print(quat.z(), 4);
Serial.print("\t\t");
*/

/* Display calibration status for each sensor. */
uint8_t system, gyro, accel, mag = 0;
bno.getCalibration(&system, &gyro, &accel, &mag);
Serial.print("CALIBRATION: Sys=");
Serial.print(system, DEC);
Serial.print(" Gyro=");
Serial.print(gyro, DEC);
Serial.print(" Accel=");
Serial.print(accel, DEC);
Serial.print(" Mag=");
Serial.println(mag, DEC);

delay(BNO055_SAMPLERATE_DELAY_MS);
}

Many Thanks

I found the solution. If your having issues try this

String payload1(euler.x());
String payload2(euler.y());
String payload3(euler.z());

char x[100];
payload1.toCharArray( x, 100);
client.publish("ORI/x", x);

char y[100];
payload2.toCharArray( y, 100);
client.publish("ORI/y", y);

char z[100];
payload2.toCharArray( z, 100);
client.publish("ORI/z", z);

probably a long shot as it has been awhile, but can you explain this a bit more?