help ccs811 posting values to mqtt

hi i tried to make a code to send the values of the ccs811/bme280 sensor from sparkfun but i am always getting an error when trying to compile it can you please check my code and see what i have done wrong ?
thanks i advance for every help

#include <SparkFunBME280.h>
#include <SparkFunCCS811.h>
#include <ESP8266WiFi.h>
#include <PubSubClient.h>

#define CCS811_ADDR 0x5B //Default I2C Address
//#define CCS811_ADDR 0x5A //Alternate I2C Address

#define PIN_NOT_WAKE 5

//Global sensor objects
CCS811 myCCS811(CCS811_ADDR);
BME280 myBME280;

// Connect to the WiFi
const char* ssid = "*********";
const char* password = "*******!";
const char* mqtt_server = "192.168.1.177";

WiFiClient espClient;
PubSubClient client(espClient);

boolean reconnect() {  // **********************************************************

  // Loop until we're reconnected
  while (!client.connected()) {
    Serial.print (F("Contacting MQTT server..."));
    // Attempt to connect
    if (client.connect("E_C_G","username", "password")) {     //assign a "client name".  Each wemos must have a unique name
      Serial.println (F("connected"));

      // ... SUBSCRIBE TO TOPICS
      //      client.subscribe("Upstairs/Mbr/BME280/TempF");
      //      client.subscribe("Upstairs/Mbr/BME280/TempC");
      //      client.subscribe("Upstairs/Mbr/BME280/Humidity");
      //      client.subscribe("Upstairs/Mbr/BME280/Pressure");

      return client.connected();

      Serial.print (F("Failed to connect. "));
      Serial.println (F(" Attempting connection again in 3 seconds"));
      // Wait 3 seconds before retrying
      //      delay(3000);
      return 0;
    }
  }
}

void setup(){
{
  {
    Serial.begin(9600);
    client.setServer(mqtt_server, 1883);
  }
    // Connect to WiFinetwork
  Serial.println();
  Serial.println();
  Serial.print (F("Connecting to "));
  Serial.println(ssid);

  WiFi.begin(ssid, password);
  WiFi.mode(WIFI_STA);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    //Serial.begin(9600);
    Serial.print (F("."));
  }
  Serial.println (F(""));
  Serial.println (F("WiFi connected"));
  // Print the IP address
  Serial.print (F("Local IP: "));
  Serial.println(WiFi.localIP());
}
    //  *********************************************************************************

  
{  Serial.println();
  Serial.println("Apply BME280 data to CCS811 for compensation.");

  //This begins the CCS811 sensor and prints error status of .begin()
  CCS811Core::status returnCode = myCCS811.begin();
  Serial.print("CCS811 begin exited with: ");
  //Pass the error code to a function to print the results
  printDriverError( returnCode );
  Serial.println();

  //For I2C, enable the following and disable the SPI section
  myBME280.settings.commInterface = I2C_MODE;
  myBME280.settings.I2CAddress = 0x77;

  //Initialize BME280
  //For I2C, enable the following and disable the SPI section
  myBME280.settings.commInterface = I2C_MODE;
  myBME280.settings.I2CAddress = 0x77;
  myBME280.settings.runMode = 3; //Normal mode
  myBME280.settings.tStandby = 0;
  myBME280.settings.filter = 4;
  myBME280.settings.tempOverSample = 5;
  myBME280.settings.pressOverSample = 5;
  myBME280.settings.humidOverSample = 5;

  //Calling .begin() causes the settings to be loaded
  delay(10);  //Make sure sensor had enough time to turn on. BME280 requires 2ms to start up.
  myBME280.begin();


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

{
  //Check to see if data is available
  if (myCCS811.dataAvailable())
  {
    //Calling this function updates the global tVOC and eCO2 variables
    myCCS811.readAlgorithmResults();
    //printInfoSerial fetches the values of tVOC and eCO2
    printInfoSerial();

    float BMEtempC = myBME280.readTempC();
    float BMEhumid = myBME280.readFloatHumidity();

    Serial.print("Applying new values (deg C, %): ");
    Serial.print(BMEtempC);
    Serial.print(",");
    Serial.println(BMEhumid);
    Serial.println();

    //This sends the temperature data to the CCS811
    myCCS811.setEnvironmentalData(BMEhumid, BMEtempC);
  }
  else if (myCCS811.checkForStatusError())
  {
    //If the CCS811 found an internal error, print it.
    printSensorError();
  }

  delay(2000); //Wait for next reading
}

//---------------------------------------------------------------
void printInfoSerial()
{
  //getCO2() gets the previously read data from the library
  
  Serial.println("CCS811 data:");
  Serial.print(" CO2 concentration : ");
  Serial.print(myCCS811.getCO2());
  Serial.println(" ppm");
  client.publish("enviroment/sensor/E_C_G/CO2", (myCCS811.getCO2()))

  //getTVOC() gets the previously read data from the library
  Serial.print(" TVOC concentration : ");
  Serial.print(myCCS811.getTVOC());
  Serial.println(" ppb");
  client.publish("enviroment/sensor/E_C_G/TVOC_ppb", (myCCS811.getTVOC()));

  Serial.println("BME280 data:");
  Serial.print(" Temperature: ");
  Serial.print(myBME280.readTempC(), 2);
  Serial.println(" degrees C");
  client.publish("enviroment/sensor/E_C_G/TempC",(myBME280.readTempC(), 2));

  Serial.print(" Temperature: ");
  Serial.print(myBME280.readTempF(), 2);
  Serial.println(" degrees F");
  client.publish("enviroment/sensor/E_C_G/TempF", (buffermyBME280.readTempF(), 2));
  
  Serial.print(" Pressure: ");
  Serial.print(myBME280.readFloatPressure(), 2);
  Serial.println(" Pa");
  client.publish("enviroment/sensor/E_C_G/Pressure_Pa", (myBME280.readFloatPressure(), 2));

  Serial.print(" Pressure: ");
  Serial.print((myBME280.readFloatPressure() * 0.0002953), 2);
  Serial.println(" InHg");
  client.publish("enviroment/sensor/E_C_G/Pressure_InHg",(myBME280.readFloatPressure() * 0.0002953), 2));
  
  Serial.print(" Altitude: ");
  Serial.print(myBME280.readFloatAltitudeMeters(), 2);
  Serial.println("m");
  client.publish("enviroment/sensor/E_C_G/AltitudeMeters",(myBME280.readFloatAltitudeMeters(), 2));
  
  Serial.print(" Altitude: ");
  Serial.print(myBME280.readFloatAltitudeFeet(), 2);
  Serial.println("ft");
  
  Serial.print(" %RH: ");
  Serial.print(myBME280.readFloatHumidity(), 2);
  Serial.println(" %");
  client.publish("enviroment/sensor/E_C_G/Humidity",(myBME280.readFloatHumidity(), 2));
  
  Serial.println();


}

