ESP8266 on Arduino Mega problems

Hi everyone!

I am have serious problems with getting my ESP8266 module (ESP-01) working with my Arduino Mega. I have looked at dozens of tutorials but I don't really understand how to set things up.

The ESP is connected to my Mega like this.

External 3.3V to ESP GND to ESP ESP TX to Arduino RX (Serial2) ESP RX to level shift to Arduino TX (Serial2)

The bridge for the chip enable is there as well. The modul lights up, I can even find the Soft AP it creates.

Now here is what I wish to do.

I want to connect the ESP to my WIFI network. Once it is connected, I want to use an Android device to send serial data to the ESP's IP. The Arduino will then need to read this data through the ESP.

For instance, I want to send a string to the ESP like this:

"I,7,25,30,52,67,38,78.9,91.3!"

I have implemented this using an HC-06 bluetooth modul and everything is working fine, but I would like to switch to WIFI now.

The problem is, I can not get the ESP to react to any AT commands. Also I keep seeing people flashing some firmware on the ESP, is this necessary?

I'm simply not aware of the steps that need to be taken in order to send and receive basic raw serial data.

Thanks in advance!

Bavilo: The problem is, I can not get the ESP to react to any AT commands.

Please post the code that you used to test this. The best code would be something that simply echos any thing received/send in the Serial Monitor. It is also useful for testing to get a USB-serial breakout board such as the FTDI FT232RL for testing so that you can communicate directly from your PC to the ESP8266, removing the extra complication of the Arduino. Then once you are sure the ESP8266 is working correctly you can connect the Arduino.

Bavilo: I keep seeing people flashing some firmware on the ESP, is this necessary?

Likely not, every ESP8266 module I've worked with came with the AT firmware installed. However it may have an old version or a modified version from what you expect, even so the basic commands should remain the same regardless.

If you send AT+GMR it will print out the firmware version(assuming the AT firmware is installed).

One thing you have to get right is the baud rate to communicate to the ESP8266. This is usually 115200 by default but you can change it via AT commands. It's possible it has a different baud rate than 115200 set.

pert: Please post the code that you used to test this. The best code would be something that simply echos any thing received/send in the Serial Monitor. It is also useful for testing to get a USB-serial breakout board such as the FTDI FT232RL for testing so that you can communicate directly from your PC to the ESP8266, removing the extra complication of the Arduino. Then once you are sure the ESP8266 is working correctly you can connect the Arduino. Likely not, every ESP8266 module I've worked with came with the AT firmware installed. However it may have an old version or a modified version from what you expect, even so the basic commands should remain the same regardless.

If you send AT+GMR it will print out the firmware version(assuming the AT firmware is installed).

One thing you have to get right is the baud rate to communicate to the ESP8266. This is usually 115200 by default but you can change it via AT commands. It's possible it has a different baud rate than 115200 set.

Ok I have tried everything now...This is truly the poorliest documented device on this planet. I really have now clue how to get it to work.

I see people using no level shift at all, I see people pulling the enable pin HIGH, I see people pulling the reset pin HIGH, some don't. Can someone just tell me how to get this thing running please?

Here is the code I am using to test it:

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

void loop() {
  if(Serial2.available()) {   
    char ser = Serial2.read();   
    Serial.print(ser);
  }
  if(Serial.available()) {   
    char ser = Serial.read();
    Serial2.print(ser);
  }
}

I have tried every baud rate, this thing won't respond. At some point I saw a "ready" in the console, once...and then never again.

What I have noticed it that when the RX and TX lines are hooked up to the Arduino, the blue LED on the ESP won't flash anymore, not even on ESP power up.

Some one PLEASE help me.

I got it working...

I forgot to connect GND from my external powersupply to Arduino GND.

AT commands are now working.

AT+GMR

AT version:0.60.0.0(Jan 29 2016 15:10:17)
SDK version:1.5.2(7eee54f4)
Ai-Thinker Technology Co. Ltd.
May  5 2016 17:30:30

So...after hours of testing. I'm still dissapointed.

When I put the ESP8266 in server mode and allowing multiple connections and when I send data to it from an Android device, the data will be received like this:

+IPD,0,31:I38,7,23,43,23,54,76.5,67.5,34!

Where I38,7,23,43,23,54,76.5,67.5,34! is the actual data

So because of this, I now have to remove the header as well. Ok no problem.

BUT! When I want to send data from the Arduino to the ESP8266 to the Android device. I first have to specify the length of the data I want to send, followed by the data with html header? This is a no go.

On my old HC-06 Bluetooth modul things worked like this: If I send:

W34,56,34!

to the Bluetooth modul, it is exactly how it's being received on the Arduino side.

In order to send:

I12,23,34,45!

to the Bluetooth modul to the Android device, I simply type:

Serial1.print("I12,23,34,45!");

and it is exactly how it will be received on the Android device.

So, is this possible at all with the ESP8266?

BUT! When I want to send data from the Arduino to the ESP8266 to the Android device. I first have to specify the length of the data I want to send, followed by the data with html header? This is a no go.

Welcome to HTML. Kind of a P.I.T.A. :-X

I'm not going to tell you it is any easier with ESP8266 ArduinoIDE programming, but you are welcome to look over a few projects I have done with Arduino running on the ESP.

Ray