Hi everyone, I am not able to connect to dashboard at Cayenne when using the ESP8266 NODEMCU or the Generic ESP8266 even after putting in the correct credentials. The code seems to be all fine. I am stuck at the “Connect your Device” step and I am not able to make a dashboard. Kindly, help me with this.
can you share the code you are using and also add #define CAYENNE_DEBUG
in the code and share the serial monitor output
Sure, here is my code:
#include <CayenneMQTTESP8266.h>
#define CAYENNE_DEBUG
#define CAYENNE_PRINT Serial
#define TRIGGER1 D1
#define ECHO1 D2
#define TRIGGER2 D5
#define ECHO2 D6
#define TRIGGER3 D7
#define ECHO3 D8
#define MAX_DISTANCE 300
#define THRESHOLD 70
char ssid = “Searching…”;
char wifiPassword = “house187”;
char mqttUsername = “f01b7780-d41f-11ed-8485-5b7d3ef089d0”;
char mqttPassword = “7229c1bf92257acf97cf7b10b7e4fe665075facb”;
char mqttClientID = “801b28b0-d427-11ed-9ab8-d511caccfe8c”;
unsigned long lastMillis = 0;
void setup() {
Serial.begin(9600);
pinMode(TRIGGER1, OUTPUT);
pinMode(ECHO1, INPUT);
pinMode(TRIGGER2, OUTPUT);
pinMode(ECHO2, INPUT);
pinMode(TRIGGER3, OUTPUT);
pinMode(ECHO3, INPUT);
Cayenne.begin(mqttUsername, mqttPassword, mqttClientID, ssid, wifiPassword);
}
void loop() {
if (millis() - lastMillis > 10000) { // send data every 10 seconds
float distance1 = getDistance(TRIGGER1, ECHO1);
float distance2 = getDistance(TRIGGER2, ECHO2);
float distance3 = getDistance(TRIGGER3, ECHO3);
Cayenne.virtualWrite(1, distance1, "ultrasonic-in", "cm"); // send data to Cayenne dashboard
Cayenne.virtualWrite(2, distance2, "ultrasonic-in", "cm");
Cayenne.virtualWrite(3, distance3, "ultrasonic-in", "cm");
if (distance1 > THRESHOLD) {
Serial.println("Dustbin 1 is full!");
}
if (distance2 > THRESHOLD) {
Serial.println("Dustbin 2 is full!");
}
if (distance3 > THRESHOLD) {
Serial.println("Dustbin 3 is full!");
}
lastMillis = millis();
}
Cayenne.loop();
}
float getDistance(int triggerPin, int echoPin) {
digitalWrite(triggerPin, LOW);
delayMicroseconds(2);
digitalWrite(triggerPin, HIGH);
delayMicroseconds(10);
digitalWrite(triggerPin, LOW);
float duration = pulseIn(echoPin, HIGH, MAX_DISTANCE * 58);
float distance = duration / 58;
return distance;
}
In this code, I’m using three ultrasonic sensors to measure the garbage level in the bins. I want to display these garbage levels on a web dashboard using IoT and display a warning if any garbage level in any bin is above the threshold value.
can you share the serial monitor output?
The Serial Monitor does not show anything. It is blank.