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


#1

Arduino Mega 2560 with W5100 ethernet shield connected to a router D-Link
Using Web Dashboard to the first connection

My project doesnt connect to Cayenne, not at all.
I tried to make it work with W5100 source code, then I tried to use Manual Connection source code. And the web page didn’t load after that.
This is the message that Arduino IDE shows to me when Ioad the code.

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:14:

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)) {

                                                           ^

C:\Users\mauri\Documents\Arduino\libraries\CayenneMQTT\src\CayenneMQTTClient\CayenneMQTTClient.c: In function 'CayenneMQTTPublishDataInt':

C:\Users\mauri\Documents\Arduino\libraries\CayenneMQTT\src\CayenneMQTTClient\CayenneMQTTClient.c:135:2: warning: implicit declaration of function 'itoa' [-Wimplicit-function-declaration]

  itoa(value, str, 10);

  ^

C:\Users\mauri\Documents\Arduino\libraries\CayenneMQTT\src\CayenneMQTTClient\CayenneMQTTClient.c: In function 'CayenneMQTTPublishDataUInt':

C:\Users\mauri\Documents\Arduino\libraries\CayenneMQTT\src\CayenneMQTTClient\CayenneMQTTClient.c:158:2: warning: implicit declaration of function 'utoa' [-Wimplicit-function-declaration]

  utoa(value, str, 10);

  ^

C:\Users\mauri\Documents\Arduino\libraries\CayenneMQTT\src\CayenneMQTTClient\CayenneMQTTClient.c: In function 'CayenneMQTTPublishDataLong':

C:\Users\mauri\Documents\Arduino\libraries\CayenneMQTT\src\CayenneMQTTClient\CayenneMQTTClient.c:181:2: warning: implicit declaration of function 'ltoa' [-Wimplicit-function-declaration]

  ltoa(value, str, 10);

  ^

C:\Users\mauri\Documents\Arduino\libraries\CayenneMQTT\src\CayenneMQTTClient\CayenneMQTTClient.c: In function 'CayenneMQTTPublishDataULong':

C:\Users\mauri\Documents\Arduino\libraries\CayenneMQTT\src\CayenneMQTTClient\CayenneMQTTClient.c:204:2: warning: implicit declaration of function 'ultoa' [-Wimplicit-function-declaration]

  ultoa(value, str, 10);

  ^

C:\Users\mauri\Documents\Arduino\libraries\CayenneMQTT\src\CayenneMQTTClient\CayenneMQTTClient.c: In function 'CayenneMQTTPublishDataDouble':

C:\Users\mauri\Documents\Arduino\libraries\CayenneMQTT\src\CayenneMQTTClient\CayenneMQTTClient.c:227:2: warning: implicit declaration of function 'dtostrf' [-Wimplicit-function-declaration]

  dtostrf(value, 5, 3, str);

  ^

C:\Users\mauri\Documents\Arduino\libraries\CayenneMQTT\src\CayenneUtils\CayenneUtils.c: In function 'buildSuffix':

C:\Users\mauri\Documents\Arduino\libraries\CayenneMQTT\src\CayenneUtils\CayenneUtils.c:88:15: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]

   topicString = COMMAND_STRING;

           ^

C:\Users\mauri\Documents\Arduino\libraries\CayenneMQTT\src\CayenneUtils\CayenneUtils.c:91:15: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]

   topicString = DATA_STRING;

           ^

C:\Users\mauri\Documents\Arduino\libraries\CayenneMQTT\src\CayenneUtils\CayenneUtils.c:94:15: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]

   topicString = RESPONSE_STRING;

           ^

C:\Users\mauri\Documents\Arduino\libraries\CayenneMQTT\src\CayenneUtils\CayenneUtils.c:97:15: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]

   topicString = SYS_MODEL_STRING;

           ^

C:\Users\mauri\Documents\Arduino\libraries\CayenneMQTT\src\CayenneUtils\CayenneUtils.c:100:15: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]

   topicString = SYS_VERSION_STRING;

           ^

C:\Users\mauri\Documents\Arduino\libraries\CayenneMQTT\src\CayenneUtils\CayenneUtils.c:103:15: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]

   topicString = SYS_CPU_MODEL_STRING;

           ^

C:\Users\mauri\Documents\Arduino\libraries\CayenneMQTT\src\CayenneUtils\CayenneUtils.c:106:15: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]

   topicString = SYS_CPU_SPEED_STRING;

           ^

