Acrobotics ESP8266 remote monitoring

Hi there

I have spent hours trying to work out where I have gone wrong following the Acrobotics video, Remote monitoring with the ESP8266 (See my code below, I have added a serial print of the device IP address and MAC address)

I have also swapped from the DHT22 to a DHT11, but neither work, my icon on the Cayenne portal do not display, on the serial monitor it says, failed to read. I have tried all different data pins but I believe the recommended is D4

I have tested my DHT11 with a different sketch and serial monitor display and it work fine

I’ll be glad of any advice

Thanks

Jerry

#include <CayenneMQTTESP8266.h>
#include <DHT.h>
#define CAYENNE_DEBUG
#define CAYENNE_PRINT Serial
#include <ESP8266WiFi.h> //added

char ssid[] = "Beamer";
char password[] = "password";

char username[] = "USERNAME";
char mqtt_password[] = "PASSWORD";
char client_id[] = "CLIENT_ID";

//DHT dht(D2, DHT22);
DHT dht(D2, DHT11);

void setup() {
    Cayenne.begin(username, mqtt_password, client_id, ssid, password);
  pinMode(2, OUTPUT);
  digitalWrite(2, HIGH);

  //added
  Serial.begin(115200);
  delay(10);
  // We start by connecting to a WiFi network
  Serial.println();
  Serial.print("ESP8266 MAC: ");
  Serial.println(WiFi.macAddress());
  Serial.print("Connecting to ");
  Serial.println(ssid);
  WiFi.begin (ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
    //end of added
}
//added
Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());   //You can get IP address assigned to ESP
//end of added
}

void loop() {
  // put your main code here, to run repeatedly:
  Cayenne.loop();
  float temp = dht.readTemperature(true); // FAHRENHEIT
  float hum = dht.readHumidity();
  Cayenne.virtualWrite(1, temp, TYPE_TEMPERATURE, UNIT_FAHRENHEIT);
  Cayenne.virtualWrite(2, hum, TYPE_RELATIVE_HUMIDITY, UNIT_PERCENT);
}
CAYENNE_IN(0)
{
  digitalWrite(2, !getValue.asInt());
}

Try this code:

#include &lt;CayenneMQTTESP8266.h&gt;
#include &lt;DHT.h&gt;
#define CAYENNE_DEBUG
#define CAYENNE_PRINT Serial
#include &lt;ESP8266WiFi.h&gt; //added

char ssid = “Beamer”;
char password = “password”;

char username = “USERNAME”;
char mqtt_password = “PASSWORD”;
char client_id = “CLIENT_ID”;

//DHT dht(D2, DHT22);
DHT dht(D2, DHT11);

void setup() {
Serial.begin(9600);
Cayenne.begin(username, mqtt_password, client_id, ssid, password);
pinMode(2, OUTPUT);
digitalWrite(2, HIGH);
}

void loop() {
// put your main code here, to run repeatedly:
Cayenne.loop();
float temp = dht.readTemperature(true); // FAHRENHEIT
float hum = dht.readHumidity();
Cayenne.virtualWrite(1, temp, TYPE_TEMPERATURE, UNIT_FAHRENHEIT);
Cayenne.virtualWrite(2, hum, TYPE_RELATIVE_HUMIDITY, UNIT_PERCENT);
}
CAYENNE_IN(0)
{
digitalWrite(2, !getValue.asInt());
}

Against, #include <ESP8266WiFi.h> //added

I get this error

#include expects “FILENAME” or

Thanks for your help

Okay, as you provided absolutely no accompanying text I assume that you were advising me replace my greater and less than arrows with quotation marks and to simplify the code by removing the simple.dht and removing the MAC and IP address print.

None of that worked, exactly the same problem exists.

Anyone else?

can you add the basic code for cayenne esp8266 again and add #define CAYENNE_DEBUG. open the serial monitor and check what is the output. share here if you get any error.

This all I see in the serial monitor
17:42:41.325 ->

Which is the time plus 325

which is the esp8266 device you are using?

NodeMCU 1.0 (ESP 12E Module)

Thank you

can you follow this tutorial set by set and see if you can connect node-mcu to cayenne Adding a New Device using MQTT