No connexion in arduino project

I have a project based in arduino. Sometimes, when I turn on the system, it cannot connect properly with cayenne´s server. In those cases, it stops in sentence “Cayenne.begin(username, password, clientID);” and, obviously, the whole project doesn´t run.

is it possible to include (in arduino receipt) something after “Cayenne.begin(username, password, clientID)” in order to know it the connexion is ok (or not) and repeat it until get this connexion?.

Another question: is it possible to send a short text message from arduino to cayenne and show it a text box in the app?

Thank you in advance.

this stops, because there is no internet connection available to your device. it does what your asking internally, that is check and wait till the connection is available.

Thank you for your answer. I have check the internet connection and it´s ok but, the arduino´s project doesn´t connect. Right now it is connect (wired) directly to the router.

Maybe, the arduino internet shield isn´t running properly. It is only explanation that i can find but, it will be extrange because it runs sometimes and sometimes not.

could you have another idea about my problem?. Maybe, cayenne server has some restriction about the number of connections…

some idea about send text messages from arduino to cayenne (for example “device alarm” or “device ok”?

Thank you again.

Regards

this is not possible.

Regarding your issue with arduino, can you share the code and the serial monitor output when the disconnect occurs. Add the #define CAYENNE_DEBUG to provide more info

I have added #define CAYENNE_DEBUG and i´m getting the below message in the serial monitor output:

[2392] MAC: FE-33-A5-AF-8E-A

Really, it isn´t a disconnect because, it never gets a connection with the server. The serial monitor show this message at the beginning of excecution and nothing else. I have included several control messages in the loop part in arduino´s receipt but they aren´t shown because it stops in the SETUP sentence “Cayenne.begin(username, password, clientID);”

I don´t know if it gets a MAC address means that it is connected to internet properly. If it is true, i don´t know why it doesn´t follow with the next steps.

Thank you for your help (and apologize about my horrible english)

Regards

Does pressing reset button on the arduino, makes the device online and output anything more in the serial monitor?

I have started the device and it has written the next message in serial monitor:

[2401] MAC: FE-33-A5-AF-8E-A

several second after, i have pressed the arduino´s reset button and, it has written:

[3277] MAC: FE-33-A5-AF-8E-A

Several second after, i have repeated and the message has been:

[3177] MAC: FE-33-A5-AF-8E-A

Regards

Are you able to connect your arduino to internet using other sketch code. can you try this https://www.arduino.cc/en/Tutorial/WebClient

Yes, i have used your sketch and i have got the following message in the serial monitor. After this text it comes an never-end list of text.

does it give an idea to you about the connection problem?

Regards

⸮Initialize Ethernet with DHCP:
DHCP assigned IP 192.168.1.44
connecting to www.google.com
connected to 172.217.168.164
HTTP/1.1 200 OK
Content-Type: text/html; charset=ISO-8859-1
Expires: -1
Cache-Control: private, max-age=0
P3P: CP=“This is not a P3P policy! See g.co/p3phelp for more info.”
Server: gws
X-XSS-Protection: 0
X-Frame-Options: SAMEORIGIN
Set-Cookie: 1P_JAR=2019-09-27-19; expires=Sun, 27-Oct-2019 19:27:05 GMT; path=/; domain=.google.com; SameSite=none
Set-Cookie: CGIC=; expires=Wed, 25-Mar-2020 19:27:05 GMT; path=/complete/search; domain=.google.com; HttpOnly
Set-Cookie: CGIC=; expires=Wed, 25-Mar-2020 19:27:05 GMT; path=/search; domain=.google.com; HttpOnly
Set-Cookie: NID=188=WQOld3W-Y8AXCRKoLCMAKFsgbvQe7HNTAtecY6ZE31ZsvwB5o_Kb-NTCBUL9fYw_2jt6qfX71nXWr-y-FYmuCpS_x50PcPuonuG6OvvOS9aqX2e8QtWc5xX0fAhQAKcFZwEH841lr5QMf9RvwVYzJb5FV52PqtzNSXbLOhhMi3U; expires=Sat, 28-Mar-2020 19:27:05 GMT; path=/; domain=.google.com; HttpOnly
Accept-Ranges: none
Vary: Accept-Encoding
Connection: close

can you try this code https://github.com/256dpi/arduino-mqtt/blob/master/examples/ArduinoEthernetShield/ArduinoEthernetShield.ino

I´m try to install your new sketch and I´m getting the following error message when the sketch is compiled.

#include <MQTT.h>. No such file such file or directory”

I suppose that i have to install a new library in order to avoid this error. I´m looking for “mqtt” and find a lot of them. I don´t know what is the right one. Could you help me?

Regards

can you download and install this library https://github.com/256dpi/arduino-mqtt

I have run this sketch and i get only one character in monitor serial, sometimes “?” and sometimes one letter.

it´s a strange result.

what can we do in this case?

I have tried with another arduino UNO and the same internet shield and i get the same result. So if it isn´t run, i think that (maybe) the internet shield doesn’t run properly.

Thank you for your patience.

Regards

see if the network firewall is blocking traffic to mqtt.mydevices.com or port 1883.

I have done the following actions:

  1. I have checked with my internet´s provider company and, mqtt.mydevices.com isn´t blocked.

  2. I have open the port 1883 in my router with the fixed internal IP number 192.168.1.41 and MAC 78:0F::77:D4:42::DB

  3. I have included the sentence: “byte mac = { 0x78, 0x0F, 0x77, 0xD4, 0x42, 0xDB };” in my arduino´s sketch

  4. I have run my cayenne sketch in arduino.

  5. unfortunately, I have got the same message in serial monitor:

[6246] MAC: FE-33-A5-AF-8E-A

This MAC isn´t the My arduino one (whitch is
78:0F::77:D4:42::DB). Could it be this the problem?. In this case, have we any way to force the same MAC number?.

Thank you again.

Regards

try this code and set the parameters. https://github.com/myDevicesIoT/Cayenne-MQTT-Arduino/blob/master/examples/Connections/ManualConnection/ManualConnection.ino

i know the value of mac and IPAddress arduno, so i have included in the sketch:

byte mac = { 0x78, 0x0F, 0x77, 0xD4, 0x42, 0xDB };

and

IPAddress arduino_ip(192,168, 1, 41);

But, what do i have to write in the following parameters?

IPAddress dns_ip

IPAddress gateway_ip
IPAddress subnet_mask

could you help me?

Thanks a lot

[560] IP: 192.168.1.41
[561] Connecting to mqtt.mydevices.com:1883
[15805] Network connect failed
[31835] Network connect failed

you will find them in your router settings

I can´t believe it !!!

i have got the following message:

[560] IP: 192.168.1.41
[561] Connecting to mqtt.mydevices.com:1883
[1027] Connected

can i change those parameters in my original sketch and it will run properly?

Thank you

Regards

you will have to use this sketch only, as you are setting the parameters manually.