avrdude: stk500v2_ReceiveMessage(): timeout Sometimes random

Hi everybody. I post my issue.
I have been working in a project and everything was ok, until today. Today i connected my arduino mega 2560 to my mac os X 10.14.4 (all the same like yesterday), but, when I try to upload sketch, I get the error avrdude: stk500v2_ReceiveMessage(): timeout
I try everything I get by internet, blogs, forums .... none work. All is the same like yesterday, but today ... I don't know what happen.

Just one thing work. When I try to upload the sketch, arduino IDE take some seconds to compile the sketch. While it is compiling the sketch, i press the reset red button on the arduino mega, and, randomly I release the button when I think arduino IDE will begin to connect to arduino mega. And sometimes work (I think always work, but I think no always I release the button in the correct and exact time). So, why does this happen? I why today?

I release everything in the arduino mega (screens, sensors, cables), just the board and the USB cable to the computer.

Note: I use in the setup of the sketch:

Serial.begin(9600);
attachInterrupt to the TX19 and RX18 pins
new SoftwareSerial( 34, 36 );

Maybe some of this RX and TX pins is the problem? but ... why today?

Thanks everybody!

astroluzz:
While it is compiling the sketch, i press the reset red button on the arduino mega, and, randomly I release the button when I think arduino IDE will begin to connect to arduino mega. And sometimes work (I think always work, but I think no always I release the button in the correct and exact time). So, why does this happen? I why today?

It is necessary to reset the ATmega2560 microcontroller on the Arduino Mega in order to activate the bootloader, which handles the upload. The bootloader only runs for a short time waiting for the computer to start the upload. Since the Arduino IDE spends some time compiling the sketch before actually starting the upload, you have to get the timing right, otherwise the bootloader will have already timed out and exited to the sketch previously loaded on the board before the computer even starts the upload. There is a circuit on the Mega that causes this reset to happen automatically at just the right time. If you have a board you need to manually reset in order to do the upload, that means the auto reset circuit isn't working. This could be caused by having a connection between the reset and ground pins. When you are using the Mega as an "Arduino as ISP" you would put a 10 uF capacitor between the reset and ground pins to disable the auto reset circuit so you can use the board as a programmer. You need to remove that capacitor before you can use the Mega normally again. There is a solder jumper on the Mega marked "RST-EN" that you can cut to disable the auto reset circuit. If you did that, it would result in the behavior you're experiencing.

astroluzz:
Note: I use in the setup of the sketch:

Serial.begin(9600);

attachInterrupt to the TX19 and RX18 pins
new SoftwareSerial( 34, 36 );




Maybe some of this RX and TX pins is the problem?

No, that's not it.

... that means the auto reset circuit isn't working. This could be caused by having a connection between the reset and ground pins.

Ouhhhhh f...k, I'm stupid ... thanks a lot!!!! It was my problem. There was something in the reset solder pin on arduino mega that was connecting it with something ....

It already work again.

Thanks a lot again!!!

You're welcome. I'm glad to hear it's working now. Enjoy!
Per

Thanks!!! Yeah, it work!!!! :slight_smile: :slight_smile:

The moderator can close the thread (at least for me is closed and solved!)

Here's how you can mark the thread solved:

  • At the bottom of the first post of the thread, click the "Quick Edit" link.
  • Click on the input field that contains the thread title.
  • To the start of the title, add the text: "[solved]"
  • Click the "Save" button.

It's helpful to do that because then people browsing the forum looking for threads they can help with will know they can skip over it and people who have the same problem and find this thread while searching for a solution can zero in on it as likely providing a helpful solution.

Thanks!