Problem in the beginning- Doesnt Connect to Cayenne Dashboard - Solved

Arduino Code:

#define CAYENNE_DEBUG       // Uncomment to show debug messages
#define CAYENNE_PRINT Serial  // Comment this out to disable prints and save space
#include <CayenneMQTTEthernet.h>

// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username[] = "8fd42ce0-bec2-11e8-bf81-6b1a7e6fd7d2";
char password[] = "942fbf9ab708d9f343cad4dfd35490e84ab90152";
char clientID[] = "4c5d3420-c5b1-11e8-9f7b-1d1cb94fd98c";

// Mac address should be different for each device in your LAN
byte arduino_mac[] = { 0xDE, 0xED, 0xBA, 0xFE, 0xFE, 0xED };
IPAddress arduino_ip(192, 168, 0, 23);
IPAddress dns_ip(8, 8, 8, 8);
IPAddress gateway_ip(192,168, 0, 11);
IPAddress subnet_mask(255, 255, 255, 0);

void setup() {
  Serial.begin(9600);
  Cayenne.begin(username, password, clientID, arduino_ip, dns_ip, gateway_ip, subnet_mask, arduino_mac);
}

void loop() {
  Cayenne.loop();
}

// Default function for sending sensor data at intervals to Cayenne.
// You can also use functions for specific channels, e.g CAYENNE_OUT(1) for sending channel 1 data.
CAYENNE_OUT_DEFAULT()
{
  // Write data to Cayenne here. This example just sends the current uptime in milliseconds on virtual channel 0.
  Cayenne.virtualWrite(0, millis());
}

// Default function for processing actuator commands from the Cayenne Dashboard.
// You can also use functions for specific channels, e.g CAYENNE_IN(1) for channel 1 commands.
CAYENNE_IN_DEFAULT()
{
  CAYENNE_LOG("Channel %u, value %s", request.channel, getValue.asString());
  //Process message here. If there is an error set an error message using getValue.setError(), e.g getValue.setError("Error message");
}

Error Message after upload:

In file included from C:\Users\mauri\Documents\Arduino\libraries\CayenneMQTT\src/CayenneMQTTEthernetClient.h:21:0,

             from C:\Users\mauri\Documents\Arduino\libraries\CayenneMQTT\src/CayenneMQTTEthernet.h:25,

             from C:\Users\mauri\Documents\Arduino\Ethernet_Cayenne\sketch_sep24a\sketch_sep24a.ino:4:

C:\Users\mauri\Documents\Arduino\libraries\CayenneMQTT\src/CayenneArduinoMQTTClient.h: In member function 'void CayenneArduinoMQTTClient::connect()':

C:\Users\mauri\Documents\Arduino\libraries\CayenneMQTT\src/CayenneArduinoMQTTClient.h:58:63: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

if (!NetworkConnect(&_network, CAYENNE_DOMAIN, CAYENNE_PORT)) {

                                                           ^

Serial Output:

[560] IP: 192.168.0.23
[561] Connecting to mqtt.mydevices.com:1883
[2388] Network connect failed
[5213] Network connect failed
[8038] Network connect failed
[10862] Network connect failed
[13687] Network connect failed
[16513] Network connect failed
[19337] Network connect failed

Can you try replacing

Cayenne.begin(username, password, clientID, arduino_ip, dns_ip, gateway_ip, subnet_mask, arduino_mac);

with

Cayenne.begin(username, password, clientID);

in that sketch and posting the Serial Monitor output from it?

Also, does your RouterWifi have an Ethernet port? Can you try connecting the Arduino directly to it to rule out the other Router and Computer as possible issues?

1 Like

How I’m going to know if it worked if the arduino won’t be conected to my computer?

connect the arduino ethernet cable to the router while arduino USB cable to your computer.

1 Like

Thanks for the help!!! It finally worked. I just connected the ethernet shield directly to my wifi router.I think the problem was that the computer couldn’t ‘‘supply’’ internet to the ethernet shield.
I’m sorry for the trouble and for bad english. I’m new at IOT, and network knowledges.

glad to hear it is working now.

1 Like

Yeah, the computer would have probably needed to be set up to forward the traffic on to the WiFi router.

Glad that’s working for you now.

1 Like