For your design reference, here is an ESP32 CH340 programmer schematic. The Chinese WCH CH340 series of USB to UART bridge ICs are a very popular low-cost alternative to the CP2102 and FT232 USB-UART chips. You will find the CH340 chips being used in Arduino knock-offs and a bunch of ESP32 and ESP8266 development boards too. Even though we do not recommend using this chip for various reasons, here is how you can make it work with your ESP32 or ESP8266.
Also, you can use this ESP32 CH340 programmer schematic to make an ESP8266 programmer. Just make sure that the bootstrap pins like IO2 and IO15 are configured right on the ESP8266.
ESP32 CH340 Programmer Schematic
Viewing from the top-left, moving towards top-right corner, we have the microUSB connector (you can also use USB-C connectors). We have used a common 1117-3.3 LDO to derive 3.3V for the ESP32 or ESP8266 to use.
There are other variants like the CH340G and CH340D, please make sure you consult their datasheets before using them.
On the bottom half of the schematic, we have the CH340C USB to UART bridge driving the UART TXD and RXD pins of the target ESP32 or ESP8266. There are two transistors, Q1 and Q2, that toggle the enable and IO0 pins to put the ESP32 or ESP8266 in programming and run modes as required.
The ESP32 CH340 programmer schematic shown above assumes that the other bootstrap pins of the ESP32 or ESP8266 are all configured properly. Failing to do so will prevent proper operation.
CH340C power configuration options
The CH340C has 2 pins. The VCC pin and the V3 pin.
The VCC pin can take in either 5V or 3.3V. The V3 pin should be left connected to a decoupling capacitor only to enable the internal 3.3V LDO when VCC = 5V is used.
If VCC is tied to V3, then the CH340 must be powered by and external 3.3V source only.
In the example schematic, the CH340 is powered directly from the USB bus. The problem here is that the CH340C output logic levels are referenced to VCC input. Therefore, we have the TX and RX pins working at 5V instead of 3.3V.
Under normal circumstances, directly connecting the TX and RX lines to ESP32 or ESP8266 will kill the ESP chips because they are not supposed to work with 5V UART devices.
However, in this case the CH340C pin output current is limited to 3mA only and the input logic-high threshold is low enough to allow the ESP to use 3.3V CMOS logic levels on the UART pins.
This is the reason for connecting a 5V UART system directly to the ESP32 in the ESP32 CH340 programmer schematic. The clamping diodes on the ESP IOs can handle 3mA as per the datasheet.
How auto-reset logic works
The auto-reset and auto-program circuit works in a rather non-conventional way. You must have at least 100nF of capacitance on the ESP32 or ESP8266 EN pin with a pull-up resistor weaker than 10K to guarantee proper auto-program circuit operation.
Wondering why? We have discussed that in the CP2102 ESP32 programmer design article.
Please fill in the Subscription Form in the sidebar so we can keep you updated with our latest articles.
We only mail you less than 2 times a month.
Change Log
- Initial Release: 27 December 2020
References
- Reference 1: ESP auto-program forum post
- Reference 2: ESP32 datasheet
- Reference 3: CH340C English Datasheet
10 comments