Arduino goes offline when uploading code


#1

I using :

  • Arduino Uno with W5100 ethernet shield,
  • Web dashboard.

When loading a new sketch from Cayenne, Arduino disconnects, is it offline and requested to turn on the device.
What can be wrong ?
I hope your help.


#2

check your serial monitor for what causing the arduino to get offline.


#3

I see in the serial monitor:
[0] MAC: … (submitted)
[2514] IP: … (submitted)
[2515] Connecting to mqtt.mydevices.com: … (submitted)
[2891] Connected

IP address is pinging by Command Prompt.


#4

so it doesnt reconnect afterwards? it will disconnect and reconnect when you load a new sketch by default


#5

Was no OFFLINE for a while.
In the Arduino IDE I overwritte the example sketch from the dashboard record.
I hav an error message when I upload an sketch.
After a few attempts to upload, the error did not disappear, but the OFFLINE state appeared.

Upload sketch error:
C:\Users\Ramunas\AppData\Local\Temp\ccaETQfx.ltrans1.ltrans.o: In function `setup’:

C:\Users\Ramunas\AppData\Local\Temp\arduino_modified_sketch_998849/sketch_mar09a.ino:29: undefined reference to `DHT::begin()’

C:\Users\Ramunas\AppData\Local\Temp\ccaETQfx.ltrans1.ltrans.o: In function `loop’:

C:\Users\Ramunas\AppData\Local\Temp\arduino_modified_sketch_998849/sketch_mar09a.ino:37: undefined reference to `DHT::readHumidity(bool)’

C:\Users\Ramunas\AppData\Local\Temp\arduino_modified_sketch_998849/sketch_mar09a.ino:38: undefined reference to `DHT::readTemperature(bool, bool)’

C:\Users\Ramunas\AppData\Local\Temp\arduino_modified_sketch_998849/sketch_mar09a.ino:39: undefined reference to `DHT::readTemperature(bool, bool)’

C:\Users\Ramunas\AppData\Local\Temp\arduino_modified_sketch_998849/sketch_mar09a.ino:46: undefined reference to `DHT::readHumidity(bool)’

C:\Users\Ramunas\AppData\Local\Temp\arduino_modified_sketch_998849/sketch_mar09a.ino:47: undefined reference to `DHT::readTemperature(bool, bool)’

C:\Users\Ramunas\AppData\Local\Temp\ccaETQfx.ltrans8.ltrans.o: In function `__static_initialization_and_destruction_0’:

C:\Users\Ramunas\AppData\Local\Temp\arduino_modified_sketch_998849/sketch_mar09a.ino:13: undefined reference to `DHT::DHT(unsigned char, unsigned char, unsigned char)’

collect2.exe: error: ld returned 1 exit status


#6

Now, after a while that OFFLINE status has disappeared .
But how to avoid sketch error?


#7

These error lines are shown first:
In file included from C:\Users\Ramunas\Desktop\arduino-1.8.3-windows\arduino-1.8.3\portable\sketchbook\libraries\CayenneMQTT\src/CayenneMQTTClient/CayenneMQTTClient.h:24:0,

             from C:\Users\Ramunas\Desktop\arduino-1.8.3-windows\arduino-1.8.3\portable\sketchbook\libraries\CayenneMQTT\src/CayenneMessage.h:32,

             from C:\Users\Ramunas\Desktop\arduino-1.8.3-windows\arduino-1.8.3\portable\sketchbook\libraries\CayenneMQTT\src/CayenneHandlers.h:29,

             from C:\Users\Ramunas\Desktop\arduino-1.8.3-windows\arduino-1.8.3\portable\sketchbook\libraries\CayenneMQTT\src/CayenneArduinoDefines.h:128,

             from C:\Users\Ramunas\Desktop\arduino-1.8.3-windows\arduino-1.8.3\portable\sketchbook\libraries\CayenneMQTT\src/CayenneArduinoMQTTClient.h:21,

             from C:\Users\Ramunas\Desktop\arduino-1.8.3-windows\arduino-1.8.3\portable\sketchbook\libraries\CayenneMQTT\src/CayenneMQTTEthernetClient.h:21,

             from C:\Users\Ramunas\Desktop\arduino-1.8.3-windows\arduino-1.8.3\portable\sketchbook\libraries\CayenneMQTT\src/CayenneMQTTEthernet.h:25,

             from C:\Users\Ramunas\AppData\Local\Temp\arduino_modified_sketch_751057\sketch_mar09a.ino:4:

