ARduino mega ESP8266-01

Hello everyone! i am having a problem where in i cant upload any sketches to the esp8266. I tried to connection below. Nothing comes up in the serial monitor and i cant even try the AT commands. Any help would be a big help for me! Thank you!

You can not power an ESP8266 from the 3.3V line of a Mega, you need a separate power supply.

Some basic stuff could work, but using WiFi is out of question.

Whandall:
You can not power an ESP8266 from the 3.3V line of a Mega, you need a separate power supply.

Some basic stuff could work, but using WiFi is out of question.

Hello! why is it that i cannot power the esp with the 3.3v of mega? I have seen some connections like this that work on the internet.

015adfb6cfa2e9b698c3a39064dcd95fdbd31181.png

Those two unconnected pins on the esp need to be pulled up to 3.3V (eg. with 4K7) to get the esp to boot into normal mode. For sketch upload, one of them needs to be pulled low while you reset the esp. You can tell which boot mode the esp is in by the flashes from its blue led.

Are you running some code on the Mega to echo data from the main serial port to the serial port that the esp is connected to? Did you know you cannot upload a sketch that way? Did you know that once you have successfully uploaded a sketch, the AT commands no longer work?

mikaeehl:
why is it that i cannot power the esp with the 3.3v of mega? I have seen some connections like this that work on the internet.

I've seen some Bigfoots and Yetis on the internet.

PaulRB:
015adfb6cfa2e9b698c3a39064dcd95fdbd31181.png

Those two unconnected pins on the esp need to be pulled up to 3.3V (eg. with 4K7) to get the esp to boot into normal mode. For sketch upload, one of them needs to be pulled low while you reset the esp. You can tell which boot mode the esp is in by the flashes from its blue led.

Are you running some code on the Mega to echo data from the main serial port to the serial port that the esp is connected to? Did you know you cannot upload a sketch that way? Did you know that once you have successfully uploaded a sketch, the AT commands no longer work?

I am really new to esp so i know only a little. My mega has an empty sketch in it. So maybe the reason why i cant try the AT mode is that i uploaded a sketch in it? I will ground the GPIO0 and pull the GPIO2 to 3.3v? Sorry im really new. please bear with me :frowning:

mikaeehl:
So maybe the reason why i cant try the AT mode is that i uploaded a sketch in it?

When you upload a sketch to the ESP8266 (not the Mega) it overwrites the AT firmware. If you wanted to go back to using AT commands you would need to flash the ESP8266 with the AT firmware again.

You seem very confused. Please try to be clear about what you want to do. Do you want to

  • upload an Arduino sketch to the esp or
  • do you want to upload a sketch to the Mega and communicate between the Mega and the esp using AT commands?

Your diagram shows the esp connected to the TX2 & RX2 pins. The serial monitor on the PC connects with the TX0 & RX0 pins. If you connect the esp to the TX0 & RX0 pins, it may cause a short which could damage the Mega or the esp. What you may need is to upload a sketch to the Mega which echoes data between TX0/RX0 and TX2/RX2. Then you should be able to communicate AT commands from the serial monitor to the esp. But I do not know if you can upload a sketch to the esp that way, it may be possible.

I do not know if it is possible to upload a sketch to the esp using the Mega. I know it is possible using an Uno R3 because on those boards you can remove the atmega328 chip and use the board as a USB - serial adaptor.

In the past, I have upload sketches to esp-01 using a separate usb-serial adaptor.

The usefulness of uploading a sketch to the esp-01 is limited because the esp-01 has only 2 useable pins. These can be used for i2c devices, for example. These days I use Wemos Mini, which contains an esp chip with more pins that can be used.

pert:
When you upload a sketch to the ESP8266 (not the Mega) it overwrites the AT firmware. If you wanted to go back to using AT commands you would need to flash the ESP8266 with the AT firmware again.

Why does the red LED goes off when i plug the ch_pd in 3.3v? Do i need some resistor in between?

PaulRB:
You seem very confused. Please try to be clear about what you want to do. Do you want to

  • upload an Arduino sketch to the esp or
  • do you want to upload a sketch to the Mega and communicate between the Mega and the esp using AT commands?

Im sorry if i am a bit confusing. I have a project wherein i need to send a data from a sensor to the internet. I want to connect the arduino mega to the internet using the eps8266 module. But i am having since i cant upload any sketch in the esp it says the error :

warning: espcomm_sync failed
error: espcomm_open failed
error: espcomm_upload_mem failed
error: espcomm_upload_mem failed

I tried supplying the esp with external 3.3v(ch_pd and vcc). Thank you!

mikaeehl:
I want to connect the arduino mega to the internet using the eps8266 module.

Generally when people want to do that they use the AT firmware on the ESP8266 and then communicate with the ESP8266 over serial using the AT commands. In that case you should be uploading sketches to the Mega, not the ESP8266. If you’re doing that I recommend this library:

The examples are written with the assumption that the ESP8266 will be connected to Serial1 rather than Serial2 but it’s simple to change the code to use Serial2 if you like.

That’s not to say that you are required to use the AT firmware. If you want you can write some custom Arduino code and upload it to the ESP8266, then upload some code to the Mega that uses whatever communications protocol you have devised.

mikaeehl:
warning: espcomm_sync failed
error: espcomm_open failed
error: espcomm_upload_mem failed
error: espcomm_upload_mem failed

This indicates you have an ESP8266 board selected from the Tools > Board menu. If you are trying to upload to the Mega that’s wrong. You should have Tools > Board > Arduino/Genuino Mega selected.

I have accessed the AT mode in the esp8266 with the reset of arduino connected to ground. This means i bypass the chip, right? but how can i use the arduino and connect it to wifi using the esp? i cant seem to make it work without the reset shorted to the ground in arduino. thanks!

mikaeehl:
I have accessed the AT mode in the esp8266 with the reset of arduino connected to ground.

That would be impossible if you had the circuit as shown in the diagram you attached. Don't you think it would be helpful if you told us that your circuit was different?

pert:
That would be impossible if you had the circuit as shown in the diagram you attached. Don't you think it would be helpful if you told us that your circuit was different?

Oh sorry, i did some modification. I connected the rx of esp to rx of arduino(with voltage divider), tx to tx, gnd to gnd, ch_pd and vcc to 3.3v, and the GPIO0 GPI02 are not connected to anything anymore. i can only do the AT mode if the reset of arduino is shorted to ground.

RX0-RX, TX0-TX is the correct wiring if you just want to use your Arduino mega as a USB-serial adapter to do serial communication directly from your computer to the ESP8266. If you want to do communication from your Arduino Mega to the ESP8266 then you need to connect it RX-TX, TX-RX. The reason is that RX stands for receive and TX stands for transmit, so you can see that connecting receive to receive and transmit to transmit wouldn't work. I very much recommend connecting the ESP8266 to RX1, TX1 or RX2, TX2, etc. instead of RX0, TX0 because those pins are also used for communication between the Mega and your computer over USB.

It's good that you have now verified that the AT firmware is installed on your ESP8266, that's definitely a step forward.