//printDriverError decodes the CCS811Core::status type and prints the
//type of error to the serial terminal.
//
//Save the return value of any function of type CCS811Core::status, then pass
//to this function to see what the output was.
void printDriverError( CCS811Core::status errorCode )
{
  switch ( errorCode )
  {
    case CCS811Core::SENSOR_SUCCESS:
      Serial.print("SUCCESS");
      break;
    case CCS811Core::SENSOR_ID_ERROR:
      Serial.print("ID_ERROR");
      break;
    case CCS811Core::SENSOR_I2C_ERROR:
      Serial.print("I2C_ERROR");
      break;
    case CCS811Core::SENSOR_INTERNAL_ERROR:
      Serial.print("INTERNAL_ERROR");
      break;
    case CCS811Core::SENSOR_GENERIC_ERROR:
      Serial.print("GENERIC_ERROR");
      break;
    default:
      Serial.print("Unspecified error.");
  }
}

//printSensorError gets, clears, then prints the errors
//saved within the error register.
void printSensorError()
{
  uint8_t error = myCCS811.getErrorRegister();

  if ( error == 0xFF ) //comm error
  {
    Serial.println("Failed to get ERROR_ID register.");
  }
  else
  {
    Serial.print("Error: ");
    if (error & 1 << 5) Serial.print("HeaterSupply");
    if (error & 1 << 4) Serial.print("HeaterFault");
    if (error & 1 << 3) Serial.print("MaxResistance");
    if (error & 1 << 2) Serial.print("MeasModeInvalid");
    if (error & 1 << 1) Serial.print("ReadRegInvalid");
    if (error & 1 << 0) Serial.print("MsgInvalid");
    Serial.println();
  }
}

i tried compile it and i get this error now

C:\Users\Chris\Documents\Arduino\Enviroment_Gym_Control\Enviroment_Gym_Control\Enviroment_Gym_Control.ino: In function 'void setup()':

Enviroment_Gym_Control:116: error: 'printDriverError' was not declared in this scope

printDriverError( returnCode );

^

C:\Users\Chris\Documents\Arduino\Enviroment_Gym_Control\Enviroment_Gym_Control\Enviroment_Gym_Control.ino: In function 'void loop()':

Enviroment_Gym_Control:154: error: 'printInfoSerial' was not declared in this scope

printInfoSerial();

^

Enviroment_Gym_Control:171: error: 'printSensorError' was not declared in this scope

printSensorError();

^

Enviroment_Gym_Control:179: error: a function-definition is not allowed here before '{' token