C:\Users\mauri\Documents\Arduino\libraries\CayenneMQTT\src\CayenneUtils\CayenneDataArray.c: In function 'CayenneDataArrayAddInt':

C:\Users\mauri\Documents\Arduino\libraries\CayenneMQTT\src\CayenneUtils\CayenneDataArray.c:87:2: warning: implicit declaration of function 'itoa' [-Wimplicit-function-declaration]

  itoa(value, str, 10);

  ^

C:\Users\mauri\Documents\Arduino\libraries\CayenneMQTT\src\CayenneUtils\CayenneDataArray.c: In function 'CayenneDataArrayAddUInt':

C:\Users\mauri\Documents\Arduino\libraries\CayenneMQTT\src\CayenneUtils\CayenneDataArray.c:105:2: warning: implicit declaration of function 'utoa' [-Wimplicit-function-declaration]

  utoa(value, str, 10);

  ^

C:\Users\mauri\Documents\Arduino\libraries\CayenneMQTT\src\CayenneUtils\CayenneDataArray.c: In function 'CayenneDataArrayAddLong':

C:\Users\mauri\Documents\Arduino\libraries\CayenneMQTT\src\CayenneUtils\CayenneDataArray.c:123:2: warning: implicit declaration of function 'ltoa' [-Wimplicit-function-declaration]

  ltoa(value, str, 10);

  ^

C:\Users\mauri\Documents\Arduino\libraries\CayenneMQTT\src\CayenneUtils\CayenneDataArray.c: In function 'CayenneDataArrayAddULong':

C:\Users\mauri\Documents\Arduino\libraries\CayenneMQTT\src\CayenneUtils\CayenneDataArray.c:141:2: warning: implicit declaration of function 'ultoa' [-Wimplicit-function-declaration]

  ultoa(value, str, 10);

  ^

C:\Users\mauri\Documents\Arduino\libraries\CayenneMQTT\src\CayenneUtils\CayenneDataArray.c: In function 'CayenneDataArrayAddDouble':

C:\Users\mauri\Documents\Arduino\libraries\CayenneMQTT\src\CayenneUtils\CayenneDataArray.c:159:2: warning: implicit declaration of function 'dtostrf' [-Wimplicit-function-declaration]

  dtostrf(value, 5, 3, str);

  ^

O sketch usa 24844 bytes (9%) de espaço de armazenamento para programas. O máximo são 253952 bytes.
Variáveis globais usam 1145 bytes (13%) de memória dinâmica, deixando 7047 bytes para variáveis locais. O máximo são 8192 bytes.

#2

can you share the code you are using,


#3

I’m using the Manual Connection source code:

/*
This example shows how to connect to Cayenne using a manually specified Ethernet connection and send/receive sample data.

The CayenneMQTT Library is required to run this sketch. If you have not already done so you can install it from the Arduino IDE Library Manager.

Steps:
1. Set the Cayenne authentication info to match the authentication info from the Dashboard.
2. Compile and upload the sketch.
3. A temporary widget will be automatically generated in the Cayenne Dashboard. To make the widget permanent click the plus sign on the widget.
*/

//#define CAYENNE_DEBUG       // Uncomment to show debug messages
#define CAYENNE_PRINT Serial  // Comment this out to disable prints and save space
#include <CayenneMQTTEthernet.h>
//#include <CayenneMQTTEthernetW5500.h> // Uncomment this and comment out CayenneMQTTEthernet.h to use an Ethernet 2 shield or other Ethernet W5500 shield.
                                    // You will need the Ethernet2 library installed. See the ArduinoEthernetW5500 example sketch for more info.
//#include <CayenneMQTTEthernetW5200.h> // Uncomment this and comment out CayenneMQTTEthernet.h to use an Ethernet W5200 shield.
                                    // You will need the EthernetW5200 library installed. See the ArduinoEthernetW5200 example sketch for more info.

// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username[] = "8fd42ce0-bec2-11e8-bf81-6b1a7e6fd7d2";
char password[] = "942fbf9ab708d9f343cad4dfd35490e84ab90152";
char clientID[] = "ef6fb850-c597-11e8-b882-b98903039cac";

// Mac address should be different for each device in your LAN
byte arduino_mac[] = { 0xDE, 0xED, 0xBA, 0xFE, 0xFE, 0xED };
IPAddress arduino_ip(10, 0, 0, 20);
IPAddress dns_ip(8, 8, 8, 8);
IPAddress gateway_ip(192,168, 0, 2);
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());
  // Some examples of other functions you can use to send data.
  //Cayenne.celsiusWrite(1, 22.0);
  //Cayenne.luxWrite(2, 700);
  //Cayenne.virtualWrite(3, 50, TYPE_PROXIMITY, UNIT_CENTIMETER);
}

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

