How to fix Failed to connect to ESP32: Timed out waiting for packet header error? - arduino

I tried to flash an ESP32 but I didn't succeed, I tried with esptool.py and Arduino IDE. I tried to press the boot button and reset but it didn't work. Here is the error:
A fatal error occurred: Failed to connect to ESP32: Timed out waiting for packet header

If using the Arduino IDE, try lowering the upload speed (Tools/Upload Speed). Lowering mine from 921600 to 460800 did the trick.
First ensure that you are in download mode:
Start the serial monitor and set the speed (mine is 115200).
While pressing the "boot" button, press and release the "en" button (your buttons may be labeled differently).
You should see something like this on the serial monitor:
waiting for download
Now start the upload
My development machine, a 2013 iMac is connected via USB to the USB-c port on my ESP32 Dev Module. Apparently the iMac's USB or ESP32 board's USB cannot keep up at the 921600 upload speed.

DISCLAIMER! May not be correct answer but may help to save time for someone.
Quick answer if you do not want read my experience: Disconnect all wires from pins and try uploading again! It may help.
I came across with the same error and could not figure it out. I first thought that something is wrong with the code, because it happened after I edited working code while figuring out where to connect what pin 😀. I also wasn't able to upload simple HelloWorld after it happened with connected wires. But then I disconnected all my wires from the board and the upload works fine.
I can not figure out the WHY factor but I think it must had been the input/data pin I was using, in my case D13. I have the DevKit with fewer pins. Maybe someone can comment why connected pins may make the error come up?

To make your ESP32 board go into flashing/uploading mode automatically, you can connect a 10 μF electrolytic capacitor between the EN pin and GND. When I had the same problem, when I followed this advice, the problem was solved.
References
Failed to connect to ESP32: Timed out waiting for packet header
espressif/arduino-esp32 - issue

On some AliExpress-like ESP32s you have to press the boot button in order to upload your sketch.
If you are watching the Arduino IDE console ouput and Connecting ... appears, you have to press the boot button for approximately 2 seconds until the console output changes.

Try to do this one after the other
Press the boot button when press uploading button until it write the code.
Try disconnect esp32 from the board/header/pcb that you are using right at the time.
Disconnect any other connection that your esp32 might have.
Do not connect to anything even your hand if possible.
Try put it in something that doesnt have a moist surface. look pic number 3.
MY CASES(30 pin version):
Case 1: I dont know why. I was connecting the pin to a female header it doesnt work and sometimes it just work like that. look pic number 1.
Case 2: when Im holding esp32 on my hand sometimes it wont work then i put it on my table and another time it doing well.
Case 3: pressing boot button when uploading it helped sometimes, and the other time it just work like it should.
Case 4: when it connected to pcb its simply just wont work, but when disconnected boom it work like nothing ever happen. look pic number 2.
Maybe just maybe something with capacitive or something like that (just assuming because number Case 1). hope that will help you out.
pic 1pic 2pic 3

This technique definitely working
Goto Tools > programmer, Select ISP and Upload Your Code.
if you can't see any programmer, then download 1.8.12 version.
https://www.arduino.cc/en/software/OldSoftwareReleases

With Arduino IDE
Make sure the Com port is selected under Tools menu. My experience with ESP32 is Com 5.
If it is not available as an option, try changing USB ports and/or re-select Tools - Board - ESP32 dev module.
Watch the "Compiling Sketch" window.
Press the "Boot" button as soon as you get the red message "Serial port Com 5" You can release the button as soon as it starts to upload.
If this doesn't work,try plugging into another USB port.
The Reset button only resets the uploaded sketch to re-initialise and has nothing to do with the uploading.

Install expressif.exe and port drivers,connect the port and flash the esp32 ,upload the code using ardiuno,solve the error

in my case buttons are new but not shorting properly as multimeter showed ..opened both scratched resoldered and all working

Changing by upload speed from 921600bps to 115200bps fixed it. No need to press any buttons.

Just download the drivers x)
CP210x: CP210x USB to UART Bridge VCP Drivers
FTDI: FTDI Virtual COM Port Drivers