C:\Users\Ramunas\Desktop\arduino-1.8.3-windows\arduino-1.8.3\portable\sketchbook\libraries\CayenneMQTT\src/CayenneMQTTClient/…/CayenneUtils/CayenneDataArray.h:328:30: warning: type qualifiers ignored on function return type [-Wignored-qualifiers]

  const size_t getCount() const {

                          ^

In file included from C:\Users\Ramunas\Desktop\arduino-1.8.3-windows\arduino-1.8.3\portable\sketchbook\libraries\CayenneMQTT\src/CayenneMQTTEthernetClient.h:21:0,

             from C:\Users\Ramunas\Desktop\arduino-1.8.3-windows\arduino-1.8.3\portable\sketchbook\libraries\CayenneMQTT\src/CayenneMQTTEthernet.h:25,

             from C:\Users\Ramunas\AppData\Local\Temp\arduino_modified_sketch_751057\sketch_mar09a.ino:4:

C:\Users\Ramunas\Desktop\arduino-1.8.3-windows\arduino-1.8.3\portable\sketchbook\libraries\CayenneMQTT\src/CayenneArduinoMQTTClient.h: In member function ‘void CayenneArduinoMQTTClient::connect()’:

C:\Users\Ramunas\Desktop\arduino-1.8.3-windows\arduino-1.8.3\portable\sketchbook\libraries\CayenneMQTT\src/CayenneArduinoMQTTClient.h:58:63: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]

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

                                                           ^

In file included from C:\Users\Ramunas\Desktop\arduino-1.8.3-windows\arduino-1.8.3\portable\sketchbook\libraries\CayenneMQTT\src/CayenneMQTTEthernetClient.h:21:0,

             from C:\Users\Ramunas\Desktop\arduino-1.8.3-windows\arduino-1.8.3\portable\sketchbook\libraries\CayenneMQTT\src/CayenneMQTTEthernet.h:25,

             from C:\Users\Ramunas\AppData\Local\Temp\arduino_modified_sketch_751057\sketch_mar09a.ino:4:

C:\Users\Ramunas\Desktop\arduino-1.8.3-windows\arduino-1.8.3\portable\sketchbook\libraries\CayenneMQTT\src/CayenneArduinoMQTTClient.h: At global scope:

C:\Users\Ramunas\Desktop\arduino-1.8.3-windows\arduino-1.8.3\portable\sketchbook\libraries\CayenneMQTT\src/CayenneArduinoMQTTClient.h:311:23: warning: unused parameter ‘channel’ [-Wunused-parameter]

void syncVirtual(int channel)

                   ^

In file included from C:\Users\Ramunas\Desktop\arduino-1.8.3-windows\arduino-1.8.3\portable\sketchbook\libraries\CayenneMQTT\src/CayenneMQTTEthernet.h:25:0,

             from C:\Users\Ramunas\AppData\Local\Temp\arduino_modified_sketch_751057\sketch_mar09a.ino:4:

C:\Users\Ramunas\Desktop\arduino-1.8.3-windows\arduino-1.8.3\portable\sketchbook\libraries\CayenneMQTT\src/CayenneMQTTEthernetClient.h: In member function ‘void CayenneMQTTEthernetClient::begin(const char*, const char*, const char*, const byte*)’:

C:\Users\Ramunas\Desktop\arduino-1.8.3-windows\arduino-1.8.3\portable\sketchbook\libraries\CayenneMQTT\src/CayenneMQTTEthernetClient.h:43:13: warning: variable ‘local_ip’ set but not used [-Wunused-but-set-variable]

IPAddress local_ip = Ethernet.localIP();

         ^

C:\Users\Ramunas\Desktop\arduino-1.8.3-windows\arduino-1.8.3\portable\sketchbook\libraries\CayenneMQTT\src/CayenneMQTTEthernetClient.h: In member function ‘void CayenneMQTTEthernetClient::begin(const char*, const char*, const char*, IPAddress, const byte*)’:

C:\Users\Ramunas\Desktop\arduino-1.8.3-windows\arduino-1.8.3\portable\sketchbook\libraries\CayenneMQTT\src/CayenneMQTTEthernetClient.h:59:13: warning: variable ‘local_ip’ set but not used [-Wunused-but-set-variable]

