Arduino IoT Verify and Upload Error

I keep getting some version of this error week after week for every project I work on:

/tmp/3251972954/The_Nerd_mar15b/The_Nerd_mar15b.ino: In function 'void onNerdsFoodChange()': /tmp/3251972954/The_Nerd_mar15b/The_Nerd_mar15b.ino:131:6: error: redefinition of 'void onNerdsFoodChange()' void onNerdsFoodChange() { ^~~~~~~~~~~~~~~~~ /tmp/3251972954/The_Nerd_mar15b/The_Nerd_mar15b.ino:121:6: note: 'void onNerdsFoodChange()' previously defined here void onNerdsFoodChange(){ ^~~~~~~~~~~~~~~~~ /tmp/3251972954/The_Nerd_mar15b/The_Nerd_mar15b.ino: In function 'void onNerdsTimeChange()': /tmp/3251972954/The_Nerd_mar15b/The_Nerd_mar15b.ino:138:6: error: redefinition of 'void onNerdsTimeChange()' void onNerdsTimeChange() { ^~~~~~~~~~~~~~~~~ /tmp/3251972954/The_Nerd_mar15b/The_Nerd_mar15b.ino:114:6: note: 'void onNerdsTimeChange()' previously defined here void onNerdsTimeChange(){ ^~~~~~~~~~~~~~~~~ Multiple libraries were found for "SPI.h" Used: /home/builder/.arduino15/packages/arduino/hardware/mbed_nano/4.1.1/libraries/SPI Not used: /home/builder/opt/libraries/eventethernet_1_0_0 Multiple libraries were found for "ECCX08.h" Used: /home/builder/opt/libraries/arduinoeccx08_1_3_8 Not used: /home/builder/opt/libraries/rak5814_atecc608a_1_0_0 Multiple libraries were found for "Wire.h" Used: /home/builder/.arduino15/packages/arduino/hardware/mbed_nano/4.1.1/libraries/Wire Not used: /home/builder/opt/libraries/flexwire_1_2_0 Multiple libraries were found for "WiFiNINA.h" Used: /home/builder/opt/libraries/wifinina_1_8_14 Not used: /home/builder/opt/libraries/vega_wifinina_1_0_1 Error during build: exit status 1

/tmp/3251972954/The_Nerd_mar15b/The_Nerd_mar15b.ino: In function 'void onNerdsFoodChange()': /tmp/3251972954/The_Nerd_mar15b/The_Nerd_mar15b.ino:131:6: error: redefinition of 'void onNerdsFoodChange()' void onNerdsFoodChange() { ^~~~~~~~~~~~~~~~~ /tmp/3251972954/The_Nerd_mar15b/The_Nerd_mar15b.ino:121:6: note: 'void onNerdsFoodChange()' previously defined here void onNerdsFoodChange(){ ^~~~~~~~~~~~~~~~~ /tmp/3251972954/The_Nerd_mar15b/The_Nerd_mar15b.ino: In function 'void onNerdsTimeChange()': /tmp/3251972954/The_Nerd_mar15b/The_Nerd_mar15b.ino:138:6: error: redefinition of 'void onNerdsTimeChange()' void onNerdsTimeChange() { ^~~~~~~~~~~~~~~~~ /tmp/3251972954/The_Nerd_mar15b/The_Nerd_mar15b.ino:114:6: note: 'void onNerdsTimeChange()' previously defined here void onNerdsTimeChange(){ ^~~~~~~~~~~~~~~~~ Multiple libraries were found for "SPI.h" Used: /home/builder/.arduino15/packages/arduino/hardware/mbed_nano/4.1.1/libraries/SPI Not used: /home/builder/opt/libraries/eventethernet_1_0_0 Multiple libraries were found for "ECCX08.h" Used: /home/builder/opt/libraries/arduinoeccx08_1_3_8 Not used: /home/builder/opt/libraries/rak5814_atecc608a_1_0_0 Multiple libraries were found for "Wire.h" Used: /home/builder/.arduino15/packages/arduino/hardware/mbed_nano/4.1.1/libraries/Wire Not used: /home/builder/opt/libraries/flexwire_1_2_0 Multiple libraries were found for "WiFiNINA.h" Used: /home/builder/opt/libraries/wifinina_1_8_14 Not used: /home/builder/opt/libraries/vega_wifinina_1_0_1 Error during build: exit status 1

I do the arduino IoT templates as assignments for a class, and the troubleshooting to actually get the verification to work is what takes the most time. I want to know how to fix this error for this specific instance, and what I have to do to stop this error from happening going forward? The current template I'm trying to use is "The Nerd." My computer does connect to and register that there is an arduino nano. I have gotten it to upload in the past before, but everytime it feels so so random. If someone can help me find some consistency or standardization so that I can have fewer troubles in the future and an easier time troubleshooting, that would be awesome!

Any help would be greatly appreciated!

Welcome to the forum

You started a topic in the Uncategorised category of the forum

Your topic has been moved to a relevant category. Please be careful in future when deciding where to start new topics

Please post the full sketch that you are working on, using code tags when you do

How many tabs have you got open in the IDE and what are their filenames ?

This is using the Arduino IoT cloud program. The code is the same code from the template for The Nerd. I will post it here for reference sake:

#include <SPI.h>
#include "thingProperties.h"

// RGB LED pins
int redPin = 6;
int greenPin = 8;
int bluePin = 7;

int BuzzerPin = 9;
int SensorPin = A2;
int buttonPin = 2; // the number of the pushbutton pin

bool hungry=true;
bool justWokeUp=true;
int buttonState = 0;

void setup() {

Serial.begin(115200);
delay(2000);

// Defined in thingProperties.h
initProperties();

// Connect to Arduino IoT Cloud
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
pinMode(buttonPin, INPUT);
}

void loop() {

nerdsLight = analogRead(SensorPin);
buttonState = digitalRead(buttonPin);
ArduinoCloud.update();

// Awaking notification
if(nerdsLight>150 && justWokeUp){
Serial.print("woke up");
if(nerdsFood == 0){
nerdsFood = 2;
}
justWokeUp=false;
setColor(0, 255, 0); // green
tone(BuzzerPin, 31, 200); // tone(Pin, Note, Duration);
delay(200);
setColor(0, 0, 0); // off
noTone(BuzzerPin);
delay(1000);
}

if (buttonState == HIGH) {
if(nerdsFood < 12 && nerdsLight>150){
nerdsFood++;
tone(BuzzerPin, 40, 300); // tone(Pin, Note, Duration);
delay(100);
tone(BuzzerPin, 40, 300); // tone(Pin, Note, Duration);
delay(100);
noTone(BuzzerPin);
}
delay(500);
}

// Set color status feedback
if(nerdsFood < 4){ // if starving show red
setColor(255, 0, 0); // Red
}
else if(nerdsFood >= 4 && nerdsFood < 8){
setColor(255, 255, 0); // yellow
}
else{
setColor(0, 255, 0); // green
}
}

void SOS(){
for(int a = 0; a< 3; a++){
setColor(255, 0, 0); // Red
tone(BuzzerPin, 31, 100); // tone(Pin, Note, Duration);
delay(100);
setColor(0, 0, 0); // off
noTone(BuzzerPin);
delay(50);
}

delay(1000);
for(int a = 0; a< 3; a++){
setColor(255, 0, 0); // Red
tone(BuzzerPin, 31, 2000); // tone(Pin, Note, Duration);
delay(1000);
}

for(int a = 0; a< 3; a++){
setColor(255, 0, 0); // Red
tone(BuzzerPin, 31, 100); // tone(Pin, Note, Duration);
delay(100);
setColor(0, 0, 0); // off
noTone(BuzzerPin);
delay(50);
}
delay(10000);
}

// Send RGB values to the LED pins
void setColor(int red, int green, int blue){
analogWrite(redPin, red);
analogWrite(greenPin, green);
analogWrite(bluePin, blue);
}

void onNerdsTimeChange(){
if(nerdsFood > 0){
nerdsFood--;
delay(200);
}
}

void onNerdsFoodChange(){
if(nerdsFood == 0 && justWokeUp==false){
// DIE :frowning:
SOS();
}
}
/*
Since NerdsFood is READ_WRITE variable, onNerdsFoodChange() is
executed every time a new value is received from IoT Cloud.
*/

This is the easiest way to tidy up the code and add the code tags

Start by tidying up your code by using Tools/Auto Format in the IDE to make it easier to read. Then use Edit/Copy for Forum and paste what was copied in a new reply. Code tags will have been added to the code to make it easy to read in the forum thus making it easier to provide help.

Hi @shamoney. There is a bug in the "The_Nerd" sketch from the tutorial. You can fix the bug that causes the compilation errors by removing the redundant definitions of the onNerdsFoodChange and onNerdsTimeChange functions. Simply delete lines 126-139 from the sketch:

/*
  Since NerdsFood is READ_WRITE variable, onNerdsFoodChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onNerdsFoodChange()  {
  // Add your code here to act upon NerdsFood change
}
/*
  Since NerdsTime is READ_WRITE variable, onNerdsTimeChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onNerdsTimeChange()  {
  // Add your code here to act upon NerdsTime change
}

Unfortunately even after fixing those bugs, the sketch is fatally flawed. It doesn't work as described in the tutorial, and doesn't work in any sensible manner at all. I have reported these problems to the people at Arduino who created and maintain the tutorial.

For now, my recommendation is to move on to a different tutorial since I think you will have a bad experience with this one.

Okay, after taking your suggestion, the overall program didnt work. This is so frustrating as this was assigned to me by my class. So I have to do this one. Where would you recommend I start making changes in the code to get it to work?

Yes, as I warned you in my previous reply.

Having gone through this myself, I very much sympathize. I apologize for the poor experience.

I would suggest looking at the original "The Nerd" project:

This version was written for use with the MKR 1000 WiFi board. I haven't looked into this closely (I just gave up and submitted a bug report to the responsible parties after I realized how broken the runtime behavior of the modern "The Nerd" program was), but my impression is that the runtime flaws in the sketch code were introduced at the time the program was ported from targeting the MKR 1000 WiFi board to the version in the modern "The Nerd" tutorial that targets the Nano RP2040 Connect board.

Assuming that original "The Nerd" project was fully functional, I think it will provide a better starting point for you than the nonsensical code in the tutorial. You will need to modify the code provided in that "The Nerd" project so that it can work on your Nano RP2040 Connect board though (and with Arduino Cloud's IoT features if you want).

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