Go Down

Topic: Keep getting error on a ESP8266 ESP05 (Read 161 times) previous topic - next topic

jtomasrl

I just bought an ESP8266 ESP05 and put in on a Arduino UNO as follows:
RX -> TX
TX -> RX
3.3V -> 3.3V
GND -> GND

I wrote a simple code to test my new ESP8266 ESP05

Code: [Select]
#define ESP8266 Serial
 
 
void setup()
{
 Serial.begin(9600);
 ESP8266.begin(115200);
}
 
void loop() {
  String response = "";
     while (ESP8266.available()) {
      // The ESP has data so display its output to the serial window
      char c = ESP8266.read(); // read the next character.
      response += c;
    }
    Serial.print(response);
  }
 


But after going to Serial monitor I keep getting ERROR messages, is it normal?

Code: [Select]
rll⸮⸮|⸮l⸮| ⸮ l⸮ b|⸮⸮⸮⸮s⸮cl b⸮⸮no⸮lon⸮⸮⸮ cp lblslp⸮n⸮ ⸮ l b o⸮|⸮ ⸮ c⸮⸮on⸮l⸮⸮l`⸮on l`ns⸮⸮⸮o ⸮⸮l`p⸮o⸮ r⸮⸮⸮⸮⸮ c o⸮|쏏⸮b⸮⸮nn⸮ l`⸮on l`ns⸮⸮⸮o  ⸮lp⸮o⸮ s⸮⸮⸮⸮⸮⸮l c n⸮|⸮⸮⸮ c⸮⸮nn⸮ l`⸮nn l`or⸮⸮⸮n ⸮l`r⸮⸮o ⸮l`sl⸮⸮o⸮⸮⸮no⸮⸮⸮⸮snno⸮ l⸮c⸮l ⸮⸮l⸮⸮⸮⸮ ⸮ ⸮lll~rl ⸮⸮lllo⸮⸮ ⸮ l⸮lll ⸮⸮l⸮⸮n⸮⸮n⸮n⸮⸮ll⸮⸮c llpb⸮br⸮⸮⸮l`nl⸮p⸮⸮l`bl`l⸮⸮n ⸮o⸮⸮⸮nl⸮|c l l`sl⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮o⸮r⸮⸮o|⸮ ⸮ ⸮|sl⸮⸮r⸮l⸮l⸮ l`⸮⸮s⸮l⸮l⸮ l`⸮⸮r⸮l ⸮⸮⸮ ll`sl⸮⸮rl⸮⸮⸮c ⸮⸮c⸮b br⸮r c⸮⸮o⸮oo⸮ l⸮⸮ l ⸮ l⸮⸮ll⸮⸮⸮⸮⸮⸮l⸮n⸮⸮⸮⸮b l l⸮rp ⸮⸮⸮c l ⸮crlrl
ready


ERROR
ready

ERROR

 ets Jan  8 2013,rst cause:1, boot mode:(3,0)

load 0x40100000, len 2408, room 16
tail 8
chksum 0xe5
load 0x3ffe8000, len 776, room 0
tail 8
chksum 0x84
load 0x3ffe8310, len 632, room 0
tail 8
chksum 0xd8
csum 0xd8

2nd boot version : 1.6
  SPI Speed      : 40MHz
  SPI Mode       : QIO
  SPI Flash Size & Map: 8Mbit(512KB+512KB)
jump to run user1 @ 1000

⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮o⸮r⸮⸮o|⸮ ⸮ ⸮|sl⸮⸮r⸮l⸮l⸮ l`⸮⸮s⸮l⸮l⸮ l`⸮⸮r⸮l ⸮⸮⸮ ll`sl⸮⸮rl⸮⸮⸮c ⸮⸮c⸮b br⸮r c⸮⸮o⸮on⸮ l⸮⸮ l ⸮ l⸮⸮ll⸮⸮⸮⸮⸮⸮l⸮n⸮⸮⸮⸮b l l⸮rp ⸮⸮⸮c l ⸮crlrl
!⸮V⸮⸮5

!⸮V⸮⸮5
ERROR

!⸮V⸮⸮5

ERROR
ERROR

ERROR

!⸮V⸮⸮5


ERROR
ERROR

ERROR
ERROR


ERROR
ERROR

ERROR

!⸮V⸮⸮5




pert

Unrelated to your problem, but you really need to take the time to understand what this code does:
Code: [Select]
Serial.begin(9600);
 ESP8266.begin(115200);

At the top of your sketch, you have this macro definition:
Code: [Select]
#define ESP8266 Serial
#define is a preprocessor directive. The preprocessor acts on your code before it's compiled. #define does a text replacement. So everywhere in your code where there is found "ESP8266" it will be changed to "Serial". So now let's look at that code after preprocessing:
Code: [Select]
[code] Serial.begin(9600);
 Serial.begin(115200);
[/code]
You set Serial to run at 9600 baud and then immediately set it to run at 115200 baud.

Your use of this macro might make you think there is magically one serial interface for the Serial Monitor and another for the ESP8266. This is purely an illusion. The RX and TX pins on your Uno are also connected to your computer. What this means is every time you print something to the Serial Monitor, you're also printing it to the ESP8266, thus all those "ERROR" as it receives things that are not valid AT commands. You will also likely find that you can no longer upload sketches to your Uno with the ESP8266 connected to those pins.

A more sane approach is to use the SoftwareSerial library to create another serial port on some pins other than 0 and 1 on your Uno, connect the ESP8266 to those pins, and update your code accordingly. However, this has its trickiness as well. The ESP8266's AT firmware communicates at 115200 baud by default, but the SoftwareSerial library won't work reliably at that speed. So you should use the appropriate AT command (AT+UART_DEF) to set your ESP8266 to communicate at 9600 baud while you still have the connection on pins 0 and 1.

jtomasrl

wow, actually this is my first time trying to upload something into an arduino and your comment cant make more sense. You are completely right, actually I was questioning the code, I knew something was wrong but didnt even think that the serial was shared between my computer and the module.

The only thing is that I cant use other port rather than 0 or 1 because Im using a cnc shield thats using every other pin on the board. Maybe I should just omit the error messages? anyway, there shouldn't be any error message when running without a usb connected to the board

pert

As long as you have this line in your sketch:
Code: [Select]
Serial.print(response);
there will be error messages, whether the USB is connected or not. What you're doing there is echoing every bit of the output from the ESP8266 right back at the ESP8266, which will output an error message, which will then be echoed right back at it, and so on forever.

Go Up