Skip to content

Different circuit neeeded for automatic upload using CP210x #480

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
probonopd opened this issue Jun 28, 2015 · 25 comments
Closed

Different circuit neeeded for automatic upload using CP210x #480

probonopd opened this issue Jun 28, 2015 · 25 comments

Comments

@probonopd
Copy link
Contributor

[Comment shortened in order not to confuse people -- see https://github.com//issues/480#issuecomment-122993574 for the recommended circuit]

I can reliably upload using baud rate 921600.

It would be good if others could test this setup too and if it works for everyone, it could be changed in the README.

@Links2004
Copy link
Collaborator

the problem is the Arduino IDE or you Serial terminal.

is the boot loading still working with the 10k?
i don't think its good for the stability of the uploading.

the problem shut be fixed in software (Arduino IDE) so that DTR and RTS is not activate in our case.
i use "real term" for serial debugging there i can control DTR and RTS manually.

@probonopd
Copy link
Contributor Author

Yes 921600 is working fine for me.

@cimba007
Copy link

I thing I have the same problem here. What are your resistor values for "pull up and pull down"?

@probonopd
Copy link
Contributor Author

10K

@cimba007
Copy link

What are u doing with GPIO0 and RESET when the CP210x is not connected? What values are you using in this case?

@probonopd
Copy link
Contributor Author

Good point. In my case the CP210x is always connected and is also used to provide the 3.3V (which appears to work sometimes in my case - better use the 5V from USB and a voltage regulator). I guess you'd have to put in pullups instead when the CP210x is removed.

@probonopd
Copy link
Contributor Author

Following advice from igrr, I am now using the circuitry from the NodeMCU 0.9 for my ESP-12Es. See the schematics of the NodeMCU 0.9.

circuit

I used slightly different parts that I had lying around, two 2N2222 npn transistors and 3 10k resistors, thereof 1 pullup for CH_PD. (I think I inadvertently connected CH_PD instead of nRST; need to double check.) U2 is the CP210x in my case. Note that it cannot provide enough 3.3V current, but using a voltage regulator to convert 5V coming from USB works.

Working well (occasionally I have to press upload twice, maybe this is related to me wiring up CH_PD instead of nRST). This circuit can be used for flashing and running, it does auto-reset and the serial monitor in the IDE can be used.

I built a jig out of perfboard that holds the ESP-12E in place using the castellated pins.

jig

This way I can flash and experiment with bare ESP-12E boards very quickly - no need to solder anything to them.

Possibly the documentation in the README should be updated to reflect this.

@JeroenBeemster
Copy link

Thanks probonopd, This solved my issue aswell.For everyone who find it hard to read electronic schematics. I created a simplified example using a breadboard explanation.
http://www.arduinesp.com/blink

@probonopd
Copy link
Contributor Author

Thanks JeroenBeemster, I hope you are not offended if I attach your example for quick reference here.

ttl-to-esp01-blink-npn

@ReMiA00
Copy link

ReMiA00 commented Oct 14, 2015

I have tried several methods on resetting the ESP-12E for flashing with Arduino IDE
However none worked great, and all will break the "serial monitor" in the IDE

Since i had a ATtiny85 lying around i used this to send the reset to the ESP:

  • The RTS pulse on my CP2102 lasts about 5 to 8 millis
  • When serial monitor is started RTS remains low until the monitor is closed.
  • To reset the ESP the RST pin needs to gow LOW while keeping GPIO0 LOW while booting the ESP
/*
  Reset ESP-12E with ATTiny85 (8Mhz)
 */

#include <SoftwareSerial.h>
#define rxPin 3  
#define txPin 4

SoftwareSerial mySerial(rxPin, txPin);

const int RTS_pin = 2; // Pin 7 on Attiny
const int RST_pin = 0; // Pin 5 on Attiny
const int GPIO0_pin = 1; // Pin 6 on Attiny

// Hookup 
// ESP     <--> Tiny pin <--> CP2102 or FT232RL
//  GND   <-->  4        <--> GND
//  5V    <-->  8 
//              7        <--> RTS 
//  RST    <--> 5            
//  GPIO0 <-->  6                  
//  RX <-------------------> TX
//  TX <-------------------> RX

unsigned long StartReset = 0;
unsigned long Puls = 0; 

void setup() {
  mySerial.begin(9600);

// USB to Serial Converter Flow Control RTS
  pinMode(RTS_pin,INPUT);

// ESP Pins
  pinMode(RST_pin,OUTPUT);
  pinMode(GPIO0_pin,OUTPUT);
  digitalWrite(RST_pin, HIGH);
  digitalWrite(GPIO0_pin, HIGH);
}

void loop() {
  int RTS = digitalRead(RTS_pin);

  if (RTS == 0 and StartReset == 0 ) { // Start Reset Puls
    StartReset = millis();
    mySerial.println("Reset");
  } 
  if (RTS == 1 and StartReset > 0 ) {  // Eind Reset Puls
    Puls = millis() - StartReset;
    mySerial.print("Puls = ");
    mySerial.println(Puls);
    StartReset = 0;

    if (Puls > 0 and Puls < 20) { // puls is around 5 to 8 millis
      digitalWrite(RST_pin, LOW);
      digitalWrite(GPIO0_pin, LOW);
      delay(5);        // length Reset puls
      digitalWrite(RST_pin, HIGH);
      delay(1000);        // Wait for ESP to boot
      digitalWrite(GPIO0_pin, HIGH);
      Puls = 0;
    }  
  }
}

I used a Arduino Nano with ArduinoISP sketch to program the ATTiny using IDE 1.6.5
Add in "Boards Manager" https://raw.githubusercontent.com/damellis/attiny/ide-1.6.x-boards-manager/package_damellis_attiny_index.json (see http://highlowtech.org/?p=1695)

Wire it up:
// Hookup to Program ATTiny85
// NANO <--> Tiny pin
// GND <--> 4
// 5V <--> 8
// 10 <--> 1
// 11 <--> 5
// 12 <--> 6
// 13 <--> 7

Choose ATTiny85 Board at 8Mhz and flash the Bootloader
Now you can upload the sketch to the ATTiny (use Arduino as ISP as programmer)

Wires for Serial debugging
// NANO <--> Tiny pin
// RX(0) <--> 3 serial monitor
// TX(1) <--> 4 serial monitor

@vicatcu
Copy link

vicatcu commented Oct 20, 2015

@igrr @probonopd ... reading the README on the esptool github repository, and using pin nomenclature from the wiki, it says:

esptool uses the RTS and DTR modem status lines to automatically enter the bootloader. Connect RTS to CH_PD (which is used as active-low reset) and DTR to GPIO0.

I believe CHIP_EN is synonymous with CH_PD (i.e. pin 7 of the ESP8266).. Looking at the whole NodeMCU 0.9 schematic, it would appear that they label this net "EN" and it is simply pulled up to 3.3V. They effectively connect the net named "nRST" which is synonymous with EXT_RSTB (i.e. pin 32 of the ESP8266), to the DTR line, and effectively connect GPIO0 to the RTS line. That's quite a difference to the recommendations of esptool. Unless RTS and DTR are functionally symmetric? They've also put a small capacitance (470pF) to GND on the EXT_RSTB pin, that may be critically important to the functionality of this circuit?

GPIO0, GPIO2, and EXT_RSTB are also passively pulled up to 3.3V, and GPIO15 is passively pulled down to GND.

The difference between CHIP_EN and EXT_RSTB is pretty subtle, so it probably doesn't matter (?) which one gets wiggled for auto-reset/upload support.. But I'm more doubtful where it comes to the differences between RTS and DTR. Is the circuitry in this thread above still sound, or should new hardware wire to RTS and DTR in agreement with the esptool recommendations? Maybe this could be covered in the wiki somehow?

@igrr
Copy link
Member

igrr commented Oct 20, 2015

The circuit in this thread works with esptool-ck when reset method is set
to 'nodemcu'. It might be different with esptool.py which you linked to.

On Tue, Oct 20, 2015, 16:33 Victor Aprea [email protected] wrote:

@igrr https://github.com/igrr @probonopd https://github.com/probonopd
... reading the README on the esptool github repository
https://github.com/themadinventor/esptool, and using pin nomenclature
from the wiki
https://github.com/esp8266/esp8266-wiki/wiki/Pin-definition, it says:

esptool uses the RTS and DTR modem status lines to automatically enter the
bootloader. Connect RTS to CH_PD (which is used as active-low reset) and
DTR to GPIO0.

I believe CHIP_EN is synonymous with CH_PD (i.e. pin 7 of the ESP8266)..
Looking at the whole NodeMCU 0.9 schematic, it would appear that they label
this net "EN" and it is simply pulled up to 3.3V. They effectively connect
the net named "nRST" which is synonymous with EXT_RSTB (i.e. pin 32 of the
ESP8266), to the DTR line, and effectively connect GPIO0 to the RTS line.
That's quite a difference to the recommendations of esptool.

GPIO0, GPIO2, and EXT_RSTB are also passively pulled up to 3.3V, and
GPIO15 is passively pulled down to GND.

The difference between CHIP_EN and EXT_RSTB is pretty subtle, so it
probably doesn't matter (?) which one gets wiggled for auto-reset/upload
support.. But I'm more doubtful where it comes to the differences between
RTS and DTR. Is the circuitry in this thread above still sound, or should
new hardware wire to DTR in agreement with the esptool recommendations?


Reply to this email directly or view it on GitHub
#480 (comment).

@vicatcu
Copy link

vicatcu commented Oct 20, 2015

@igrr interesting, didn't realize there was a difference. So does auto-reset not work for "Generic ESP8266 Module" selections, or is the same wiring applicable in that case? I'm asking because I'm designing in an ESP8266 module on a board right now and would like to have it be compatible with this project.

@hallard
Copy link
Contributor

hallard commented Nov 12, 2015

For those who just have FTDI cable with only DTR and no RTS line, I'm using this one (FTDI 5V compatible) with great success on ESP12 and ESP07

esp8266 auto reset final

Of course for this to work, don't forget pull down on GPIO15 (10K).

If your FTDI is 3V3 don't try to power your board with it (use another source), lot's of FTDI onboard reg can't do 200mA needed sometimes by ESP

@hallard
Copy link
Contributor

hallard commented Nov 17, 2015

After some investigation, it's better to reset with CH_PD
here it why
I've updated previous schematic

@ReMiA00
Copy link

ReMiA00 commented Nov 17, 2015

This looks promosing !
Will the serial monitor also work in the IDE ?

@hallard
Copy link
Contributor

hallard commented Nov 17, 2015

@ReMiA00
yes Serial monitor works fine with this and FTDI like cable, I use it every day ;-)