#4

can you check what is the version of cayenne library you are using.


#5

Its 1.2.0


#6

why have you include all device in the sketch which is opened in IDE behind?


#7

Ohh that happened just before I captured the screen. The code was like i showed to you a few awnsers ago.


#8

i am not sure why you are having those error, i compiled your code at my end and it did not give any error. Can you try deleting and reinstalling the library.


#9

Should I set the gateway to the same one the router uses?


#10

the problem here right now is you are not able to upload the code to your arduino mega?


#11

It shows an error and then complete the 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:14:

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)) {

                                                           ^

C:\Users\mauri\Documents\Arduino\libraries\CayenneMQTT\src\CayenneMQTTClient\CayenneMQTTClient.c: In function 'CayenneMQTTPublishDataInt':

C:\Users\mauri\Documents\Arduino\libraries\CayenneMQTT\src\CayenneMQTTClient\CayenneMQTTClient.c:135:2: warning: implicit declaration of function 'itoa' [-Wimplicit-function-declaration]

  itoa(value, str, 10);

  ^

C:\Users\mauri\Documents\Arduino\libraries\CayenneMQTT\src\CayenneMQTTClient\CayenneMQTTClient.c: In function 'CayenneMQTTPublishDataUInt':

C:\Users\mauri\Documents\Arduino\libraries\CayenneMQTT\src\CayenneMQTTClient\CayenneMQTTClient.c:158:2: warning: implicit declaration of function 'utoa' [-Wimplicit-function-declaration]

  utoa(value, str, 10);

  ^

C:\Users\mauri\Documents\Arduino\libraries\CayenneMQTT\src\CayenneMQTTClient\CayenneMQTTClient.c: In function 'CayenneMQTTPublishDataLong':

C:\Users\mauri\Documents\Arduino\libraries\CayenneMQTT\src\CayenneMQTTClient\CayenneMQTTClient.c:181:2: warning: implicit declaration of function 'ltoa' [-Wimplicit-function-declaration]

  ltoa(value, str, 10);

  ^

C:\Users\mauri\Documents\Arduino\libraries\CayenneMQTT\src\CayenneMQTTClient\CayenneMQTTClient.c: In function 'CayenneMQTTPublishDataULong':

C:\Users\mauri\Documents\Arduino\libraries\CayenneMQTT\src\CayenneMQTTClient\CayenneMQTTClient.c:204:2: warning: implicit declaration of function 'ultoa' [-Wimplicit-function-declaration]

  ultoa(value, str, 10);

  ^

C:\Users\mauri\Documents\Arduino\libraries\CayenneMQTT\src\CayenneMQTTClient\CayenneMQTTClient.c: In function 'CayenneMQTTPublishDataDouble':

C:\Users\mauri\Documents\Arduino\libraries\CayenneMQTT\src\CayenneMQTTClient\CayenneMQTTClient.c:227:2: warning: implicit declaration of function 'dtostrf' [-Wimplicit-function-declaration]

  dtostrf(value, 5, 3, str);

  ^

C:\Users\mauri\Documents\Arduino\libraries\CayenneMQTT\src\CayenneUtils\CayenneUtils.c: In function 'buildSuffix':

C:\Users\mauri\Documents\Arduino\libraries\CayenneMQTT\src\CayenneUtils\CayenneUtils.c:88:15: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]

   topicString = COMMAND_STRING;

           ^

C:\Users\mauri\Documents\Arduino\libraries\CayenneMQTT\src\CayenneUtils\CayenneUtils.c:91:15: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]

   topicString = DATA_STRING;

           ^

C:\Users\mauri\Documents\Arduino\libraries\CayenneMQTT\src\CayenneUtils\CayenneUtils.c:94:15: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]

   topicString = RESPONSE_STRING;

           ^

C:\Users\mauri\Documents\Arduino\libraries\CayenneMQTT\src\CayenneUtils\CayenneUtils.c:97:15: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]

   topicString = SYS_MODEL_STRING;

           ^

C:\Users\mauri\Documents\Arduino\libraries\CayenneMQTT\src\CayenneUtils\CayenneUtils.c:100:15: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]

   topicString = SYS_VERSION_STRING;

           ^

