HI IM BEGINNER AND NEED HELP. I HAVE A CODE WHICH RUNS PERFECTLY AND DATA UPDATES EVERY 2 SECONDS BUT WHEN I ADD ANOTHER SENSOR IN THE CODE THE DEVICE GOES OFFLINE.
HERES THE CODE:
#define CAYENNE_DEBUG // Uncomment to show debug messages
#define CAYENNE_PRINT Serial // Comment this out to disable prints and save space
#include <CayenneMQTTESP8266Shield.h>
#include <Ultrasonic.h>
#include "DHT.h"
#include "thermistor.h"
#include "HardwareSerial.h"
#define NTC_PIN A0
THERMISTOR thermistor(NTC_PIN, // Analog pin
10000, // Nominal resistance at 25 ºC
3950, // thermistor's beta coefficient
10000); // Value of the series resistor
#define DHTPIN 7
uint16_t temp;
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
Ultrasonic ultrasonic(12, 13);
char ssid[] = "NETGEAR92";
char wifiPassword[] = "waterychair234";
char username[] = "";
char password[] = "";
char clientID[] = "";
#define EspSerial Serial
ESP8266 wifi(&EspSerial);
void setup()
{
Serial.begin(9600);
delay(10);
EspSerial.begin(115200);
delay(10);
Cayenne.begin(username, password, clientID, wifi, ssid, wifiPassword);
}
void loop()
{
Cayenne.loop();
float temp = thermistor.read(); // Read temperature
}
CAYENNE_OUT(9){
float h = dht.readHumidity();
Cayenne.virtualWrite(9,h);
}
CAYENNE_OUT(10){
float t = dht.readTemperature();
Cayenne.virtualWrite(10,t);}
CAYENNE_OUT(6){
Cayenne.virtualWrite(6, ultrasonic.distanceRead());
}
CAYENNE_OUT(11)
{
Cayenne.virtualWrite(11,temp);
}
THE CAYENNE OUT 11 MAKES DEVICE GO OFFLINE