@tablatronix
Copy link
Contributor

I am using the nodemcu circuit and it works great for programing, but my module reboots when I open and close the serial monitor. Expected behavior ?

My logic probe, says my adapter DTR and RTS are both high at rest and LOW when serial monitor is open ( same for putty ). Changes to neither serial.disable... settings makes any difference either,

Are these in stable IDE yet?
Using IDE 1.6.6, and git version of repo.

EDIT:
Looks like no..
#22

@tablatronix
Copy link
Contributor

FYI, I am using 2n3904 transistors (have a bunch) with 10k base resistors, I have not bothered calculating proper resistor values yet.. Seems to work ok for programming every time so far.

@jayseeee
Copy link

jayseeee commented Jan 3, 2016

I had to come up with another circuit to do the "autoreset" with the FDTI interface as none of the above mentioned worked for me. I designed the PCB as an interface in between the FDTI an the board to be programmed, with an additional output of RESET and FLASH (GPIO0).

autoreset_sch

@muke1970
Copy link

muke1970 commented Jul 8, 2016

I tried JeroenBeemster's circuit on esp8266-01 and work very well. I tried the same on esp8266-12F but receive warning: espcomm_sync failed error: espcomm_open failed error: espcomm_upload_mem failed. The same with hallard's. Do you have suggestions for me? :-)
Thanks.
Emiliano.
P.S. If I wiring GPIO0 to GND work well

@muke1970
Copy link

muke1970 commented Jul 9, 2016

Sorry I make a mistake to wiring esp8266-12F.
It work like a charm!
Thanks again.
Emiliano.

@tablatronix
Copy link
Contributor

Make sure you are using nodemcu reset mode not ck

@paulwww
Copy link

paulwww commented Aug 2, 2016

ReMiA00 many thanks for the attiny85 solution. It is working well for me. At first I got it to work on an atmega328 since I could easily debug/test there. I then went to the attiny85 and built a circuit between my FTDI and ESP8266, now it is even more fun to develop for the ESP8266.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests