Can not initialize ESP module in Arduino SoftwareSerial's example sketch in configuring WiFi module.
In the sketch it tells:
#include "WiFiEsp.h"
// Emulate Serial1 on pins 6/7 if not present
#ifndef HAVE_HWSERIAL1
#include "SoftwareSerial.h"
SoftwareSerial Serial1(11,12); // RX, TX
#endif
I plugged jumper wires in from esp8266 RX to Digital 11 of mega which is RX and TX of esp8266 to Digital 12 of mega, and I compile the code and looked at the Serial Monitor, but it says:
[WiFiEsp] Initializing ESP module
[WiFiEsp] >>> TIMEOUT >>>
[WiFiEsp] >>> TIMEOUT >>>
[WiFiEsp] >>> TIMEOUT >>>
[WiFiEsp] >>> TIMEOUT >>>
[WiFiEsp] >>> TIMEOUT >>>
[WiFiEsp] Cannot initialize ESP module
Advise is greatly appreciated.
-
2it is not SoftwareSerial on Mega. Mega has Serial1. did you connect ground? connect Rx to TX and TX to RX. use pins of hardware Serial1 of MegaJuraj– Juraj ♦2018年02月09日 12:46:49 +00:00Commented Feb 9, 2018 at 12:46
-
Yes i connect the ground, my esp01 responds if the connection is RX of esp01 to TX of mega and TX of esp01 to RX of mega.Karena– Karena2018年02月09日 13:43:52 +00:00Commented Feb 9, 2018 at 13:43
1 Answer 1
#ifndef HAVE_HWSERIAL1
#include "SoftwareSerial.h"
SoftwareSerial Serial1(11,12); // RX, TX
#endif
Because your Mega has a Hardware Serial1
port, HAVE_HWSERIAL1
is defined. Thus the lines inside that preprocessor conditional will not be compiled. This means you should connect the ESP8266 to the Serial1
lines on your Mega:
Mega | ESP8266
--------------
19 | TX
18 | RX
-
I try to plug it in mega's 18 with esp01's TX and 19 with esp01's RX and reverse but still gives me time out :( i don't know what to do now.Karena– Karena2018年02月09日 13:49:23 +00:00Commented Feb 9, 2018 at 13:49
-
And also it gives me :error compiling for board arduino /genuino mega or mega2560. please sir help.Karena– Karena2018年02月09日 13:59:35 +00:00Commented Feb 9, 2018 at 13:59
-
1first of all the sketch with WiFiEsp library must compile. what are the error details?2018年02月09日 14:01:19 +00:00Commented Feb 9, 2018 at 14:01
-
I download the library in this link:github.com/bportaluri/WiFiEsp and tried the ConnectWPA example.Karena– Karena2018年02月10日 02:40:47 +00:00Commented Feb 10, 2018 at 2:40
-
1and the compile error? changing connections is for nothing if the code doesn't compile and upload2018年02月14日 14:31:19 +00:00Commented Feb 14, 2018 at 14:31
Explore related questions
See similar questions with these tags.