Related

Arduino IDE Flora - Greyed Out Ports

I'm trying to learn how to use the Adafruit Flora, and I have followed the guides below:
https://learn.adafruit.com/getting-started-with-flora/windows-setup
https://learn.adafruit.com/getting-started-with-flora/blink-onboard-led
But, I'm struggling withe connecting to a port. It's greyed out in my IDE and I have tried a lot of things like, booting to BIOS and changing the settings to auto, to looking in for any hidden devices in the device manager window. I can't see a "Ports COM" section there and it's preventing me from uploading anything to the flora.
Arduino: 1.6.11 (Windows 10), Board: "Adafruit Flora"
Couldn't find a Board on the selected port. Check that you have the correct
port selected. If it is correct, try pressing the board's reset button
after initiating the upload.
Please help!
First of all check your usb cable. It might be faulty one or it could be charge only. If your board light/blink, it mean power lines are ok. But if there is no action from OS, there might be communication lines broken or missing.

Uploading program to teensy not working

i got a brand new Teensy 3.2 with the blinking LED programm on it.
When I now tried to upload another programm on the teensy, Arduino says:
Teensy did not respond to a USB-based request to automatically reboot.
Please press the PROGRAM MODE BUTTON on your Teensy to upload your sketch.
The automatically starting window of Teensy, doesn't give me a chance to (for example) reboot the Teensy as well, so something of the connection seems to be wrong or something, but what...
Even if I mannualy press the pushbutton, it's still not possible to upload something. Any ideas why?
I have encountered this problem twice. The first I tossed out the board. This time, when I power it, it runs the last program I burned on it, but when I try to program it again, the LED stops blinking and everything stops.
The claim that it might not be a data cable is not reasonable, because how can it stop the current program unless it was told to. I doubt very much that +5V can provide such commands.
I have tried different cables, different USB ports, rebooting my Linux box, reinstalling (twice), checking the pins on the Teensy and the cable... no clue.
It always boots up in the old app (I left the blinker running to indicate "liveness"). I had programmed a message to come out the hardware serial port. Could that have been the problem? Wait... Is there a way to set the baud rate on the USB? I wonder if that is the problem! --
Banner(void) {
Serial.begin(9600);
Serial1.begin(115200);
};
The example had me programming the USB serial! I bet that is the problem! Better yet, does anyone know what the protocol is for talking to USB serial commander?
Under Ubuntu 18.04 install this https://www.pjrc.com/teensy/49-teensy.rules file into /etc/udev/rules.d

Arduino com port keeps getting busy

I have got an Arduino Uno R3 on which I have an accelerometer that I'm playing a bit with. This setup has worked for quite a while now, everything working from uploading to checking the serial output.
Today I started having problems with the com port reporting busy or not connected at all. When I use the default IDE it cant find the arduino at all but when I use a modded IDE (Arduino ERW 1.0.5) seems to find the port to communicate on but it reports it being busy.
I have reinstalled the driver like 5 or 6 times now and searched for any other driver that might work but they wont change anything. I have also checked that my pc actually detects the arduino which it does, it is listed among the COM ports on Device Manager. I also tried changing the Com port from COM3 to COM4 and still it worked for like 3 uploads and then the COM port kinda "disappeared" from the serial port list on the IDE.
EDIT: Weirdly, after closing some programs that seem to have to do with serial communication it works. I have to look into what I close and when.
EDIT2: For now it seems that processing sometimes didnt close properly when not using the stop button on the processing application which then didnt close the connection to the arduino. I havent had any problems since I started to use the Stop button on processing.
Win 8.1
Latest driver and IDE(an modded IDE called Arduino ERW 1.0.5 seem to work a bit better but have the same issues)
One thing I noticed is that if I press the reset button when it starts again it wont send anything through serial, is it defaulting to the Blink program after a reset or what?
For those getting the "port busy" error while connecting Arduino and Process, one fix is to close the serial monitor in Arduino.
For anyone who is struggling with this, you have to give again rw rights to ttyACM0
sudo chmod a+rw /dev/ttyACM0
after that I was able to open the serial port.
I found the problem being in Processing itself, on win 8.1 the P3D option for 3D renderer seems to leave the java process open after closure which causes the serial port to be busy even after the main window is closed.
I simply fixed it by using OPENGL instead of P3D which didn't change anything visibly so I'm fine with it.

