I have connected Arduino with ESP8266 with
Arduino pin 2 connected to ESP's Tx Arduino pin 3 connected to ESP's Rx via Voltage Divider Arduino GND connected to ESP's GND Arduino 3v3 connected to ESP's CH_PD
I have powered ESP8266 using 1117 Voltage regulator
When I initially bought ESP8266 it was working properly(I could even set up a server) but now when I connect it to Arduino an endless stream of garbage values is seen on the Serial Monitor...
The arduino is programmed with the following code
#include <SoftwareSerial.h>
SoftwareSerial esp8266(2,3); // make RX Arduino line is pin 2, make TX Arduino line is pin 3.
// This means that you need to connect the TX line from the esp to the Arduino's pin 2
// and the RX line from the esp to the Arduino's pin 3
void setup()
{
Serial.begin(9600);
esp8266.begin(9600); // your esp's baud rate might be different
}
void loop()
{
if(esp8266.available()) // check if the esp is sending a message
{
while(esp8266.available())
{
// The esp has data so display its output to the serial window
char c = esp8266.read(); // read the next character.
Serial.write(c);
}
}
if(Serial.available())
{
// the following delay is required because otherwise the arduino will read the first letter of the command but not the rest
// In other words without the delay if you use AT+RST, for example, the Arduino will read the letter A send it, then read the rest and send it
// but we want to send everything at the same time.
delay(1000);
String command="";
while(Serial.available()) // read the command character by character
{
// read one character
command+=(char)Serial.read();
}
esp8266.println(command); // send the read character to the esp8266
}
}
-
Maybe it helps if you tell us what happened between "initially" and "now"?fuenfundachtzig– fuenfundachtzig2015年06月09日 13:48:14 +00:00Commented Jun 9, 2015 at 13:48
-
1Lose the Arduino and program the ESP directly. You can do it with the same language as Arduino. github.com/esp8266/Arduino - also supported in UECIDE - all you need is a USB -> UART dongle.Majenko– Majenko2015年06月09日 15:57:49 +00:00Commented Jun 9, 2015 at 15:57
-
If the stream of garbage values comes in response to things you send to the ESP8266, then the problem is most likely the baud rate. For the ESP8266-01 modules that I have used, the default baud rate is 115200.Kluge– Kluge2015年06月11日 22:59:47 +00:00Commented Jun 11, 2015 at 22:59
-
I had already changed the Baud Rate of the Module to 9600 using AT+BAUD command..AngryBird– AngryBird2015年06月12日 03:44:47 +00:00Commented Jun 12, 2015 at 3:44
1 Answer 1
There is a new command for the ESP8266 in AT version:0.50.0.0 - SDK version:1.4.0 that lets you explicitly set the full UART configuration:
AT+UART_CUR
– set the current UART configuration
This command sets the current UART configuration; it does not write to the flash. Hence there is no change in the default baud rate.
For example:
AT+UART_CUR=9600,8,1,0,0