Hello everyone, I was wondering if someone could help me on an issue I am having.
- I had a previously connected Huzzah ESP8266 to a DHT11
-No issues at all connecting to Cayenne initially. Had it running for a few weeks
*I updated the Arduino sketch to convert the C readings to F.
-Uploaded code to the board, no issues uploading
- The Device would not connect so I removed it and did the “Bring your Own Device.” It seems like it’s taking a long time to connect “Waiting for board to connect…”
Here is my sketch:
// This example shows how to connect to Cayenne using an ESP8266 and send/receive sample data.
// Make sure you install the ESP8266 Board Package via the Arduino IDE Board Manager and select the correct ESP8266 board before compiling.
//#define CAYENNE_DEBUG
#define CAYENNE_PRINT Serial
#include <CayenneMQTTESP8266.h>
#include <SimpleTimer.h> // Download from GitHub - jfturcot/SimpleTimer: SimpleTimer library for Arduino
#include <SimpleDHT.h> // Download from GitHub - adafruit/DHT-sensor-library: Arduino library for DHT11, DHT22, etc Temperature & Humidity Sensors
// WiFi network info.
char ssid = “XXXXX”;
char wifiPassword = “XXXXX”;
// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username = “X”;
char password = “XX”;
char clientID = “XXXX”;
// DHT11 Pin
int pinDHT11 = 2;
SimpleDHT11 dht11;
// Timer
SimpleTimer timer;
void setup() {
Serial.begin(9600);
Cayenne.begin(username, password, clientID, ssid, wifiPassword);
timer.setInterval(60000L, transmitData); // Method to execute every minute
}
void loop() {
Cayenne.loop();
timer.run();
}
void transmitData()
{
byte temperature = 0;
byte humidity = 0;
int err = SimpleDHTErrSuccess;
// converting Celsius to Fahrenheit
byte f = temperature * 1.8 + 32;
Serial.print(“Sample OK: “);
Serial.print((int)temperature); Serial.print(” *C, “);
Serial.print((int)f); Serial.print(” *F, “);
Serial.print((int)humidity); Serial.println(” H humidity”);
if ((err = dht11.read(pinDHT11, &temperature, &humidity, NULL)) != SimpleDHTErrSuccess) {
Cayenne.virtualWrite(V4, 0);
Cayenne.virtualWrite(V2, 0);
}
else {
Cayenne.virtualWrite(V4, (int)temperature);
Cayenne.virtualWrite(V2, (int)humidity);
}}