1

I have had so many problems with this board. I have a detailed list of everything I've tried at the link below, but for simplicity I will just summarize where I am now:

https://forum.arduino.cc/index.php?topic=673618.new

What I am trying to do

I want to connect my Arduino Nano to the internet using an ESP8266 ESP-01. Links to board references below:

Arduino Nano: https://128217-368301-raikfcquaxqncofqfm.stackpathdns.com/wp-content/uploads/2017/06/NSE-1004-2_7.jpg

ESP01: https://components101.com/sites/default/files/component_pin/ESP8266-Pinout.png

My Arduino is a clone. Here is the exact model: https://www.amazon.com/Longruner-ATmega328P-Controller-Module-Arduino/dp/B01MSYWE6B/ref=sr_1_7?dchild=1&keywords=arduinonano&qid=1585358071&sr=8-7

I have a server running on my network that will take two types of requests from these Arduinos. One Arduino/ESP pair will send data from sensors to the server, another pair will take that data from the server. These are dedicated processes. The sender will never receive and the receiver will never send.

Circuit

Three devices are at play: Arduino Nano (AN), ESP, and External Power Supply (EXPWS)

ESP: VCC -> 3.3v EXPWS

GND -> GND EXPWS

CH_PD -> 3.3v EXPWS

RX -> RX AN*

TX -> TX AN*

GPIO0 -> 3.3v EXPWS*

RESET -> 3.3v EXPWS*

Arduino

GND -> GND EXPWS

GND -> Reset AN*

  • I have tested various configurations of these. GPIO0 to ground, Reset of ESP to nothing, inverting RX and TX depending on what I am doing, etc. GND to Reset on the Arduino is when I try to upload to the ESP using the Arduino as a USB TTL converter. More on that later.

Where I am

I have been able to communicate with the ESP using the Arduino IDE via AT commands in the Serial monitor. I have connected the ESP to my WiFi network, can ping it from my Mac, and have set the default baud rate to 9600.

Things I cannot do

I cannot access AT commands when this sketch is uploaded to the Arduino:

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

}

void loop() {
  // put your main code here, to run repeatedly:

}

But I can access AT commands with the following two:

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}

and

void setup() {
  int i = 0;

}

void loop() {
  // put your main code here, to run repeatedly:

}

This tells me that trying to use Serial commands is causing a problem. I considered trying to work the ESP by sending AT commands via Serial communications, but, as per my description above, I received no responses from the ESP.

I also cannot use libraries intended for the ESP, namely WiFiEsp. I receive the error:

[WiFiEsp] Initializing ESP module
[WiFiEsp] >>> TIMEOUT >>>
[WiFiEsp] >>> TIMEOUT >>>
[WiFiEsp] >>> TIMEOUT >>>
[WiFiEsp] >>> TIMEOUT >>>
[WiFiEsp] >>> TIMEOUT >>>
[WiFiEsp] Cannot initialize ESP module
[WiFiEsp] >>> TIMEOUT >>>
[WiFiEsp] No tag found
WiFi shield not present

When I run any example sketches provided by the library (even when I change parameters such as baud rate and adding delay statements to the library code). Here is a link to that library, you can find the examples there: https://github.com/bportaluri/WiFiEsp/blob/master/examples/WebClientRepeating/WebClientRepeating.ino

I also cannot upload sketches directly to the ESP using the Arduino as a USB TTL converter. I have tried grounding the Arduino reset pin while uploading, grounding it during compiling then pulling that connection when it starts to upload, and doing nothing to the Arduino reset pin. I have tried different combinations with the GPIO0 pin (ground, vcc, nothing), as well as the other pins.

Conclusion

