Go Down

Topic: Arduino is throwing an error while uploading and not uploading ! help ! (Read 537 times) previous topic - next topic

firashelou

Hello everyone,
I am using arduino Nano to upload a sketch and I am getting the below error :

Multiple libraries were found for "SPI.h"
 Used: C:\Program
 Not used: C:\Program
Multiple libraries were found for "RF24.h"
 Used: C:\Program
Using library SPI at version 1.0 in folder: C:\Program Files
Using library RF24 at version 1.3.3 in folder: C:\Program Files

avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
.
.
.
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x00
An error occurred while uploading the sketch


So my circuit contains a Nextion display, a 4021 shift in register, 6 buttons connected to the 4021, 4 rotary switches connected to A0 to A3 and NRF24L01 long range connected to the nano. So before doing this circuit I tried each alone with the nano and programmed each alone and all worked fine. So now i am combining the sketch below.

What I tried is different options from online search for this question but none worked like disconnect the arduino and reconnect, check the right board is selected, check the right COM is selected, restart of the IDE, restart of the laptop, tried to change the nano for another one, checked that the Nextion is not connected to the arduino pin 0 and 1 while uploading, tried to upload the circuit to an arduino Uno which has only the NRF24L01 connected to it (this last one worked and no error was thrown but other options did not worked and kept throwing the error). I seek your help please to try and define what is the error preventing the sketch from being uploaded.


Edit
This is only happening on the Nano, i tried uploading the sketch on a nano alone without anything connected to it but I am getting an error. Just a thought maybe the memory ? my sketch is 16KB size


My code in the next post
Aiming for the unreachable !

my social website https://www.asserter.net

firashelou

Code: [Select]

#define Nextion Serial
// Defining the SPI library and RF24
// We must make sure to download RF24 library and place it in the arduino libraries folder
#include <SPI.h>
#include <RF24.h>
//#include <nRF24L01.h>

int msgTX[2]; //Message to be transmitted, can contain up to 2 array elements, 2 bytes
int ackMessage[2]; //Acknowledgment message, means the message that will be received from the receiver or the car, 1 element for the moment

//Defining radio object for the RF24 function pin 7 and 8 of arduino
RF24 radio(9, 10); // CE, CSN

//Defining the radio variables and values
const uint64_t pipe = 0xE8E8F0F0E1LL; //pipe address
const rf24_datarate_e dataRate = RF24_250KBPS; //Data rate defined in the documentations, RF24_250KBPS, RF24_1MBPS or RF24_2MBPS

//Steering potentiometers
const byte Throttle = A4;
const byte Braking = A5;

// #define Name Value
#define POTPIN A0   // select the input pin for the potentiometer
#define RETRY_LOOP   100   // The number of times that it will read the value of potentiometer for more accurate reading
int page_selector_val = 0;    // variable to store the value coming from the sensor
int last_page_selector_val = 0;  // variable to store the last value coming from sensor
byte page_loaded =0;       // variable to store the page ID that is loaded on Nextion
byte goto_page ;        //  variable to store the page that is selected from the switch

//Define arduino pins connected to CD4021
int dataPin = 8;   // Pin 0 of DigiSpark connected to Pin 3 of CD4021
int clockPin = 6;  // Pin 1 of DigiSpark connected to Pin 10 of CD4021
int latchPin = 7;  // Pin 2 of DigiSpark connected to Pin 9 of CD4021

byte RegisterValue = 0;  // Used to hold data from CD4021

// Define the pins for push buttons for debouncing
boolean lastPushButton1 = LOW;
boolean currentPushButton1 = LOW;
boolean led1On = false;

boolean lastPushButton2 = LOW;
boolean currentPushButton2 = LOW;
boolean led2On = false;

boolean lastPushButton3 = LOW;
boolean currentPushButton3 = LOW;
boolean led3On = false;

boolean lastPushButton4 = LOW;
boolean currentPushButton4 = LOW;
boolean led4On = false;

boolean lastPushButton5 = LOW;
boolean currentPushButton5 = LOW;
boolean led5On = false;

boolean lastPushButton6 = LOW;
boolean currentPushButton6 = LOW;
boolean led6On = false;

boolean lastPushButton7 = LOW;
boolean currentPushButton7 = LOW;
boolean led7On = false;

boolean lastPushButton8 = LOW;
boolean currentPushButton8 = LOW;
boolean led8On = false;

// Gear Number variable
int gearNum = 0;