IPAddress local_ip = Ethernet.localIP();

         ^

In file included from C:\Users\Ramunas\Desktop\arduino-1.8.3-windows\arduino-1.8.3\portable\sketchbook\libraries\CayenneMQTT\src/CayenneMQTTEthernet.h:25:0,

             from C:\Users\Ramunas\AppData\Local\Temp\arduino_modified_sketch_751057\sketch_mar09a.ino:4:

C:\Users\Ramunas\Desktop\arduino-1.8.3-windows\arduino-1.8.3\portable\sketchbook\libraries\CayenneMQTT\src/CayenneMQTTEthernetClient.h: In member function ‘void CayenneMQTTEthernetClient::begin(const char*, const char*, const char*, IPAddress, IPAddress, IPAddress, IPAddress, const byte*)’:

C:\Users\Ramunas\Desktop\arduino-1.8.3-windows\arduino-1.8.3\portable\sketchbook\libraries\CayenneMQTT\src/CayenneMQTTEthernetClient.h:78:13: warning: variable ‘local_ip’ set but not used [-Wunused-but-set-variable]

IPAddress local_ip = Ethernet.localIP();

         ^

C:\Users\Ramunas\Desktop\arduino-1.8.3-windows\arduino-1.8.3\portable\sketchbook\libraries\CayenneMQTT\src/CayenneMQTTEthernetClient.h: In member function ‘const byte* CayenneMQTTEthernetClient::GetMACAddress(const char*, const byte*)’:

C:\Users\Ramunas\Desktop\arduino-1.8.3-windows\arduino-1.8.3\portable\sketchbook\libraries\CayenneMQTT\src/CayenneMQTTEthernetClient.h:98:24: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]

((uint32_t)&_mac[2]) = fnv1a(token);


#8

Again Cayenne does not show attached Arduino when I try to load a new sketch.
Serial monitor image:
image
Cayenne Dashboard image:

Maybe, Is it a good idea to give Arduino a permanent IP address for trouble shooting?


#9

Hi Brendon.
How long waiting? I’m waiting for a long time - 3-5 min.


#10

It shouldnt be too long normally. You’re connecting but then you’re disconnecting though. Can you upload your code?


#11

Initially, I upload an Ethernet Shield W5100 sketch:

/*
This example shows how to connect to Cayenne using an Ethernet W5100 shield 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>

// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username[] = “f28…efd4”;
char password[] = “f46b7…75ef7d”;
char clientID[] = “01e…cd606”;

void setup() {
Serial.begin(9600);
Cayenne.begin(username, password, clientID);
}

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”);
}

in the serial monitor appears:
image

I have to restart my computer and Arduino so that the serial monitor displays full information (as I stated earlier).
I can not understand why there are such disturbances?
Could you help my figure out?


#12

ok so thats a very basic sketch so it shouldnt be an issue.

What board are you using with the w5100 board?
Is the ethernet from the w5100 connected directly to your router?

also you should edit out your client user and password from your pasted code for security reasons above.


#13

I’m using Arduino Uno.
W5100 Internet connection through the corporate network.


#14

what do you mean by corporate network?


#15

that mean a company LAN.
R.


#16

would there be anything firewall wise or network wise (ie your company has seen the IP address and decided to block it, or they dont hand out DHCP) at your company that could be stopping it? your sketch is very basic, i dont see what would stop that working - it literally cant be any more simple.

the only thing I would try is to delete your device and add a new one with a new mqtt ID etc


#17

In my case, the Arduino Ethernet Shield’s network administrator offers a fixed static IP address.
Is it appropriate to assign a static IP address? Will it not interfere with Arduino, Arduino Ethernet Shield and other device configurations, i.e. library selection, sketch writing?
In general, Can Cayenne operate with static IP address of the devices?

Thanks in the advance.
Ramunas1


#18

Sorry, do you mean your network admin has given your arduino sheild its own IP address?

If that is the case you can force your IP address in the arduino code, which you would need to do. If you go into your arduino IDE and look under examples > cayenne > internet connections, theres a manual connection option - you might want to add those settings to set your IP address statically to the address your network administrator has given you.

If thats not what you mean, let us know