I am really open to some suggestions here. The root of the problem seems to be Serial communications - it is the common thread between basic sketches on the Arduino and uploading to the ESP itself. I have four of these modules and all of them behave the same way. If I can't get a solution here, I'm going to have to give them back to Satan.

  • 1
    From your connections I guess, you try to use the USB to Serial chip on the Nano to communicate with the ESP directly through the serial monitor. Then it is no wonder, that you cannot communicate that way, when you initialize Serial on the Nano. Keep in mind, that you have 3 devices connected to the same UART interface. That's not good. You may want to try using a SoftwareSerial interface for the ESP and forward data from Serial to SoftwareSerial. Then you can still use Serial for debug messages – chrisl Mar 28 at 22:42
  • Have you tried the WiFiESP library while still having Arduino RX to ESP RX and Arduino TX to ESP TX? – chrisl Mar 28 at 22:45
  • Do yourself a favour and get a 2$ USB TTL converter, flash the esp01 with Arduino software instead of wasting ttime with crutch solutions based on the espressif AT firmware (probably outdated and buggy) Development for this stopped end 2018, Arduino is still active - current 2.6.3. The esp01 is compared to the nano superioir (CPU, flash, connectivity) So in most use cases you can drop the nano – Codebreaker007 Mar 28 at 23:06
  • upvote for spending time on your question – jsotola Mar 28 at 23:54
  • First, when you use your Serial for Serial Monitor, you will need another port for communicating with ESP-01, in the case of Nano, since it has only one Serial port, so you will need SoftwareSerial. Secondly, I've been through what you (and many of others) experienced before and have tried WiFiESP, it doesn't work for me and the developer seems stop maintaining the library long ago. I use a library that I fork and fixed some minor bug and modified it that you can find in my github. It is very stable and use only 11-bytes SRAM. – hcheung Mar 29 at 0:43
1

Wow this was complicated to figure out. I am able to upload code to the esp, though it doesn't run yet.

Thanks to all who commented, the suggestions did not solve the problem, but they pointed me in the right direction. Rather than using my Arduino to interface with the ESP01, I switched to a Raspberry Pi so that I could connect it directly to the pins of the computer doing the flashing. Beyond that, it is still a complicated process, which I will go through here:

Wiring

Format: ESP -> Raspberry Pi

VCC -> 3.3v (I used a breadboard to allow multiple connections)

CH_EN -> 3.3v

GND -> GND

GPIO0 -> GND

TX -> RXD (GPIO 15)

RX -> TXD (GPIO 14)

GPIO0 needs to be connected to GND before you connect VCC to 3.3v. The purpose of this is so that the chip boots in programming mode.

Uploading

My methodology may be less useful for some, but there is probably something useful here for others.

My Raspberry Pi is headless so I needed to interface with the ESP via command line. Arduino does not have up to date resources for this, so I tried a couple of my own.

  1. First, I tried Arduino-cli - a package that can be downloaded from GitHub to compile and upload. I followed the tutorial provided by the video on the page posted below, but Arduino-cli requires you to include the FQBN of the device you are uploading to. I could not find this for the ESP and my Raspberry Pi did not recognize it on its own, so this was ultimately a dead end for me.

https://www.hackster.io/jithinsanal1610/arduino-cli-c26e6e

  1. esptool.py requires python and can be installed using pip. I created a virtual environment for the package to keep it separate from the rest of my system. The tool had trouble compiling sketches, so I used the Arduino Ide on my Mac, exported a compiled binary, and then transferred that to the Raspberry Pi via a smb drive. Using the command below, I was able to flash the compiled file to my ESP01.

    esptool.py --port /dev/ttyS0 write_flash 0x1000 SketchFolder/Sketch.ino.generic.bin

Now here is the important part. Restart the ESP01 after each flash attempt. Unplug it from VCC, plug it back in, then upload. If you upload successfully, then run the exact same command again, it will not upload! I suspect this may be the same problem I was running into when I was originally using the Arduino Ide. I haven't tested this, but I received a similar message when uploads failed on the Arduino and esptool.py:

Connecting: ----....----....----
Failed to connect

and

Invalid head of packet

These are not copy/pasted error messages, but they should be enough for anyone googling the error.

It is also worth noting that I used an AT command previously to change the default baud rate to 9600. I specified in the esptool.py command -b 9600. This did not allow me to upload. Leave the command alone - the default is 115200 but you don't need to specify it even if you changed the ESP baud rate (though it may be the case that I reset this somehow. I really don't know enough about the board to say).

Conclusion

There are a lot of bad resources out there for this board. Frankly, I would have bought a different one had I known. But it taunted me, and I don't play games. Good luck to anyone else who tries to work with this board! I am going to post a new question for my current problem, but for now I would say this one deserves to be marked as solved.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.