void setup() {
  Nextion.begin(9600);
  delay(500); // give Nextion some time to finish initialize
  Nextion.print("page 0"); // for synchronize Nextion in case of reset to Arduino
  Nextion.print("\xFF\xFF\xFF");
  Nextion_serial_listen(); // reading from Nextion first time
  read_page_selector(); // This is going to read the selector and load the selected page on Nextion for first start up.

  //define arduino pins used to connect to the CD4021 Shift Register
  pinMode(dataPin, INPUT);
  pinMode(latchPin, OUTPUT);
  pinMode(clockPin, OUTPUT);

  radio.begin();
  radio.setDataRate(dataRate);
  //radio.openWritingPipe(address);
  radio.enableAckPayload(); //enables receiving data from receiver side
  //radio.setPALevel(RF24_PA_MIN); //Power Amplifier (PA) level to one of four levels RF24_PA_MIN, RF24_PA_LOW, RF24_PA_HIGH and RF24_PA_MAX
  //radio.stopListening();
}

void loop() {
  int ThrottleValue = analogRead(Throttle);  // read the value from the sensor
  //ThrottleValue =  map(ThrottleValue, 0, 1023, 255, 0); //middle throttle value 121
  
  int BrakingValue = analogRead(Braking);  // read the value from the sensor
  //SteeringValue =  map(SteeringValue, 0, 1023, 0, 255); //middle steering value 125

  radio.openWritingPipe(pipe);
  msgTX[0] = ThrottleValue;
  msgTX[1] = BrakingValue;
  radio.write(msgTX, sizeof(msgTX)); //Sends the Data
  AcknowledgmentDATA();
  
  Nextion_serial_listen();
  read_page_selector();

  // We must set Clock Pin HIGH first in this chip CD4021 but not all of the chips!
  digitalWrite(clockPin,1);
  // Set latch pin to 1 to get recent data into the CD4021
  digitalWrite(latchPin,1);
  
  delayMicroseconds(20);
  
  //Set latch pin to 0 to get data from the CD4021
  digitalWrite(latchPin,0);

  //Get CD4021 register data in byte variable
  RegisterValue = shiftIn(dataPin, clockPin, MSBFIRST);

  // This is for first push button -----------------------
  currentPushButton1 = debounce(lastPushButton1, 0);
  if(lastPushButton1 == LOW && currentPushButton1 == HIGH)
  {
    led1On = !led1On;
  }
  lastPushButton1 = currentPushButton1;
  // -------------------------------------------------

  // This is for second push button
  currentPushButton2 = debounce(lastPushButton2, 1);
  if(lastPushButton2 == LOW && currentPushButton2 == HIGH)
  {
    led2On = !led2On;
  }  
  lastPushButton2 = currentPushButton2;
  // --------------------------------------------------

  // This is for third push button
  currentPushButton3 = debounce(lastPushButton3, 2);
  if(lastPushButton3 == LOW && currentPushButton3 == HIGH)
  {
    led3On = !led3On;
  }
  lastPushButton3 = currentPushButton3;
  // --------------------------------------------------

  // This is for fourth push button
  currentPushButton4 = debounce(lastPushButton4, 3);
  if(lastPushButton4 == LOW && currentPushButton4 == HIGH)
  {
    led4On = !led4On;
  }
  lastPushButton4 = currentPushButton4;
  // --------------------------------------------------

  // This is for fifth push button
  currentPushButton5 = debounce(lastPushButton5, 4);
  if(lastPushButton5 == LOW && currentPushButton5 == HIGH)
  {
    led5On = !led5On;
  }
  lastPushButton5 = currentPushButton5;
  // --------------------------------------------------

  // This is for sixth push button
  currentPushButton6 = debounce(lastPushButton6, 5);
  if(lastPushButton6 == LOW && currentPushButton6 == HIGH)
  {
    led6On = !led6On;
  }
  lastPushButton6 = currentPushButton6;
  // --------------------------------------------------

  // This is for seventh push button
  currentPushButton7 = debounce(lastPushButton7, 6);
  if(lastPushButton7 == LOW && currentPushButton7 == HIGH)
  {
    gearNum--;
    if(gearNum == 0) {
      Nextion.print("page0.gearNum.txt=");  
      Nextion.print("\"");
      Nextion.print("N");
      Nextion.print("\"");
      Nextion.write(0xff);
      Nextion.write(0xff);
      Nextion.write(0xff);
    } else if (gearNum > 0){
      Nextion.print("page0.gearNum.txt=");  
      Nextion.print("\"");
      Nextion.print(gearNum);
      Nextion.print("\"");
      Nextion.write(0xff);
      Nextion.write(0xff);
      Nextion.write(0xff);
    }
  }
  lastPushButton7 = currentPushButton7;
  // --------------------------------------------------

  // This is for eighth push button
  currentPushButton8 = debounce(lastPushButton8, 7);
  if(lastPushButton8 == LOW && currentPushButton8 == HIGH)
  {
    gearNum++;
    if(gearNum == 0) {
      Nextion.print("page0.gearNum.txt=");  
      Nextion.print("\"");
      Nextion.print("N");
      Nextion.print("\"");
      Nextion.write(0xff);
      Nextion.write(0xff);
      Nextion.write(0xff);
    } else if (gearNum > 0 && gearNum < 8){
      Nextion.print("page0.gearNum.txt=");  
      Nextion.print("\"");
      Nextion.print(gearNum);
      Nextion.print("\"");
      Nextion.write(0xff);
      Nextion.write(0xff);
      Nextion.write(0xff);
    }
  }
  lastPushButton8 = currentPushButton8;
  // --------------------------------------------------

  if(gearNum > 7)
  {
    gearNum = 7;
    Nextion.print("page0.gearNum.txt=");  
    Nextion.print("\"");
    Nextion.print(gearNum);
    Nextion.print("\"");
    Nextion.write(0xff);
    Nextion.write(0xff);
    Nextion.write(0xff);
  } else if (gearNum < 0)
  {
    gearNum = 0;
    Nextion.print("page0.gearNum.txt=");  
    Nextion.print("\"");
    Nextion.print("N");
    Nextion.print("\"");
    Nextion.write(0xff);
    Nextion.write(0xff);
    Nextion.write(0xff);
  }

  
}
Aiming for the unreachable !

my social website https://www.asserter.net

firashelou

the rest of the sketch

Code: [Select]

//DATA Receiving from the Receiver part, Acknowledgment Data
void AcknowledgmentDATA(){
   
  while ( radio.isAckPayloadAvailable() ){
    //Serial.println("Ack Available");
    radio.read(ackMessage, sizeof(ackMessage));
    int value = ackMessage[1];
 
  }
 
}


void read_page_selector()
{             
    // ---- Software filter. Average values for more accurate reading----                 
    uint32_t pot_val = 0;    // 32-bit variable used for adding up analogRead of potentiometer.
    for(int i = 0; i < RETRY_LOOP; i++){
     pot_val += analogRead(POTPIN);        // at adc_val, it adds the value of analogRead as long as the number of times are less than the RETRY_LOOP
     delay(1);        // one ms delay between readings.
                   
    }
   
    page_selector_val = (pot_val / RETRY_LOOP);
   
 
    if(page_selector_val != last_page_selector_val){
       
       if(page_selector_val < 750 && page_selector_val > 735){
            goto_page = 0;
        }
       if (page_selector_val < 660 && page_selector_val > 640) {
            goto_page = 1;
        }
       if (page_selector_val < 565 && page_selector_val > 545) {
            goto_page = 2;
        }
       if (page_selector_val < 475 && page_selector_val > 455) {
            goto_page = 3;
        }
       if (page_selector_val < 380 && page_selector_val > 360) {
            goto_page = 4;
        }
       if (page_selector_val < 285 && page_selector_val > 260) {
            goto_page = 5;
        }
       if(goto_page != page_loaded){
          Nextion.print("page ");
          Nextion.print(goto_page);
          Nextion.print("\xFF\xFF\xFF"); // Nextion end command
        }
     last_page_selector_val = page_selector_val ; // Refresh the value of <last_page_selector_val> variable
    }   
}
boolean debounce(boolean last, int bitToRead)
{
  boolean current = bitRead(RegisterValue, bitToRead);
  if(last != current)
  {
    delay(5);
    current = bitRead(RegisterValue, bitToRead);
  }
  return current;
}

void Nextion_serial_listen()

{
    if(Nextion.available() > 2){                // Read if more then 2 bytes come (we always send more than 2 <#> <len> <cmd> <id>
        char start_char = Nextion.read();      // Create a local variable (start_char) read and store the first byte on it
        if(start_char == '#'){                // And when we find the character #
          uint8_t len = Nextion.read();      // Create local variable (len) / read and store the value of the second byte
                                            // <len> is the lenght (number of bytes following)
          unsigned long tmr_1 = millis();
          boolean cmd_found = true;
           
          while(Nextion.available() < len){ // Waiting for all the bytes that we declare with <len> to arrive             
            if((millis() - tmr_1) > 100){    // Waiting... But not forever......
              cmd_found = false;              // tmr_1 a timer to avoid the stack in the while loop if there is not any bytes on Serial
              break;                           
            }                                     
            delay(1);                            // Delay for nothing delete it if you want
          }                                   
                                               
            if(cmd_found == true){            // So..., A command is found (bytes in Serial buffer egual more than len)
              uint8_t cmd = Nextion.read();  // Create local variable (cmd). Read and store the next byte. This is the command group
                                             
              switch (cmd){
                case 'P':
           
                  page_loaded = Nextion.read();
                   
                  break;     
                case 'X':
                   // for future use, adding new command group
                  break;
              }
            }
        }
    }   
}
Aiming for the unreachable !

my social website https://www.asserter.net

pert

