- Tue Oct 08, 2019 5:56 am
Thanks all for the advice. I have made some progress and can now answer my own questions.Re 1.
The voltages I measure on the pins of the USB To ESP8266 Serial Adapter
are real and correct. The threatening 5V reading on GPIO3/TX does not do any damage to the chip. At least not in the short run. Today I managed to upload a sketch (Blink) successfully to the ESP8266. And it works! No damage done. Re 2. How to load a sketch?
The real question should have been: "Why do I get the message 'esptool.FatalError: Failed to connect to ESP8266: Timed out waiting for packet header'?" I did the right thing (wiring and IDE) to load a sketch, but physics got in the way. I was running the USB To ESP8266 Serial Adapter
from a USB2 connector on my laptop. As far as I can see USB2 does not specify the minimum current available from the power line. But my laptop specification limits this current to 200mA.
This article (https://www.ondrovo.com/a/20170207-esp-consumption/
) makes it clear that 200mA is not enough for reliable operation. If you have an oscilloscope, you can directly observe the voltage drop on the 3.3V (Vcc) pin. And that's what caused the problem. The under powered startup, the ESP8266 ends up in a weird state (more on that below) and uploads fail with "esptool.FatalError: Failed to connect to ESP8266: Timed out waiting for packet header".
The solution for me is to
a. Use the USB To ESP8266 Serial Adapter
b. Instead of connecting the ESP8266 board 3.3V (Vcc) pin to the 3.3V out on the USB To ESP8266 Serial Adapter
you connect the ESP8266 board 3.3V (Vcc) pin to a separate power supply providing 3.3V with a current rating > 500mA. I use a 1 Amp/5V power supply with a 3.3V regulator.
When you upload a sketch in this configuration, the oscilloscope shows no voltage drops on the 3.3V (Vcc) ESP8266 pin during upload and the upload completes successfully!
And I suspect that, if my USB port had provided enough current in the first place, the USB To ESP8266 Serial Adapte
r would have worked satisfactory first time. But I cannot test that.Some other observations
Whilst investigating the issues described above I learned a fair bit about the ESP8266.
1. It is completely usable with the USB To ESP8266 Serial Adapter
as supplied and the Arduino IDE. There are some quirks though:
1.a When you reset the ESP8266 by putting RST to ground for a short time, the ESP8266 will sent a message of successful reset "ets Jan 8 2013,rst cause:2, boot mode:(3,3)" which you can see in the Serial monitor of the Arduino IDE. Provided you have set the baud rate to 74880!!
. Of course this had already been reported on this forum (https://www.esp8266.com/viewtopic.php?f=160&t=12635
), but I did not know to look for it
1.b Once you can read the reset message, you can get info from the reported boot mode (3,3) is fine for upload. But in my case i found that my ESP8266 booted up with boot mode (3.7) or (3.6). The documentation I found (https://www.esp8266.com/viewtopic.php?f=6&t=8386
- Barnabynear last message) made it clear that my ESP8266 was in a "weird" state.
1.c To get out of the "weird" state I needed to completely disconnect all power, let all capacitors drain (60 seconds) and start again with a fresh instance of the Arduino IDE. No other sequence of events gave a reliable boot result.
1.d Once the ESP8266 reports a successful boot in the right mode, you are able to run AT commands successfully from the Serial terminal in the Arduini IDE at 115200 baud!!
2. To upload sketches your power supply to the ESP8266 must be able to supply sufficient current, as described above. The wiring is quite simple.
2.a Connect the ESP8266 to the USB to ESP8266 Serial Adapter,
minus the 3.3V (Vcc, pin 4)
2.b connect GPIO0 (FLASH, pin 6) to ground
2.c connect ESP8266 3.3V (Vcc, pin 4) to the high current 3.3V power supply
2.d Connect the USB To ESP8266 Serial Adapter
to the USB port on your laptop
2.e Start the Arduino IDE on your laptop
2.f reset the ESP8266 by pulling RST (pin 3) momentarily to ground
2.g the Serial Monitor (74880 baud) will show boot mode (3,3)
2.h switch serial monitor to 115200 baud
2.i upload your sketch
2.j finishes with: "Hard resetting via RTS pin...". But that does not happen A manual reset with RST to ground is required.
2.k DONE!3. Boot modes, rst causes and exceptions - references.
Once you know to ask the right question, there are plenty references on the web. Here is a start.https://riktronics.wordpress.com/2017/10/02/esp8266-error-messages-and-exceptions-explained/https://zoetrope.io/tech-blog/esp8266-bootloader-modes-and-gpio-state-startup/https://robertoostenveld.nl/esp-12-bootloader-modes/https://arduino-esp8266.readthedocs.io/en/latest/boards.html