New Topic - Error in IoT Cloud Kit Tutorial

I am getting this error from the tutorial from the IoT Cloud Kit (Which uses the Arduino MKR WiFi 1010:

libraries/arduino_mkriotcarrier_0_9_9/Arduino_MKRIoTCarrier.cpp.o:(.bss.CARRIER_CASE+0x0): multiple definition of `CARRIER_CASE' sketch/Activity_2_apr13b.ino.cpp.o:(.bss.CARRIER_CASE+0x0): first defined here collect2: error: ld returned 1 exit status exit status 1

libraries/arduino_mkriotcarrier_0_9_9/Arduino_MKRIoTCarrier.cpp.o:(.bss.CARRIER_CASE+0x0): multiple definition of `CARRIER_CASE' sketch/Activity_2_apr13b.ino.cpp.o:(.bss.CARRIER_CASE+0x0): first defined here collect2: error: ld returned 1 exit status exit status 1  

Here's my URL:

https://create.arduino.cc/iot/things/bae19aef-44e1-4aa7-958d-2d23eb32eddd/setup

I also have a Arduino Mega on another port so I am wondering if this is a conflict because of the libraries. I use the Arduino IDE on this other port.

I commented out this line in the code and got it to compile with a lot of messages but didn't get it working when the sketch was downloaded to the carrier:

bool CARRIER_CASE = false;

Here's the whole sketch:

#include "thingProperties.h"
#include <Arduino_MKRIoTCarrier.h>  
MKRIoTCarrier carrier;
bool CARRIER_CASE = false;

/* 
  Sketch generated by the Arduino IoT Cloud Thing "Activity 2"
  https://create.arduino.cc/cloud/things/bae19aef-44e1-4aa7-958d-2d23eb32eddd 

  Arduino IoT Cloud Variables description

  The following variables are automatically generated and updated when changes are made to the Thing

  float humidity;
  float temperature;

  Variables which are marked as READ/WRITE in the Cloud Thing will also have functions
  which are called when their values are changed from the Dashboard.
  These functions are generated with the Thing and added at the end of this sketch.
*/



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

void loop() {
	ArduinoCloud.update();
	// Your code here 
	temperature = carrier.Env.readTemperature();
  humidity = carrier.Env.readHumidity();
	
  Serial.print(temperature);
	Serial.print(",");
	Serial.println(humidity);
	
	delay(1000);
  
}

I tried the code on a second machine, fresh install, have the same error(s).

Hi @jglogau! Yes, there was a typo in the Oplà instructions. Just remove the bool keyword before CARRIER_CASE and it will compile (better than removing the entire line, because you can just turn it to true when you put it in the plastic enclosure).

You said it does not work when uploaded to the board. What happens exactly? Are you uploading from the IoT Cloud web interface? Did you double check that the wifi credentials are correct? If they are not correct, the board will not be able to connect to the cloud and will fail silently (actually, if you open the Serial Monitor section you will see errors coming from the board, and they will help you troubleshoot).

Give us more details and we will gladly help you :slight_smile:

Removed the bool, Here's the error messages.

/tmp/033916169/Activity_2_apr14a/Activity_2_apr14a.ino:5:1: error: 'CARRIER_CASE' does not name a type CARRIER_CASE = false; ^~~~~~~~~~~~ exit status 1
/tmp/033916169/Activity_2_apr14a/Activity_2_apr14a.ino:5:1: error: 'CARRIER_CASE' does not name a type CARRIER_CASE = false; ^~~~~~~~~~~~ exit status 1

If I read some of the help boards correctly having the message repeat is an indication that the error is "someplace else"

I also tried an extern, but that didn't work either.

Yes, I am using the IoT Cloud web interface.

BUT, I also can't get the Arduino system tray to turn greenish blue, it's that dirty white.

When you say my WiFi, you mean my local home network, correct? I have a little baby network running off the Wifi shield on my Mega
with its own IP that doesn't talk to the Internet. Just using an old phone as a controller for my trains

I am sorry I didn't say this in my earlier email.

THANK YOU VERY MUCH :grinning:

No need to say thank you, the typo in the instructions is totally our fault! :see_no_evil:

I gave you an incomplete information: in addition to removing bool you need to move that line inside setup(). Try this complete code:

#include "thingProperties.h"
#include <Arduino_MKRIoTCarrier.h>
MKRIoTCarrier carrier;
 
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);
 
  //Get Cloud Info/errors , 0 (only errors) up to 4
  setDebugMessageLevel(2);
  ArduinoCloud.printDebugInfo();
 
  //Wait to get cloud connection to init the carrier
  while (ArduinoCloud.connected() != 1) {
    ArduinoCloud.update();
    delay(500);
  }
 
  delay(500);
  CARRIER_CASE = false;
  carrier.begin();
  carrier.display.setRotation(0);
  
}
 
void loop() {
  ArduinoCloud.update();
 
  temperature = carrier.Env.readTemperature();
  humidity = carrier.Env.readHumidity();
 
  delay(1000);
}

Yes, you need to enter the credentials of your home network! They will be injected into the Arduino board so that it can access the Internet and connect to the cloud :cloud:

Alessandro:

Yes, all the pieces are working together, including the dashboard, thanks again.

I have a question:

As I was looking at the error messages I saw that underneath things are "real" C++ modules (cpp)? As I tried to find a way to fix the errors I went looking for the right libraries and realized they weren't on my machine.

Is Arduino code full C++ or a simplified version?

What if you want to create Arduino code but hook it to a regular SQL database, can that be done?

Regards,
Jordan

1 Like

Happy to hear everything is working!

Yes, Arduino is C++ so you can use its full syntax to write your code. If you use the web editor, libraries are stored on the cloud so you'll not find them on your machine. If you use the Arduino IDE, libraries get installed locally and they are plain C++ files.

Regarding SQL, there are some libraries implementing client protocols for popular database servers, such as this one: MySQL Connector Arduino - Arduino Reference
You'll need to experiment a bit to understand if this solution is viable and reliable, since you're operating in an environment with limited RAM compared to a normal machine.
Another simpler solution would be to call a HTTP API which then writes to the database, so you don't need to implement the database client on the Arduino.

What is your use case?

Alessandro:

I have worked with MySQL on numerous projects. The install used to be an issue but less so today. However I agree, using an HTTP API is a path of least resistance, see below

I got into the Arduino family because of model railroading so I started with a Mega, I understand memory limitations.

I think using a HTTP API makes a lot of sense, it seems like there are a number of approaches to the client and server solution. Any suggestions where to start reading about an approach? I assume that it doesn't matter if it's HTTPS?

Looking to gather data from sensors for office plants and office gardens, it would be a way for garden service companies to maintain plants in tiptop shape. Yes, the price per unit would have to be very low, also portable and last longer than your average garden consumable.

Regards,
Jordan Glogau

It's easy, you basically use the ArduinoHttpClient library to perform HTTP calls to your server. Then you're free to implement the server however you want. HTTPS is easily achieved; you just need to load the TLS server certificate to the Arduino board using the IDE like explained here: https://support.arduino.cc/hc/en-us/articles/360016119219-How-to-add-certificates-to-Wifi-Nina-Wifi-101-Modules-

I'd also advise to consider building your system on top of the Arduino IoT Cloud which provides a reliable infrastructure to collect data and visualize it, without worrying about backend development, scaling, security etc. - at least in the prototyping phase

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