Arduino "avrdude" Error

I have been working with the Arduino system with an Arduino Uno chip for a while, but I recently came upon a problem I cannot solve. The problem is that whenever I attempt to upload a new program to my chip, I get the following error:
avrdude: stk500_getsync(): not in sync: resp=0x00
I have done some research, and I have tried everything that people have suggested. I have checked the COM port, checked the chip type, checked the component installations, updated the FTDI drivers, hit the reset button, tried the latest Arduino software, and yes, I have even made sure the board is plugged into the computer.
Earlier this year I had absolutely no problem uploading code to my board, and almost nothing has changed since I last tried it. The only thing that has changed is the cable I have used to upload the programs, and I have tried several different cables as well. Could it just be a batch of bad cables? This seems unlikely. I have also tried uploading code onto different boards, with the same result.
This is getting quite frustrating, as I really want to continue working on my projects. However, that will not happen if I cannot even print "Hello World!" to the serial monitor.
I am running on a 32-bit Windows 7 machine. Any suggestions to solving this would be greatly appreciated.
If you are expecting a normal upload using Serial then you should ensure your preferences are not set to "Upload using programmer" and that you are not selecting "Upload using programmer" from any of the Arduino menus.
EDIT
If you have not overridden the programmer then you must have the wrong board selected on the tools menu boards list. lpt1 in the error message is not what the Uno uses.
It turns out that the problem was the FTDI cable I was using. I tried a bunch of different cables until I found one that works, and now uploading occurs without any problems.
check the board you have selected in tools-> board . If you selected wrong board error comes as above. If right board being selected still getting same error , then it is definitely boot loader crashed error. You need to upload boot loader.
Sometimes parts connected to digital pin 0 and 1. The parts interfere communication between the computer and arduino so I recommend this procedure.
Check something is connected to D0 and D1.
If something is connected, unplug those.
Upload the sketch.
Plug parts removed at step 2.
your arduino maybe not uno, change board to duemilanove.

Arduino stuck in an infinite loop

My Arduino is stuck in an infinite loop trying to read from a pin and print it to the serial console. I can't upload any other programs now. What can I do to get the chip out of the loop?
Remove the USB connection, close the IDE, open the IDE, open BareMinimum, hold the reset button, plugin the USB connection, click the upload button 1/2 a second after removing your finger from the reset button.
If you're using an Arduino Uno, you might want to check out Updating the Atmega8U2 on an Uno or Mega2560 using DFU. Apparently there was a bug in the interface firmware.
This may sounds silly but what about disconnect it from the power supply to reset the MCU?
Edit:
I see it is powered via USB; then make sure you disconnect the device, remove/discharge any battery/capacitors whatsoever. If nothing works, close down the Arduino IDE, change the USB port you are using (sometimes it does happen that they get stuck..), reboot the PC.. Good luck!
Reprogramming the interface firmware (see ViennaMike's response) did not work for me, so I purchased another Arduino and turned it into an ISP programmer and overwrote the offending application:
https://stackoverflow.com/a/8453576/1090713
While this approach had some cost, I now have another tool and a way to save an Arduino in the future.
Upload your boot loader using Avr pocket programmer. This solves your MCU reset.
Use Watchdog timer instruction while coding infinite loop provided you are dealing with critical parameter to be written when it restarts.
If you run across the same problem with Arduino Yun, try uploading empty sketch using WIFI as port. It worked for me when I couldn't upload new sketch via USB.
The Arduino will wait a short while when attempting to upload. So you can press the reset and hold it until the Ide shows attempting to upload. then let go of it.
The problem can be that when you click upload the Ide first compiles then at the end of the process attempts to upload. So pressing reset, clicking compile and immediately letting go of reset doesn't always work because you let go of the reset too quickly.

Resources