C:\Users\mauri\Documents\Arduino\libraries\CayenneMQTT\src\CayenneUtils\CayenneUtils.c:103:15: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]

   topicString = SYS_CPU_MODEL_STRING;

           ^

C:\Users\mauri\Documents\Arduino\libraries\CayenneMQTT\src\CayenneUtils\CayenneUtils.c:106:15: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]

   topicString = SYS_CPU_SPEED_STRING;

           ^

C:\Users\mauri\Documents\Arduino\libraries\CayenneMQTT\src\CayenneUtils\CayenneDataArray.c: In function 'CayenneDataArrayAddInt':

C:\Users\mauri\Documents\Arduino\libraries\CayenneMQTT\src\CayenneUtils\CayenneDataArray.c:87:2: warning: implicit declaration of function 'itoa' [-Wimplicit-function-declaration]

  itoa(value, str, 10);

  ^

C:\Users\mauri\Documents\Arduino\libraries\CayenneMQTT\src\CayenneUtils\CayenneDataArray.c: In function 'CayenneDataArrayAddUInt':

C:\Users\mauri\Documents\Arduino\libraries\CayenneMQTT\src\CayenneUtils\CayenneDataArray.c:105:2: warning: implicit declaration of function 'utoa' [-Wimplicit-function-declaration]

  utoa(value, str, 10);

  ^

C:\Users\mauri\Documents\Arduino\libraries\CayenneMQTT\src\CayenneUtils\CayenneDataArray.c: In function 'CayenneDataArrayAddLong':

C:\Users\mauri\Documents\Arduino\libraries\CayenneMQTT\src\CayenneUtils\CayenneDataArray.c:123:2: warning: implicit declaration of function 'ltoa' [-Wimplicit-function-declaration]

  ltoa(value, str, 10);

  ^

C:\Users\mauri\Documents\Arduino\libraries\CayenneMQTT\src\CayenneUtils\CayenneDataArray.c: In function 'CayenneDataArrayAddULong':

C:\Users\mauri\Documents\Arduino\libraries\CayenneMQTT\src\CayenneUtils\CayenneDataArray.c:141:2: warning: implicit declaration of function 'ultoa' [-Wimplicit-function-declaration]

  ultoa(value, str, 10);

  ^

C:\Users\mauri\Documents\Arduino\libraries\CayenneMQTT\src\CayenneUtils\CayenneDataArray.c: In function 'CayenneDataArrayAddDouble':

C:\Users\mauri\Documents\Arduino\libraries\CayenneMQTT\src\CayenneUtils\CayenneDataArray.c:159:2: warning: implicit declaration of function 'dtostrf' [-Wimplicit-function-declaration]

  dtostrf(value, 5, 3, str);

  ^

O sketch usa 24842 bytes (9%) de espaço de armazenamento para programas. O máximo são 253952 bytes.
Variáveis globais usam 1145 bytes (13%) de memória dinâmica, deixando 7047 bytes para variáveis locais. O máximo são 8192 bytes.

This message says to me It was completed.(It’s in portuguese)


#12

#define CAYENNE_DEBUG can you add this line and check the serial monitor?
some things to change in your code:

  IPAddress arduino_ip(10, 0, 0, 20);

set the address (192, 168, 1, x); where x is from 2 to 253

 IPAddress gateway_ip(192,168, 0, 2);

the default gateway address is 192.168.1.1


#13


The first one is the ethernet adapter that is a cable connected to the router that is connected to the Ethernet shield.
The second is my wifi network adapter
If I put 192.168.1.1 its going to be out of the network,isn’t it?


#14

looking at your image try changing IPAddress gateway_ip(192,168, 0, 1); and IPAddress arduino_ip (192,168, 0, x);


#15

Now the error is smaller. And completed the upload again.

    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:14:

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)) {

                                                               ^

O sketch usa 25386 bytes (9%) de espaço de armazenamento para programas. O máximo são 253952 bytes.
Variáveis globais usam 1157 bytes (14%) de memória dinâmica, deixando 7035 bytes para variáveis locais. O máximo são 8192 bytes.

#16

Look I changed everything you asked and look what is happening at serial monitor.


#17

can you login into your router and check what is the Preferred DNS server and Alternate DNS server


#18

Which router the one connected between the computer and the arduino or the one that is my wifi?


#19

you have connected your arduino to the router?
Also check if some network firewall blocking traffic to mqtt.mydevices.com or port 1883.
can you reupload W5100 code and share the serial output.


#20

Connection Sequence:

Arduino----Router(using like a switch)------ Computer-----RouterWifi