Saturday 7 August 2021

ESP32 auto program fix

Out of the box my ESP32 dev board required me to hold down the BOOT button at the start of programming to get it to program from the Arduino IDE. The board has a pair of transistors to connect the DTR and RTS lines to EN and GPIO0. This is intended to enter programming mode automatically but seems to have timing problems. If I don't hold the button I get:

Fatal Error Occurred: “Failed to connect to ESP32: Timed out waiting for packet header”

Looking around the internet I found a recommendation to add a 10uF electrolytic capacitor between EN and ground. While this did work for programming it seemed to inhibit the board reset at the end of programming. I found 1uF worked better, which let me use a small ceramic SMT cap, which is a lot neater.


The nearest ground is the top right pin of the module and I could have angled it to reach that but I found it easier to just link it to the metal can.

Investigating why it doesn't work I found the setup and hold times for the strapping pins in the ESP32 datasheet:

To enter programming mode GPIO0 needs to be low as EN transitions to high and stay low for 1ms after that.

This is the two transistor circuit on my board which is labelled ESP32 DEV KIT V1, which implements the truth table shown.

The truth table shows that EN and IO0 can't go low at the same time, so the zero setup time cannot be achieved unless both lines change together. Here is what it looks like on a scope after I added the capacitor.


During reset RTS is low and DTR is high, which makes EN low and IO0 high. At the end of reset DTR goes low and then about 1ms later RTS goes high. This would work without the transistors but with them EN starts to go high 1ms before IO0 goes low, so it violates both the setup and hold time. Adding the capacitor delays EN long enough for IO0 to be low as the chip comes out of reset.

My best guess is the transistor circuit is there to ensure random serial monitors don't put the board into programming mode if they assert both DTR and RTS. To work without a capacitor RTS and DTR would need to change state simultaneously. There is a long discussion about it here: https://github.com/espressif/esptool/issues/136.

Friday 16 July 2021

Third Hand

A problem I often face hand soldering surface mount components is keeping them in the correct position while soldering the first end. The surface tension of the solder invariably moves the component.  When using paste and an oven the surface tension is the same on both ends and pulls the component into position. Solder paste and hot air works similarly but it is easy to blow the component away.

One solution is to tin the pad and the end of the component first and then use tweezers to hold the component on the pad while applying the soldering iron to the tinned end. However that requires a steady hand and today, after having two strong cups of coffee, my hands are far from steady!

Some time ago I bought a PCBite probing kit from Elektor. This consists of a steel base, four magnetic clamping posts to hold a PCB and four sharp tip probes with magnetic bases and flexible swan necks intended for making measurements. It works well for its intended purpose although I think the flexible necks would be better if they were stiffer.



I found they make an excellent third hand for holding SMT components in place while soldering.


Here it is holding an 0805 resistor, they are the smallest parts I am comfortable soldering by hand.