Please do this:
  • (In the Arduino IDE) File > Preferences
  • Uncheck the checkbox next to "Show verbose output during: compilation"
  • Check the checkbox next to "Show verbose output during: upload
  • Click "OK"
  • Sketch > Upload
  • After the upload fails, you'll see a button on the right side of the orange bar "Copy error messages" (or the icon that looks like two pieces of paper at the top right corner of the black console window in the Arduino Web Editor). Click that button.
  • In a forum reply here, click on the reply field.
  • Click the </> button on the forum toolbar. This will add the forum's code tags markup to your reply.
  • Press "Ctrl + V". This will paste the upload output between the code tags.
  • Move the cursor outside of the code tags before you add any additional text to your reply.

TomGeorge

Hi,
Why are your libraries in C:\Program folder?
Where is your Library folder?
What version IDE are you using?

Tom.... :)
Everything runs on smoke, let the smoke out, it stops running....

firashelou

Hi,
Why are your libraries in C:\Program folder?
Where is your Library folder?
What version IDE are you using?

Tom.... :)

they are not ! that's what is weird ! they are in C:\Program files(x86)\Arduino\libraries
Aiming for the unreachable !

my social website https://www.asserter.net

firashelou

Code: [Select]

Arduino: 1.8.10 (Windows 10), Board: "Arduino Nano, ATmega328P"

Sketch uses 4994 bytes (16%) of program storage space. Maximum is 30720 bytes.
Global variables use 282 bytes (13%) of dynamic memory, leaving 1766 bytes for local variables. Maximum is 2048 bytes.
C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude -CC:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -carduino -PCOM3 -b115200 -D -Uflash:w:C:\Users\ACER\AppData\Local\Temp\arduino_build_63677/Steering_Wheel_Simulator_sketch.ino.hex:i

avrdude: Version 6.3-20190619
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"

         Using Port                    : COM3
         Using Programmer              : arduino
         Overriding Baud Rate          : 115200
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x00

avrdude done.  Thank you.

An error occurred while uploading the sketch

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.


It says something about overriding baud rate 115200
Aiming for the unreachable !

my social website https://www.asserter.net

pert

@firashelou select Tools > Processor > ATmega328P (Old Bootloader) and then try uploading again.

Why are your libraries in C:\Program folder?
There is a bug in Arduino IDE 1.8.10 where the "Multiple libraries were found" output gets truncated when there is a space in the path:
https://github.com/arduino/Arduino/issues/9287

TomGeorge

@firashelou select Tools > Processor > ATmega328P (Old Bootloader) and then try uploading again.
There is a bug in Arduino IDE 1.8.10 where the "Multiple libraries were found" output gets truncated when there is a space in the path:
https://github.com/arduino/Arduino/issues/9287
That was my next thought. :)
Can you load and run the "Blink without Delay" sketch?


Tom... :)
Everything runs on smoke, let the smoke out, it stops running....

firashelou

That was my next thought. :)
Can you load and run the "Blink without Delay" sketch?


Tom... :)
I was not able to upload the blink example ! it gave me same error !
Aiming for the unreachable !

my social website https://www.asserter.net

sterretje

I was not able to upload the blink example ! it gave me same error !
Did you see reply #7 ?
If you understand an example, use it.
If you don't understand an example, don't use it.

Electronics engineer by trade, software engineer by profession. Trying to get back into electronics after 15 years absence.

firashelou

@firashelou select Tools > Processor > ATmega328P (Old Bootloader) and then try uploading again.
There is a bug in Arduino IDE 1.8.10 where the "Multiple libraries were found" output gets truncated when there is a space in the path:
https://github.com/arduino/Arduino/issues/9287
pert I moved arduino to C:/ and the error stayed !
Aiming for the unreachable !

my social website https://www.asserter.net

pert

You misunderstood what I wrote. The solution to your problem is this:
@firashelou select Tools > Processor > ATmega328P (Old Bootloader) and then try uploading again.
The other part of that reply was directed to TomGeorge, not to you. I was just explaining why the "Multiple libraries were found" output you posted was truncated. That has absolutely nothing to do with your problem uploading. Please ignore it.

firashelou

Did you see reply #7 ?
yes i did but i was replying to Tom, well what i did from Chris answer is moving arduino from C:/Program Files (x86) to C:/
and by checking my preferences the sketchbook location is C:\Users\ACER\Documents\Arduino
Aiming for the unreachable !

my social website https://www.asserter.net

firashelou

You misunderstood what I wrote. The solution to your problem is this:
The other part of that reply was directed to TomGeorge, not to you. I was just explaining why the "Multiple libraries were found" output you posted was truncated. That has absolutely nothing to do with your problem uploading. Please ignore it.
yes i already tried this solution of bootloader but the error stayed :/

It is happening only on the nano, on the uno no problem
Aiming for the unreachable !

my social website https://www.asserter.net

Go Up