Hi im using an arduino Mega with an esp8266 chip (RX/TX) that connects to Cayenne IOT Dahsboard.. The sensor works perfectly without me using software serial.. but as soon as i add the cayenne credentials etc.. the sensor never gets past the 5 min warming up stage.. Please advise.. im fairly new to this and no idea why it wont work.. heres my code.. #include <SoftwareSerial.h> //#define CAYENNE_DEBUG // Uncomment to show debug messages #define CAYENNE_PRINT Serial // Comment this out to disable prints and save space SoftwareSerial ESPserial(19, 18); // RX | TXAT+CIOBAUD=9600 #include <CayenneMQTTESP8266Shield.h> // ---------- WiFi network info ----------- char ssid[] = "VM2588954-2G"; char wifiPassword[] = "v2yhHrkFybwv"; char username[] = "0dcf1300-a65f-11ea-a67f-15e30d90bbf4"; char password[] = "7955777e9b1d2bec0b2da83baa65d271aad95c03"; char clientID[] = "a19cece0-9967-11ec-8c44-371df593ba58"; // Set ESP8266 Serial object. In this example we use the Serial1 hardware serial which is available on boards like the Arduino Mega. #define EspSerial Serial1 ESP8266 wifi(&EspSerial); // - BME680 - SETUP #include <Wire.h> #include "bsec.h" Bsec iaqSensor; String output; unsigned long time_trigger = millis(); // ************************************************************************** void setup() { Serial.begin(9600); Serial.begin(9600); EspSerial.begin(115200); delay(10); Cayenne.begin(username, password, clientID, wifi, ssid, wifiPassword); Wire.begin(); Serial.println(F("BME680 test")); // iaqSensor.begin(BME680_I2C_ADDR_SECONDARY, Wire); // Adafruit iaqSensor.begin(BME680_I2C_ADDR_PRIMARY, Wire); // Seed output = "\nBSEC library version " + String(iaqSensor.version.major) + "." + String(iaqSensor.version.minor) + "." + String(iaqSensor.version.major_bugfix) + "." + String(iaqSensor.version.minor_bugfix); Serial.println(output); checkIaqSensorStatus(); bsec_virtual_sensor_t sensorList[10] = { BSEC_OUTPUT_RAW_TEMPERATURE, BSEC_OUTPUT_RAW_PRESSURE, BSEC_OUTPUT_RAW_HUMIDITY, BSEC_OUTPUT_RAW_GAS, BSEC_OUTPUT_IAQ, BSEC_OUTPUT_STATIC_IAQ, BSEC_OUTPUT_CO2_EQUIVALENT, BSEC_OUTPUT_BREATH_VOC_EQUIVALENT, BSEC_OUTPUT_SENSOR_HEAT_COMPENSATED_TEMPERATURE, BSEC_OUTPUT_SENSOR_HEAT_COMPENSATED_HUMIDITY, }; iaqSensor.updateSubscription(sensorList, 10, BSEC_SAMPLE_RATE_LP); checkIaqSensorStatus(); // Print the header output = "Timestamp [ms], raw temperature [°C], pressure [hPa], raw relative humidity [%], gas [Ohm], IAQ, IAQ accuracy, temperature [°C], relative humidity [%], Static IAQ, CO2 equivalent, breath VOC equivalent"; Serial.println(output); } //*********************************************************************** void loop() { Cayenne.loop(); if (! iaqSensor.run()) { // If no data is available checkIaqSensorStatus(); return; } output = String (time_trigger); output += ", " + String(iaqSensor.rawTemperature); output += ", " + String(iaqSensor.pressure); output += ", " + String(iaqSensor.rawHumidity); output += ", " + String(iaqSensor.gasResistance); output += ", " + String(iaqSensor.iaq); output += ", " + String(iaqSensor.iaqAccuracy); output += ", " + String(iaqSensor.temperature); output += ", " + String(iaqSensor.humidity); output += ", " + String(iaqSensor.staticIaq); output += ", " + String(iaqSensor.co2Equivalent); output += ", " + String(iaqSensor.breathVocEquivalent); Serial.println(output); Serial.print("Temperature = "); Serial.print(iaqSensor.temperature); Serial.println(" *C"); Serial.print("Pressure = "); Serial.print(iaqSensor.pressure / 100.0); Serial.println(" hPa"); Serial.print("Humidity = "); Serial.print(iaqSensor.humidity); Serial.println(" %"); Serial.print("IAQ = "); Serial.print(iaqSensor.staticIaq); Serial.println(""); Serial.print("CO2 equiv = "); Serial.print(iaqSensor.co2Equivalent); Serial.println(""); Serial.print("Breath VOC = "); Serial.print(iaqSensor.breathVocEquivalent); Serial.println(""); Serial.println(); }// Loop End void checkIaqSensorStatus(void) { if (iaqSensor.status != BSEC_OK) { if (iaqSensor.status < BSEC_OK) { output = "BSEC error code : " + String(iaqSensor.status); Serial.println(output); for (;;) delay(10); } else { output = "BSEC warning code : " + String(iaqSensor.status); Serial.println(output); } } if (iaqSensor.bme680Status != BME680_OK) { if (iaqSensor.bme680Status < BME680_OK) { output = "BME680 error code : " + String(iaqSensor.bme680Status); Serial.println(output); for (;;) delay(10); } else { output = "BME680 warning code : " + String(iaqSensor.bme680Status); Serial.println(output); } } } CAYENNE_OUT_DEFAULT() { float bme_temperature = iaqSensor.temperature; float bme_humidity = iaqSensor.humidity; float bme_pressure = iaqSensor.pressure / 100.0; float bme_gas_resistance = iaqSensor.gasResistance / 100; float bme_iaq = iaqSensor.staticIaq; float bme_co2 = iaqSensor.co2Equivalent; Cayenne.celsiusWrite(1, bme_temperature); // Temp Cayenne.virtualWrite(2, bme_humidity, "rel_hum", "p"); // Humidity Cayenne.virtualWrite(3, bme_pressure, "bp", "hpa"); // Pressure Cayenne.virtualWrite(4, bme_gas_resistance, "analog_sensor", "ppm"); // RAW GAS Cayenne.virtualWrite(7, bme_co2, "gas_sensor", "null"); // CO2 BME680 Cayenne.virtualWrite(20, bme_iaq, "IAQ", "null"); // IAQ } Thank you
... View more