My nodemcu dev board has built-in USB programmer. When I plug into USB port on PC, it defaults to COM1 which is surprising in itself. I loaded the board into Arduino IDE without problems. But if I try to upload a sketch. it ends up with the error message “espcomm_open failed”.
Is it necessary to first load Arduino bootloader ? What should be the setting for “programmer” in the tools menu of the IDE?
I tried several different settings, but the result is always the same. IT may have been sold with lua firmware installed, but how do I make sure to have Arduino firmware loaded?
Just to clarify:
- if you open the Arduino IDE and you remove your ESP. Do you see any COM port available?
- When you plug back your ESP, does it appear as COM1 in Arduino IDE?
- Which exact board and programmer are you using? Can you send me a link to where you bought your boards?
Note: you don’t need to worry about that. After uploading a new Arduino sketch it automatically erases the Lua firmware. Thanks,
Rui
Thanks for the prompt response Rui. Further to my questiom-
I was wrong about the com port, it is COM11 and it behaves, or seems to behave , as normal , i.e. it opens only when the board is connected to PC and powered on. I have the complete circuit diagram of the board. It has on-board USB and also a voltage reg for 3.3v. I do not know how to attach the diagram here. The USB programmer is based on CH340 and the RX and TX pins are connected (on board ) to TX and Rx resp of the ESP201.
In Arduino IDE Tools menu the board selection is generic ESP8266 NodeMCU and the board info seems to be correct. The port is 115200 . The default programmer is AVRSPI. With all this, when I try to upload the sketch, it always results in error “espcomm_open failed”. There is a switch on the dev board that grounds GPIO0 to groind when powering up, to put the board in upload mode. It is also possible to ground both GPIO0 and GPIO15 by separate mini-switches.
I have tried everything, including changing board selection to other ESP8266 models and the programmer in the tools menu. The same error message is the result.
HOw to send you the relevant diagrams ? Can you suss out what is going wrong?
Thanks for your help.
Thanks for providing these details.
- Basically, if your computer detects the COM11 port and you select it, that’s a good step
- Can you send me a link to where your purchased your board?
- Selecting the “generic ESP8266 board” should definitely work for any board
The error “espcomm_open failed” means that your ESP is not establishing a serial connection with your computer. If you were using a bare ESP8266 chip:
- Then, you need to double-check that TX and RX are well connected
- GPIO 0 (and if your board also has GPIO 15 exposed) must be connected to GND on bootup
At the moment our website doesn’t support file uploading, but we’ll try to add that feature in the next update. In the meantime, I recommend using a link to Google Drive file, Imgur.com, dropbox, or box.com (any file sharing service).
Hi Rui I have sent you a link to Google Drive folder, to support email address since I only have that.
I have double checked connections and voltages. You will see the eight mini switches. Sw 7 and 8 will ground GPIO0 and GPIO15. The Ebay page says to press S2 while powering on, but this will only ground GPIO0 momentarily, I tried both methods, same error message.
Unless the ESP201 board is faulty, I cannot see why the error. In arduino IDE tools menu there is a programmer option, What should that be set to? The default is AVRSPI.
Hope you can help.
Unfortunately I’ve never used that board, so to be honest I don’t know how it works. In summary, in any ESP8266 board, you just have to connect GPIO15 and GPIO 0 to GND in order to upload a code to your board (to force it into flashing mode…). TX and RX must also be properly connected.
As I said, before the error “espcomm_open failed” simply means that your ESP is not establishing a serial connection with your computer.
Leaving all the default settings in your Arduino tools menu should work just fine.
Yes, I received your link. Thank you. But you just need to post here the link to the eBay seller where you bought your board… According to the schematics it looks like it should work.
Hi Rui
I think I found the problem with my board. I wrote a small sketch, just print a line to serial monitor. It was uploaded and ran. I then modified your webserver sketch by commenting out all the lines in the void()loop function, leaving all else as it is. I wanted to see ig the board will connect to my network SSID. This sketch also got uploaed but the connection did not succeed, just continued printing dots.
While doing this I founds that the USB connection looked a bit loose so the sketch did not always upload. I tried different cable, but the fault seems to be in the Mini USB connector. It is beyond my skill level to replace the SMD Mini USB connector
In any case, it did not connect to the network. Is it able to broadcast on the network to obtain IP address from the DHCP server ? Is that part of the ESP8266WiFi library ? Please let me know because if it can connect to the network, I can work around the USB connection..
If not, I have to trash the board. I had bought it long ago, so no point in trying to return ut.
Please let me know about DHCP broadcast.
Many thanks for your help.
Is it a problem with the Mini USB connector or with your USB cable? There are USB cables that make a better connection with those mini USB connectors. So, trying different USB cables might help (the USB cables must have data wires).
How just connecting the ESP8266 to your network would fix that issue? You still need to upload a sketch first…
Thanks Rui
I did try 3 different cables. All worked intermittently, and felt loose in the socket. As I said, I did manage to upload the sketches sometimes due to intermittent connection and the sketches did work when upload was successful.
One sketch just printed a “It works” line to the serial monitor and the second was the modified sketch with all lines in the void()loop commented out. The attempt to connect is in the setup function, so after upload was successful, I got the message “Trying to connect” to my SSID using my password. I also increased the delay in the sketch to 2 Seconds, so on the serial monitor I kept getting the dots every two seconds as programmed in the WHILE loop of the setup function.
This is why I asked how the board gets its IP address, does it broadcast a DHCP request ? Where is the DHCP client function?
I have not had a chance yet to look at ESP8266WiFi.h file in detail. You probably know it backwards, so please tell me what the problem could be about connecting to my network. If I could get a connection to my network. I will not trash the board. It has jumpers that can give access to Rx and Tx lines of the ESP201 so I can connect another USB programmer to those lines directly… But if the RF side also fails to connect, I will just trash the board.
Please let me know how the DHCP works for the ESP8266.
I have many UNO and nano boards. but I was hoping to have the wireless transceiver capability of the ESP201.
You have been a great help and I find your material most useful and easy to follow.
You have three options:
- Your ESP8266 can be set as an Access Point
- ESP8266 is connected to your router and the router automatically assigns an IP address
- ESP8266 is connected to your router and you set a fixed IP address (directly in your router through the Mac Address or in the ESP8266 code)
However, what do you want to do afterwards with the connection? You need to have a code that can receive data while connected to Wi-Fi, for example…
Note: you can learn more about the ESP8266 GPIOs using our ESP8266 Pinout and GPIOs Reference Guide