Getting "multiple definition of" error while connecting Opla Kit to the cloud

Hello!
I bought OplaIoTKit a few days ago. I finished the "Get to know The Carrier" lesson. Now I am doing the "Get to know the cloud" lesson and I got stuck.

The problem is writing the code in the sketch after creating the dashboard.

First, the void setup() function of the code written in the lesson https://opla.arduino.cc/opla/module/cloud/lesson/get-to-know-the-cloud, is not the same. My project generates the following function:

void setup() {
  // Initialize serial and wait for port to open:
  Serial.begin(9600);
  // This delay gives the chance to wait for a Serial Monitor without blocking if none is found
  delay(1500); 

  // Defined in thingProperties.h
  initProperties();

  // Connect to Arduino IoT Cloud
  ArduinoCloud.begin(ArduinoIoTPreferredConnection);
  
  /*
     The following function allows you to obtain more information
     related to the state of network and IoT Cloud connection and errors
     the higher number the more granular information you’ll get.
     The default is 0 (only errors).
     Maximum is 4
 */
  setDebugMessageLevel(2);
  ArduinoCloud.printDebugInfo();
}

I assume even though the code differs from the one from the lesson, it is correct, so I did not change anything.

Second, when I add all the missing code, as written in the lesson, I get the following error:
libraries/arduino_mkriotcarrier_0_9_8/Arduino_MKRIoTCarrier.cpp.o:(.bss.CARRIER_CASE+0x0): multiple definition of `CARRIER_CASE' sketch/Untitled_feb06a.ino.cpp.o:(.bss.CARRIER_CASE+0x0): first defined here collect2: error: ld returned 1 exit status exit status 1

If I delete the line "bool CARRIER_CASE = false;" from the top of the code, there is no more errors, but when I check the Serial Monitor tab, it does not say that my Arduino is connected to the cloud or Wi-Fi network.

I tried to copy the whole code from the lesson into my sketch, but the result is the same.

Any ideas?

why don't you put

 CARRIER_CASE = false;

directly in the setup() as they do in the example?

(you can't re-declare this variable as it's already declared here in the Arduino_MKRIoTCarrier library)

Thank you very much, your help did the trick! And thank you for the explanation.
I am fairly new at programming and I just copied the code here, that is why I put it on the top: https://opla.arduino.cc/opla/module/cloud/lesson/get-to-know-the-cloud

have fun!
don't worry we all started from not knowing much.

Hi, I hit this same problem and figured out that that sketch at https://opla.arduino.cc/opla/module/cloud/lesson/get-to-know-the-cloud is the problem - it has the CARRIER-CASE = false/true statement in a place in the code that causes the problem.

I'm running into a number of these issues as I work through the Opla examples - is there someway to report these as documentation bugs??

Thanks, John P.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.