{

^

Enviroment_Gym_Control:240: error: a function-definition is not allowed here before '{' token

{

^

Enviroment_Gym_Control:284: error: expected '}' at end of input

}

^

exit status 1
'printDriverError' was not declared in this scope

you appear to have an unmatched { in loop()

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

//{    << try commenting this { out

ok so here is the fixed code i managed to have everything working exept i cant get the actual values published cause i get this error so i had to put "" to all stop the errors but this is not what i want
can you please help me with this

 In function 'void printInfoSerial()':

Enviroment_Gym_Control:184: error: invalid conversion from 'uint16_t {aka short unsigned int}' to 'const char*' [-fpermissive]

   client.publish("enviroment/sensor/group1/CO2", (myCCS811.getCO2()));


C:\Users\Chris\Documents\Arduino\libraries\pubsubclient\src/PubSubClient.h:130:12: error:   initializing argument 2 of 'boolean PubSubClient::publish(const char*, const char*)' [-fpermissive]

    boolean publish(const char* topic, const char* payload);

            ^

exit status 1
invalid conversion from 'uint16_t {aka short unsigned int}' to 'const char*' [-fpermissive]
******************************************************************************/
#include <SparkFunBME280.h>
#include <SparkFunCCS811.h>
#include <ESP8266WiFi.h>
#include <PubSubClient.h>

#define CCS811_ADDR 0x5B //Default I2C Address
//#define CCS811_ADDR 0x5A //Alternate I2C Address

#define PIN_NOT_WAKE 5

//Global sensor objects
CCS811 myCCS811(CCS811_ADDR);
BME280 myBME280;

// Connect to the WiFi
const char* ssid = "@@@@@";
const char* password = "@@@@@";
const char* mqtt_server = "192.168.1.177";

WiFiClient espClient;
PubSubClient client(espClient);

boolean reconnect() {// Loop until we're reconnected
  while (!client.connected()) {
    Serial.print (F("Contacting MQTT server..."));
    // Attempt to connect
    if (client.connect("group1","@@@@","@@@@@")) {     //assign a "client name".  Each wemos must have a unique name
      Serial.println (F("connected"));

      // ... SUBSCRIBE TO TOPICS
      //      client.subscribe("Upstairs/Mbr/BME280/TempF");
      //      client.subscribe("Upstairs/Mbr/BME280/TempC");
      //      client.subscribe("Upstairs/Mbr/BME280/Humidity");
      //      client.subscribe("Upstairs/Mbr/BME280/Pressure");

      return client.connected();

      Serial.print (F("Failed to connect. "));
      Serial.println (F(" Attempting connection again in 3 seconds"));
      // Wait 3 seconds before retrying
      //      delay(3000);
      return 0;
    }
  }
}

void setup(){
{
  {
    Serial.begin(9600);
    client.setServer(mqtt_server, 1883);
  }
    // Connect to WiFinetwork
  Serial.println();
  Serial.println();
  Serial.print (F("Connecting to "));
  Serial.println(ssid);

  WiFi.begin(ssid, password);
  WiFi.mode(WIFI_STA);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    //Serial.begin(9600);
    Serial.print (F("."));
  }
  Serial.println (F(""));
  Serial.println (F("WiFi connected"));
  // Print the IP address
  Serial.print (F("Local IP: "));
  Serial.println(WiFi.localIP());
}
    //  *********************************************************************************

  
{  Serial.println();
  Serial.println("Apply BME280 data to CCS811 for compensation.");

  //This begins the CCS811 sensor and prints error status of .begin()
  CCS811Core::status returnCode = myCCS811.begin();
  Serial.print("CCS811 begin exited with: ");
  //Pass the error code to a function to print the results
  printDriverError( returnCode );
  Serial.println();

  //For I2C, enable the following and disable the SPI section
  myBME280.settings.commInterface = I2C_MODE;
  myBME280.settings.I2CAddress = 0x77;

  //Initialize BME280
  //For I2C, enable the following and disable the SPI section
  myBME280.settings.commInterface = I2C_MODE;
  myBME280.settings.I2CAddress = 0x77;
  myBME280.settings.runMode = 3; //Normal mode
  myBME280.settings.tStandby = 0;
  myBME280.settings.filter = 4;
  myBME280.settings.tempOverSample = 5;
  myBME280.settings.pressOverSample = 5;
  myBME280.settings.humidOverSample = 5;

  //Calling .begin() causes the settings to be loaded
  delay(10);  //Make sure sensor had enough time to turn on. BME280 requires 2ms to start up.
  myBME280.begin();


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

//{
  //Check to see if data is available
  if (myCCS811.dataAvailable())
  {
    //Calling this function updates the global tVOC and eCO2 variables
    myCCS811.readAlgorithmResults();
    //printInfoSerial fetches the values of tVOC and eCO2
    printInfoSerial();

    float BMEtempC = myBME280.readTempC();
    float BMEhumid = myBME280.readFloatHumidity();

    Serial.print("Applying new values (deg C, %): ");
    Serial.print(BMEtempC);
    Serial.print(",");
    Serial.println(BMEhumid);
    Serial.println();

    //This sends the temperature data to the CCS811
    myCCS811.setEnvironmentalData(BMEhumid, BMEtempC);
  }
  else if (myCCS811.checkForStatusError())
  {
    //If the CCS811 found an internal error, print it.
    printSensorError();
  }

  delay(30000); //Wait for next reading
}

//---------------------------------------------------------------
void printInfoSerial()
{
  //getCO2() gets the previously read data from the library
  
  Serial.println("CCS811 data:");
  Serial.print(" CO2 concentration : ");
  Serial.print(myCCS811.getCO2());
  Serial.println(" ppm");
  client.publish("enviroment/sensor/group1/CO2", (myCCS811.getCO2()));

  //getTVOC() gets the previously read data from the library
  Serial.print(" TVOC concentration : ");
  Serial.print(myCCS811.getTVOC());
  Serial.println(" ppb");
  client.publish("enviroment/sensor/group1/TVOC_ppb", "o");

  Serial.println("BME280 data:");
  Serial.print(" Temperature: ");
  Serial.print(myBME280.readTempC(), 2);
  Serial.println(" degrees C");
  client.publish("enviroment/sensor/group1/TempC","(myBME280.readTempC(), 2)");

  Serial.print(" Temperature: ");
  Serial.print(myBME280.readTempF(), 2);
  Serial.println(" degrees F");
  client.publish("enviroment/sensor/group1/TempF", "myBME280.readTempF(), 2");
  
  Serial.print(" Pressure: ");
  Serial.print(myBME280.readFloatPressure(), 2);
  Serial.println(" Pa");
  client.publish("enviroment/sensor/BME280/Pressure_Pa", "(myBME280.readFloatPressure(), 2)");
  Serial.print(" Pressure: ");
  Serial.print((myBME280.readFloatPressure() * 0.0002953), 2);
  Serial.println(" InHg");
  client.publish("enviroment/sensor/group1/Pressure_InHg","(myBME280.readFloatPressure() * 0.0002953), 2)");
  
  Serial.print(" Altitude: ");
  Serial.print(myBME280.readFloatAltitudeMeters(), 2);
  Serial.println("m");
  client.publish("enviroment/sensor/group1/AltitudeMeters","(myBME280.readFloatAltitudeMeters(), 2)");
  
  Serial.print(" Altitude: ");
  Serial.print(myBME280.readFloatAltitudeFeet(), 2);
  Serial.println("ft");
  
  Serial.print(" %RH: ");
  Serial.print(myBME280.readFloatHumidity(), 2);
  Serial.println(" %");
  client.publish("enviroment/sensor/group1/Humidity","0000");
  
  Serial.println();


}

//printDriverError decodes the CCS811Core::status type and prints the
//type of error to the serial terminal.
//
//Save the return value of any function of type CCS811Core::status, then pass
//to this function to see what the output was.
void printDriverError( CCS811Core::status errorCode )
{
  switch ( errorCode )
  {
    case CCS811Core::SENSOR_SUCCESS:
      Serial.print("SUCCESS");
      break;
    case CCS811Core::SENSOR_ID_ERROR:
      Serial.print("ID_ERROR");
      break;
    case CCS811Core::SENSOR_I2C_ERROR:
      Serial.print("I2C_ERROR");
      break;
    case CCS811Core::SENSOR_INTERNAL_ERROR:
      Serial.print("INTERNAL_ERROR");
      break;
    case CCS811Core::SENSOR_GENERIC_ERROR:
      Serial.print("GENERIC_ERROR");
      break;
    default:
      Serial.print("Unspecified error.");
  }
}

//printSensorError gets, clears, then prints the errors
//saved within the error register.
void printSensorError()
{
  uint8_t error = myCCS811.getErrorRegister();

  if ( error == 0xFF ) //comm error
  {
    Serial.println("Failed to get ERROR_ID register.");
  }
  else
  {
    Serial.print("Error: ");
    if (error & 1 << 5) Serial.print("HeaterSupply");
    if (error & 1 << 4) Serial.print("HeaterFault");
    if (error & 1 << 3) Serial.print("MaxResistance");
    if (error & 1 << 2) Serial.print("MeasModeInvalid");
    if (error & 1 << 1) Serial.print("ReadRegInvalid");
    if (error & 1 << 0) Serial.print("MsgInvalid");
    Serial.println();
  }
}

looking at the error message the method

 boolean publish(const char* topic, const char* payload);

expects the second parameter to the a char* (pointer to char usually an array of char)
in the statement

client.publish("enviroment/sensor/group1/CO2", (myCCS811.getCO2()));

the second parameter getCO2() returns an integer
try converting the value to a char*, e.g.

int data= (myCCS811.getCO2());
char cstr[16];
itoa(data, cstr, 10);
client.publish("enviroment/sensor/group1/CO2", cstr);

ok so i managed to have the 2 first values send to mqtt correct but all the rest were wrong it only send 2 or nothing .
is the place were i put the code for the chart corvetion correct? and what else do i have to do to have the correct values posted ?
thanks for your help so far you were very helpfull
here is the code and the screen shot from the nodered is in the atachments
thanks in advance
chris

/

******************************************************************************/
#include <SparkFunBME280.h>
#include <SparkFunCCS811.h>
#include <ESP8266WiFi.h>
#include <PubSubClient.h>

#define CCS811_ADDR 0x5B //Default I2C Address
//#define CCS811_ADDR 0x5A //Alternate I2C Address

#define PIN_NOT_WAKE 5

//Global sensor objects
CCS811 myCCS811(CCS811_ADDR);
BME280 myBME280;

// Connect to the WiFi
const char* ssid = "@@@@@@";
const char* password = "@@@@@@";
const char* mqtt_server = "192.168.1.177";

//covert to chart
    char cCo2[16];
    char cTvoc[16];
    char cTemp[16];
    char cPa[16];
    char cAlt[16];
    char cRh[16]; 
    char cInHg[16];

WiFiClient espClient;
PubSubClient client(espClient);

boolean reconnect() {// Loop until we're reconnected
  while (!client.connected()) {
    Serial.print (F("Contacting MQTT server..."));
    // Attempt to connect
    if (client.connect("group1","admin","@@@@@@")) {     //assign a "client name".  Each wemos must have a unique name
      Serial.println (F("connected"));

      // ... SUBSCRIBE TO TOPICS
      //      client.subscribe("Upstairs/Mbr/BME280/TempF");
      //      client.subscribe("Upstairs/Mbr/BME280/TempC");
      //      client.subscribe("Upstairs/Mbr/BME280/Humidity");
      //      client.subscribe("Upstairs/Mbr/BME280/Pressure");

      return client.connected();

      Serial.print (F("Failed to connect. "));
      Serial.println (F(" Attempting connection again in 3 seconds"));
      // Wait 3 seconds before retrying
      //      delay(3000);
      return 0;
    }
  }
}

void setup(){
{
  {
    Serial.begin(9600);
    client.setServer(mqtt_server, 1883);
  }
    // Connect to WiFinetwork
  Serial.println();
  Serial.println();
  Serial.print (F("Connecting to "));
  Serial.println(ssid);

  WiFi.begin(ssid, password);
  WiFi.mode(WIFI_STA);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    //Serial.begin(9600);
    Serial.print (F("."));
  }
  Serial.println (F(""));
  Serial.println (F("WiFi connected"));
  // Print the IP address
  Serial.print (F("Local IP: "));
  Serial.println(WiFi.localIP());
}
    //  *********************************************************************************

  
{  Serial.println();
  Serial.println("Apply BME280 data to CCS811 for compensation.");

  //This begins the CCS811 sensor and prints error status of .begin()
  CCS811Core::status returnCode = myCCS811.begin();
  Serial.print("CCS811 begin exited with: ");
  //Pass the error code to a function to print the results
  printDriverError( returnCode );
  Serial.println();

  //For I2C, enable the following and disable the SPI section
  myBME280.settings.commInterface = I2C_MODE;
  myBME280.settings.I2CAddress = 0x77;

  //Initialize BME280
  //For I2C, enable the following and disable the SPI section
  myBME280.settings.commInterface = I2C_MODE;
  myBME280.settings.I2CAddress = 0x77;
  myBME280.settings.runMode = 3; //Normal mode
  myBME280.settings.tStandby = 0;
  myBME280.settings.filter = 4;
  myBME280.settings.tempOverSample = 5;
  myBME280.settings.pressOverSample = 5;
  myBME280.settings.humidOverSample = 5;

  //Calling .begin() causes the settings to be loaded
  delay(10);  //Make sure sensor had enough time to turn on. BME280 requires 2ms to start up.
  myBME280.begin();


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

//{
  //Check to see if data is available
  if (myCCS811.dataAvailable())
  {
    //Calling this function updates the global tVOC and eCO2 variables
    myCCS811.readAlgorithmResults();
    //printInfoSerial fetches the values of tVOC and eCO2
    printInfoSerial();

    float BMEtempC = myBME280.readTempC();
    float BMEhumid = myBME280.readFloatHumidity();

    Serial.print("Applying new values (deg C, %): ");
    Serial.print(BMEtempC);
    Serial.print(",");
    Serial.println(BMEhumid);
    Serial.println();

    //This sends the temperature data to the CCS811
    myCCS811.setEnvironmentalData(BMEhumid, BMEtempC);
  }
  else if (myCCS811.checkForStatusError())
  {
    //If the CCS811 found an internal error, print it.
    printSensorError();
  }
   


  delay(30000); //Wait for next reading
}

//---------------------------------------------------------------
void printInfoSerial()
{
  //getCO2() gets the previously read data from the library
  int data= (myCCS811.getCO2());
  (itoa(data, cCo2, 10));
  Serial.println("CCS811 data:");
  Serial.print(" CO2 concentration : ");
  Serial.print(myCCS811.getCO2());
  Serial.println(" ppm");
  client.publish("enviroment/sensor/group1/CO2", cCo2);
  //getTVOC() gets the previously read data from the library
  
  int data1= (myCCS811.getTVOC());
  (itoa(data1, cTvoc, 10));
  Serial.print(" TVOC concentration : ");
  Serial.print(myCCS811.getTVOC());
  Serial.println(" ppb");
  client.publish("enviroment/sensor/group1/TVOC_ppb", cTvoc);
  
  int data2= (myBME280.readTempC(), 2);
  (itoa(data2, cTemp, 10));
  Serial.println("BME280 data:");
  Serial.print(" Temperature: ");
  Serial.print(myBME280.readTempC(), 2);
  Serial.println(" degrees C");
  client.publish("enviroment/sensor/group1/TempC", cTemp);

  
  Serial.print(" Temperature: ");
  Serial.print(myBME280.readTempF(), 2);
  Serial.println(" degrees F");

  int data3= (myBME280.readFloatPressure(), 2);
  (itoa(data3, cPa, 10));
  Serial.print(" Pressure: ");
  Serial.print(myBME280.readFloatPressure(), 2);
  Serial.println(" Pa");
  client.publish("enviroment/sensor/BME280/Pressure_Pa", cPa);

  int data4= ((myBME280.readFloatPressure() * 0.0002953), 2);
  (itoa(data4, cInHg, 10));
  Serial.print(" Pressure: ");
  Serial.print((myBME280.readFloatPressure() * 0.0002953), 2);
  Serial.println(" InHg");
  client.publish("enviroment/sensor/group1/Pressure_InHg", cInHg);
  
  Serial.print(" Altitude: ");
  Serial.print(myBME280.readFloatAltitudeMeters(), 2);
  Serial.println("m");
  client.publish("enviroment/sensor/group1/AltitudeMeters", cAlt);
  
  Serial.print(" Altitude: ");
  Serial.print(myBME280.readFloatAltitudeFeet(), 2);
  Serial.println("ft");

  int data5 = (myBME280.readFloatHumidity(), 2);
  (itoa(data5, cRh, 10));  
  Serial.print(" %RH: ");
  Serial.print(myBME280.readFloatHumidity(), 2);
  Serial.println(" %");
  client.publish("enviroment/sensor/group1/Humidity", cRh);
  
  Serial.println();


}

//printDriverError decodes the CCS811Core::status type and prints the
//type of error to the serial terminal.
//
//Save the return value of any function of type CCS811Core::status, then pass
//to this function to see what the output was.
void printDriverError( CCS811Core::status errorCode )
{
  switch ( errorCode )
  {
    case CCS811Core::SENSOR_SUCCESS:
      Serial.print("SUCCESS");
      break;
    case CCS811Core::SENSOR_ID_ERROR:
      Serial.print("ID_ERROR");
      break;
    case CCS811Core::SENSOR_I2C_ERROR:
      Serial.print("I2C_ERROR");
      break;
    case CCS811Core::SENSOR_INTERNAL_ERROR:
      Serial.print("INTERNAL_ERROR");
      break;
    case CCS811Core::SENSOR_GENERIC_ERROR:
      Serial.print("GENERIC_ERROR");
      break;
    default:
      Serial.print("Unspecified error.");
  }
}

//printSensorError gets, clears, then prints the errors
//saved within the error register.
void printSensorError()
{
  uint8_t error = myCCS811.getErrorRegister();

  if ( error == 0xFF ) //comm error
  {
    Serial.println("Failed to get ERROR_ID register.");
  }
  else
  {
    Serial.print("Error: ");
    if (error & 1 << 5) Serial.print("HeaterSupply");
    if (error & 1 << 4) Serial.print("HeaterFault");
    if (error & 1 << 3) Serial.print("MaxResistance");
    if (error & 1 << 2) Serial.print("MeasModeInvalid");
    if (error & 1 << 1) Serial.print("ReadRegInvalid");
    if (error & 1 << 0) Serial.print("MsgInvalid");
    Serial.println();
  }
}

ok so i found out what the problem was
int data4= ((myBME280.readFloatPressure() * 0.0002953), 2)
when i typed this the mqtt message was 2 but when i type
int data4= ((myBME280.readFloatPressure() * 0.0002953)) and publish the data i get the value but not the rest after the decimal point and the same goes for the rest .
what did i do wrong ?
thanks in advance for your help

papas_17:
ok so i found out what the problem was
int data4= ((myBME280.readFloatPressure() * 0.0002953), 2)

you are using the comma operator, the result of the expression ((myBME280.readFloatPressure() * 0.0002953), 2) is 2 which is assigned to data4, see

when i typed this the mqtt message was 2 but when i type
int data4= ((myBME280.readFloatPressure() * 0.0002953)) and publish the data i get the value but not the rest after the decimal point and the same goes for the rest .

you are evaluating a double expression and assigning the result to an int data4 - any fractional component is lost

consider this simple program

void setup() {
  // put your setup code here, to run once:
   Serial.begin(115200);
   int pi2=((PI*2.0),2);  // commoa operator pi2 = 2
   Serial.println(pi2);
   pi2=(PI*2.0);          // assign to int pi2 = 6
   Serial.println(pi2);
   Serial.println(PI*2, 2);  // print double with 2 decimal digits
}

void loop() {}

when run I get

2
6
6.28

thanks for your fast respond and sorry if i am i little bit annoying for asking but i am a rookie and also thanks for your patience .
i understand the logic but how to incorporate to the code of the mqtt publish cause when i do a simple serial print it works but i dont know how to put it "client.publish("enviroment/sensor/BME280/Pressure_Pa", cPa);" for example, the char confuses me alot .
can you help me please
thanks in advance
chris

void printInfoSerial()
{
  //getCO2() gets the previously read data from the library
  int data= (myCCS811.getCO2());
  (itoa(data, cCo2, 10));
  Serial.println("CCS811 data:");
  Serial.print(" CO2 concentration : ");
  Serial.print(myCCS811.getCO2());
  Serial.println(" ppm");
  client.publish("enviroment/sensor/group1/CO2", cCo2);
  //getTVOC() gets the previously read data from the library
  
  int data1= (myCCS811.getTVOC());
  (itoa(data1, cTvoc, 10));
  Serial.print(" TVOC concentration : ");
  Serial.print(myCCS811.getTVOC());
  Serial.println(" ppb");
  client.publish("enviroment/sensor/group1/TVOC_ppb", cTvoc);
  
  int data2= (myBME280.readTempC());
  (itoa(data2, cTemp, 10));
  Serial.println("BME280 data:");
  Serial.print(" Temperature: ");
  Serial.print(myBME280.readTempC(), 2);
  Serial.println(" degrees C");
  client.publish("enviroment/sensor/group1/TempC", cTemp);

  
  Serial.print(" Temperature: ");
  Serial.print(myBME280.readTempF(), 2);
  Serial.println(" degrees F");

  int data3= (myBME280.readFloatPressure());
  (itoa(data3, cPa, 10));
  Serial.print(" Pressure: ");
  Serial.print(myBME280.readFloatPressure(), 2);
  Serial.println(" Pa");
  client.publish("enviroment/sensor/BME280/Pressure_Pa", cPa);

  int data4= ((myBME280.readFloatPressure() * 0.0002953));
  (itoa(data4, cInHg, 2));
  Serial.print(" Pressure: ");
  Serial.print((myBME280.readFloatPressure() * 0.0002953), 2);
  Serial.println(" InHg");
  client.publish("enviroment/sensor/group1/Pressure_InHg", cInHg);
  
  Serial.print(" Altitude: ");
  Serial.print(myBME280.readFloatAltitudeMeters(), 2);
  Serial.println("m");
  client.publish("enviroment/sensor/group1/AltitudeMeters", cAlt);
  
  Serial.print(" Altitude: ");
  Serial.print(myBME280.readFloatAltitudeFeet(), 2);
  Serial.println("ft");

  int data5 = (myBME280.readFloatHumidity());
  (itoa(data5, cRh, 10));  
  Serial.print(" %RH: ");
  Serial.print(myBME280.readFloatHumidity(), 2);
  Serial.println(" %");
  client.publish("enviroment/sensor/group1/Humidity", cRh);
  
  Serial.println();


}

from the API documentation
https://pubsubclient.knolleary.net/api.html#publish1

int publish (topic, payload)
the second parameter is the message to publish (const char[])

assuming cPa is a char[] the following should work

 int data3= (myBME280.readFloatPressure());
  (itoa(data3, cPa, 10));
  Serial.print(" Pressure: ");
  Serial.print(myBME280.readFloatPressure(), 2);
  Serial.println(" Pa");
  client.publish("enviroment/sensor/BME280/Pressure_Pa", cPa);

if you wish to publish data with fractional part (two digits after the decimal point)

 float data3= (myBME280.readFloatPressure());
  dtostrf(data3, 10, 2, cPa);
  client.publish("enviroment/sensor/BME280/Pressure_Pa", cPa);

thanks so much can i ask a question why we changed the itoa to dtostrf ? and also why the float would work better here instead of int ?

thanks so much for your help
you were realyy helpful

do you expect values with fractional components from your sensors?
if so and you want the fractional components use float variables and dtostrf() otherwise use int and atoi()

thank you that made alot of sense.
can you please guide me through this one also that is the last one .
i will have some numbers"slider from nodered" send through mqtt from 0-255 and then the esp print them though serial through espdmx library i have the code ready but again i have the problem with the same. to take the code received and print it through the dmxcommand.
can you please help me

/*

#include <espDMX.h>
#include <ESP8266WiFi.h>
#include <PubSubClient.h>

// Update these with values suitable for your network.

const char* ssid = "@@@@@@";
const char* password = "@@@@@@!";
const char* mqtt_server = "192.168.1.177";

WiFiClient espClient;
PubSubClient client(espClient);
long lastMsg = 0;
char msg[50];
int value = 0;

void setup_wifi() {

  delay(10);
  // We start by connecting to a WiFi network
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);

  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }

  randomSeed(micros());

  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
}

void callback(char* topic, byte* payload, unsigned int length) {
  Serial.print("Message arrived [");
  Serial.print(topic);
  Serial.print("] ");
  for (int i = 0; i < length; i++) {
    Serial.print((char)payload[i]);

    // Map values 1-5 to dmx channels 101 - 105 on dmxB
    dmxA.setChans((char)payload[i], 10, 1);
    // Map values 1-5 to dmx channels 101 - 105 on dmxB
    dmxB.setChans((char)payload[i], 5, 101);
  }
  Serial.println();

}

void reconnect() {
  // Loop until we're reconnected
  while (!client.connected()) {
    Serial.print("Attempting MQTT connection...");
    // Attempt to connect
    if (client.connect("dmx1","admin","@@@@@!")) {
      Serial.println("connected");
      // Once connected, publish an announcement...
      client.publish("outlight/dmx1/", "On Dmx Esp");
      // ... and resubscribe
      client.subscribe("inlight/dmx1/");
    } else {
      Serial.print("failed, rc=");
      Serial.print(client.state());
      Serial.println(" try again in 5 seconds");
      // Wait 5 seconds before retrying
      delay(5000);
    }
  }
}

void setup() {
    // Start dmxA, status LED on pin 12 with full intensity
  dmxA.begin(12);

  // Start dmxB, status LED on pin 13 with 75/255 intensity
  dmxB.begin(13, 75);
  Serial.begin(115200);
  setup_wifi();
  client.setServer(mqtt_server, 1883);
  client.setCallback(callback);
}

void loop() {

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

     long now = millis();
  if (now - lastMsg > 2000) {
    lastMsg = now;
    ++value;
    snprintf (msg, 75, "On Dmx Esp #%ld", value);
    Serial.print("Publish message: ");
    Serial.println(msg);
    client.publish("outlight/dmx1/", msg);
  
  }
}

i have managed to serial print the value with no problem but when i try to put to the line dmxA.setChans((char)payload*, 10, 1) i get always error*
"invalid conversion from 'uint8_t {aka unsigned char}' to 'uint8_t* {aka unsigned char*}' [-fpermissive]"
also do you think is best to put the dmx.setchans code there or at the void loop() as was i the example
```
*for (int i = 0; i < 10; i++) {
   
    // Output channels 1 - 10 on dmxA
    dmxA.setChans(dmxChase[i], 10, 1);

// Map values 1-5 to dmx channels 101 - 105 on dmxB
    dmxB.setChans(dmxChase[i], 5, 101);

// 1 second between each step
    delay(1000);
  }*
```
thanks again for your huge help
you helped me alot

looking at espDMX.h

the prototype of setChans specifies the first parameter as byte* (pointer to byte0
void setChans(byte*, uint16_t, uint16_t);

in your code you cast the first parameter to a char

   // Map values 1-5 to dmx channels 101 - 105 on dmxB
    dmxA.setChans((char)payload[i], 10, 1);

as payload is byte* should the call be

   // Map values 1-5 to dmx channels 101 - 105 on dmxB
    dmxA.setChans(payload, 10, 1);

ok so itry it works for a while but after it restart the esp and after a while i get these errors

Exception (0):
epc1=0x40202814 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000

ctx: sys 
sp: 3ffffc50 end: 3fffffb0 offset: 01a0

>>>stack>>>
3ffffdf0:  00000017 0000001d 00000019 00000080  
3ffffe00:  4020c416 3fff0134 3ffe961e 4000050c  
3ffffe10:  4000437b 00000030 00000016 ffffffff  
3ffffe20:  60000200 00000008 ffffffff 80000000  
3ffffe30:  20000000 3fff14f8 80000000 203fc1c0  
3ffffe40:  80000000 3fffc6fc 3ffedea8 3fff14fc  
3ffffe50:  00000134 003fc1c0 60000600 00000030  
3ffffe60:  40106b64 3fff087c 00000000 00000001  
3ffffe70:  4020ce55 3ffee328 3fff087c 4020258b  
3ffffe80:  40105244 40106ab8 3fffc250 40202820  
3ffffe90:  00000000 00000000 0000001f 40105101  
3ffffea0:  4000050c 008ebc8e 40211437 4000050c  
3ffffeb0:  40000f68 00000030 0000001c ffffffff  
3ffffec0:  40000f58 00000000 00000020 00000000  
3ffffed0:  00000013 40208fcc 3ffedea8 00000001  
3ffffee0:  ffffffff 3ffe8b04 3ffedea8 3fffdab0  
3ffffef0:  00000000 3fffdcb0 3ffedee0 00000030  
3fffff00:  00000000 400042db 00000064 60000600  
3fffff10:  40004b31 3fff133c 000002f4 003fc000  
3fffff20:  40105666 3ffeded0 3ffecf70 40106ee4  
3fffff30:  40208a9d 3ffecf70 3ffeded0 0212bf8a  
3fffff40:  3fff133c 00001000 40208f32 00000008  
3fffff50:  40105e24 00000000 40208fdf 3ffed024  
3fffff60:  3ffeded0 008f30d0 3ffeded0 60000600  
3fffff70:  4021a6c1 3ffed024 3ffeded0 02129dc6  
3fffff80:  4021a706 3fffdab0 00000000 3fffdcb0  
3fffff90:  3ffedee8 00000000 40000f65 3fffdab0  
3fffffa0:  40000f49 000182ab 3fffdab0 40000f49  
<<<stack<<<

 ets Jan  8 2013,rst cause:2, boot mode:(1,6)


 ets Jan  8 2013,rst cause:4, boot mode:(1,6)

wdt reset
wdt reset
load 0x4010f000, len 1384, room 16
tail 8
chksum 0x2d
csum 0x2d
v09f0c112
~ld

do you have any idea why

do you have a watchdog timer set?

you have prints in the callback() function which I assume is similar to an interrupt service routine
in general this is not a good idea unless the print code is reentrant
even then code should be kept as short as possible

no i haven't should i put the dmx commands in the void loop ?
it was my first place i wanted to write them but i havent done it cause i ddindnt know how to save the payload value to int so i can use later at the code cause its char .

void loop() {

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

     long now = millis();
  if (now - lastMsg > 2000) {
    lastMsg = now;
    ++value;
    snprintf (msg, 75, "On Dmx Esp #%ld", value);
  //  Serial.print("Publish message: ");
  //  Serial.println(msg);
    client.publish("outlight/dmx1/", msg);
    delay(3000);
    // Map values 1-5 to dmx channels 101 - 105 on dmxB
    dmxA.setChans(payload, 1);

    // Map values 1-5 to dmx channels 101 - 105 on dmxB
    dmxB.setChans(payload, 101);
  
  }

Hi so I think is the void callback that destroyed the code , I have to write the dmA.setCans( payload,1) at the void loop
But it says that I haven’t declared it , but I don’t know how to save the payload from the mqtt to use it for later in the code ,
Any ideas?
Thanks in advance
Chris

you define a set of volatile variables and on callback() copy the data into these
in loop() when new data has arrived you process them, e.g.

volatile char newTopic[100]={0};
volatile char newPayLoad[100]={0};
volatile int newLength=0;
volatile bool newPayLoadRecieved=false;

// copy new data to volatile variables
void callback(char* topic, byte* payload, unsigned int length) {
  strcpy((char*)newTopic, topic);
  newLength=length;
  for (int i = 0; i < length; i++) {
    newPayLoad[i]=(char)payload[i];
    }
  newPayLoadRecieved=true;
}

void loop() {
if(newPayLoadRecieved)
{
  Serial.print("Message arrived [");
  Serial.print((char *)newTopic);
  Serial.print("] ");
  for (int i = 0; i < newLength; i++) {
    Serial.print(newPayLoad[i]);
    // Map values 1-5 to dmx channels 101 - 105 on dmxB
    dmxA.setChans((char)newPayLoad[i], 10, 1);
    // Map values 1-5 to dmx channels 101 - 105 on dmxB
    dmxB.setChans((char)newPayLoad[i], 5, 101);
   }
  }
  Serial.println();
    newPayLoadRecieved=false;
}
i get this error ,should i use a different variable ?
i tried also dmxA.setChans((char)newpayload[i]); with the samne error and dmxA.setChans(newpayload[i]); again with error 
thanks i advance 
chris 
C:\Users\Chris\Documents\Arduino\EspDmx_GroupA\EspDmx_GroupA.ino: In function 'void loop()':

EspDmx_GroupA:135: error: invalid conversion from 'volatile char*' to 'uint8_t* {aka unsigned char*}' [-fpermissive]

     dmxA.setChans(newPayLoad, 10, 1);

                                    ^


C:\Users\Chris\Documents\Arduino\libraries\espDMX/espDMX.h:66:14: error:   initializing argument 1 of 'void espDMX::setChans(uint8_t*, uint16_t, uint16_t)' [-fpermissive]

         void setChans(byte*, uint16_t, uint16_t);

              ^

exit status 1
invalid conversion from 'volatile char*' to 'uint8_t* {aka unsigned char*}' [-fpermissive]

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.