We are fairly new to Arduino. We tried to use SoftwareSerial to send AT commands from Arduino UNO to ESP8266. Here is our code:
#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3); // RX, TX
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(115200);
mySerial.begin(115200);
Serial.println("Ready!");
}
void loop() { // run over and over
if (mySerial.available()) {
Serial.write(mySerial.read());
}
if (Serial.available()) {
mySerial.write(Serial.read());
}
}
We have made the following connections:
Arduino UNO-->ESP8266
pin 2 (RX of Arduino UNO)---> TX (TX of ESP8266)
pin 3 (TX)---> RX
3.3V ---> VCC
GND ---> GND
In the Serial Monitor for Arduino UNO, it prints out "Ready!", but when we send "AT", there is no response. Please help us understand why we are not getting our response. Thank you!
"Poor performer" is right but you can expect it to work at 38400.
I don't know anything about the ESP8266 but you should check to see if there is a required speed for AT commands. If there is, you can only use that speed, it is not likely to be high and I bet it isn't 115200.
All those deprived people who don't have a Mega but want to configure an HC-05 Bluetooth module, are obliged to use software serial at 38400 to do it. There is no choice. There is no problem with it either.
From this, it seems clear that 38400 is absolutely reliable for this purpose, but go one notch up and the shit starts to hit the fan.
I repeat, I don't know what the specific baud rate requirement for ESP8266 is - or if there is one.
Thank you for the replies. We tried all the baud rates. With 9600, we get a response, but it shows an error (in the Serial Monitor) :
Ready!
>> AT
stdin:2: '=' expected near 'AT'
>
> AT+NAME?
stdin:1: '=' expected near '+'
>
According to several tutorials and websites, everyone used 115200 as the baud rate, and they got the proper response. We cannot understand why we are getting this error. Please help. Thank you!
It is possible to "get a response" with mis-matched baud rates, but the only response that counts is a kosher one, and that is not likely. Gibberish back is an indicator of the wrong baud rate.
I would suggest that anybody who uses 115200 does not do it on an Arduino with software serial. We are just going round in circles. I'm sure 115200 with Software serial is just asking for trouble - the kiss of death. This is not an ESP8266 problem , it's an Arduino problem, and I'm sure it applies to any kind of serial transmission. I find it hard to believe that you MUST use 115200, as this would surely have come up as a problem before, since I imagine most users would use it with a Uno.
I think it is going off at a tangent, but I'm sure you could configure it at 115200 using hardware serial by the simple expedient of using a one-shot programme with pre-programmed AT command in the setup. Maybe it is actually common practice with the ESP8266. I believe this matter is not helped by there being several quite different versions of the ESP8266.
Thank you. The convention is using a baud rate of 115200. However we tried 9600 and 38400, and it produced the error we posted above (only response with 9600). What do you suggest we should do?
Thank you!
I'm afraid I have told you all I can - in short(!?).
If there is a required speed for configuration, it is futile to try any other speeds. Requiring it to run at 155200 for config is just plain stupid anyway and, while I would expect a specific speed, seeing it being done at 115200 would make me feel there are slower alternatives.
115200 with software serial is the kiss of death. Different versions of software serial are not likely to fix this - it would be more like rearranging the deckchairs on the Titanic. I find it strange that anybody would publish a programme using 115200 on software serial, it is a pretty sure mark of somebody who doesn't know what he is doing.
Arduino will deliver all day at 115200 using the kosher hardware serial port. There are two ways to expedite this:
Get a Mega, which has four hardware ports - two more than you need - and run ESP on Serial1.
Use a programme that configures the ESP in one shot via hardware serial, i.e. no user input via the serial monitor. Even though I am a Mega user myself, this is all I do to configure HC-06 bluetooth, it should be all you need, and I can't believe you cannot do this with the ESP.
One the brighter side, you can't be the first person with this problem and, if it was unsolvable, everybody would know about it by now. You just need somebody with more experience than me. Thinking about this under the shower last night, option 2 above may be common practice.
I am thinking of getting a couple of ESP8266, and I would be glad to hear how you go with this.
Note that there is a rumour the 3.3v Arduinos aren't too good at 115200, even on hardware serial. If that is what you have, that is the first thing to check.