Connection issues after updating code

#1

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 https://github.com/jfturcot/SimpleTimer
#include <SimpleDHT.h> // Download from https://github.com/adafruit/DHT-sensor-library

// 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);
}}

0 Likes

#2

which board are you using with arduino to connect with internet? for DHT use this code https://github.com/myDevicesIoT/Cayenne-MQTT-Arduino/blob/master/examples/CommunitySubmitted/DHT/DHT.ino

0 Likes

#3

Hi Sharmik,
I am using a Huzzah Feather esp8266

0 Likes

#4

you need to use https://github.com/myDevicesIoT/Cayenne-MQTT-Arduino/blob/master/examples/Connections/ESP8266Shield/ESP8266Shield.ino and add the code for the DHT from the previous post link.

0 Likes

#5

Okay, I will give that a go, thanks!

0 Likes