I'm stuck with this problem for a few days already. I cant seem to make my esp8266 work without bypassing the arduino. I am trying to send data to my own hosted server. I can only do the AT command if the reset and gnd of arduino is shorted. I am supplying the esp8266 with external power source. I cant do AT command if the arduino is working normally. Any solution to this? I'm a newbie so please bear with me. Thank you!!
Please give more details of what you're trying to accomplish.
mikaeehl:
I can only do the AT command if the reset and gnd of arduino is shorted.
By this I assume you are sending the AT command from Serial Monitor to the ESP8266, correct?
mikaeehl:
I cant do AT command if the arduino is working normally.
This is where it's less clear. Do you want to send AT commands from the Arduino sketch to the ESP8266 or do you still want to send AT commands from the Serial Monitor to the ESP8266?
pert:
Please give more details of what you're trying to accomplish.
By this I assume you are sending the AT command from Serial Monitor to the ESP8266, correct?
This is where it's less clear. Do you want to send AT commands from the Arduino sketch to the ESP8266 or do you still want to send AT commands from the Serial Monitor to the ESP8266?
Hello! I am trying to send AT commands with the arduino sketch. but I think i can only access the AT commands of esp8266 if the reset of arduino is grounded. I have a sketch where the ARduino is sending AT commands to the esp8266 like this:
void reset() {
esp.println("AT+RST");
delay(1000);
if (esp.find("OK") ) Serial.println("Module Reset");}
//connect to your wifi network
void connectWifi() {
String cmd = "AT+CWJAP="" + ssid + "","" + password + """;
esp.println(cmd);
delay(4000);
if (esp.find("OK")) {
Serial.println("Connected!");}
else {
connectWifi();
Serial.println("Cannot connect to wifi");
}}
nothing is appearing in the serial monitor. Thanks in advance!
You need to change the wiring. When you're using the Arduino as a USB-serial adapter to sent AT commands to the ESP8266 from the Serial Monitor, as you have done, the correct wiring is RX-RX, TX-TX. To send AT commands from your Arduino sketch running on the Arduino to the ESP8266 that is not the correct wiring. You need to change it to RX-TX, TX-RX.
pert:
You need to change the wiring. When you're using the Arduino as a USB-serial adapter to sent AT commands to the ESP8266 from the Serial Monitor, as you have done, the correct wiring is RX-RX, TX-TX. To send AT commands from your Arduino sketch running on the Arduino to the ESP8266 that is not the correct wiring. You need to change it to RX-TX, TX-RX.
I tried what you said. the blue LED is constantly blinking at baud rate of 115200. I also tried changing the baud at 9600 in the code and serial monitor. The blinking stopped. I uploaded this code:
#include <SoftwareSerial.h>
SoftwareSerial esp(6, 7);// RX, TX
void setup() {
// put your setup code here, to run once:
esp.begin(115200);
Serial.begin(115200);
}void loop() {
// put your main code here, to run repeatedly:
esp.println("AT+RST");
delay(1000);
if (esp.find("OK") ) Serial.println("Module Reset");
}
But nothing shows up in the serial monitor. Why is that?
SoftwareSerial doesn't work reliably at 115200 baud. You need to connect it back up as before and send the correct AT command from the Serial Monitor to change the baud rate. Use 9600 to be safe. Later after it's working you can increase the speed.
pert:
SoftwareSerial doesn't work reliably at 115200 baud. You need to connect it back up as before and send the correct AT command from the Serial Monitor to change the baud rate. Use 9600 to be safe. Later after it's working you can increase the speed.
I already tried changing the baudrate in my arduino sketch to 9600, but nothing shows up in the serial monitor.
You need to configure the ESP8266 to run at 9600 first by sending it the AT command that configures it to use a different baud rate.
pert:
You need to configure the ESP8266 to run at 9600 first by sending it the AT command that configures it to use a different baud rate.
Hello! i configured it using AT+CIOBAUD=9600. on my setup i use the same baud rate. nothing shows in the serial monitor. i dont know why
Which Arduino are you using?
How is the ESP8266 connected to the Arduino?
pert:
Which Arduino are you using?How is the ESP8266 connected to the Arduino?
Im really thankful you're replying to me. I am using Arduino Mega 2560. The esp8266 is supplied with external power. The connections are:
Arduino ESP8266
Gnd - GND
TX - RX (voltage divider 3.3v)
RX - TX
CH_PD 3.3v (external)
Vcc 3.3v (external
Pin 6 can't be used for RX using SoftwareSerial library on Arduino Mega 2560. See:
https://www.arduino.cc/en/Reference/SoftwareSerial
Not all pins on the Mega and Mega 2560 support change interrupts, so only the following can be used for RX: 10, 11, 12, 13, 14, 15, 50, 51, 52, 53, A8 (62), A9 (63), A10 (64), A11 (65), A12 (66), A13 (67), A14 (68), A15 (69).
pert:
Pin 6 can't be used for RX using SoftwareSerial library on Arduino Mega 2560. See:
https://www.arduino.cc/en/Reference/SoftwareSerial
The tx and rx pins are connected to 0 and 1. i also tried connecting it to pin 2 and 3, 4 and 5, 15 and 14. but still no luck in getting something from the serial monitor.
Please read this:
As you can see the syntax is this:
SoftwareSerial mySerial (rxPin, txPin);
So you need to do two things:
- Configure the SoftwareSerial library to use an RX pin that is supported on the Mega.
- Actually connect the ESP8266 to the pins that you have configured the SoftwareSerial library to use.
pert:
Please read this:
https://www.arduino.cc/en/Reference/SoftwareSerialConstructorAs you can see the syntax is this:
SoftwareSerial mySerial (rxPin, txPin);
So you need to do two things:
- Configure the SoftwareSerial library to use an RX pin that is supported on the Mega.
- Actually connect the ESP8266 to the pins that you have configured the SoftwareSerial library to use.
Today I used this code and try it:
#include <SoftwareSerial.h>
const byte rxPin = 0; // Wire this to Tx Pin of ESP8266
const byte txPin = 1; // Wire this to Rx Pin of ESP8266// We'll use a software serial interface to connect to ESP8266
SoftwareSerial ESP8266 (rxPin, txPin);void setup() {
Serial.begin(9600);
ESP8266.begin(9600); // Change this to the baudrate used by ESP8266
delay(1000); // Let the module self-initialize
}void loop() {
ESP8266.print("AT");
delay(500);
while (ESP8266.available()){
String inData = ESP8266.readStringUntil('\n');
Serial.println("Got reponse from ESP8266: " + inData);
}
}
Still no luck. im getting a bit frustrated in doing this. it has been days of research already. i've seen some that they got it fast and no problem.
A Mega (and you're using pin 0 and 1, which is already used by the USB-serial chip).
And you're using softwareSerial (while a Mega has three extra hardware serial channels).
While I never have used an ESP as serial-WiFi bridge, the above statements don't seem logical to me.
Leo..
Wawa:
A Mega (and you're using pin 0 and 1, which is already used by the USB-serial chip).
And you're using softwareSerial (while a Mega has three extra hardware channels).
While I never have used an ESP as serial-WiFi bridge, the above statements don't seem logical to me.
Leo..
Sorry, sir, i dont get it because im a newbie in arduino and esp8266. I have tried using pins 2 and 3 of Arduino Mega with the rx/tx of ESP8266. With this case, i cant seem to send AT command to the ESP8266 using my Arduino. I dont know why.
mikaeehl:
Today I used this code and try it:const byte rxPin = 0; // Wire this to Tx Pin of ESP8266
const byte txPin = 1; // Wire this to Rx Pin of ESP8266
// We'll use a software serial interface to connect to ESP8266
SoftwareSerial ESP8266 (rxPin, txPin);
Do you see pin 0 on the list of RX pins supported by the SoftwareSerial library for the Mega?
Also, pins 0 and 1 are hardware serial pins, called Serial. These pins are used for uploads to the Mega and for communication with the computer over USB such as Serial Monitor.
The Mega has 4 hardware serial ports. Unless you happen to be using all of them doing software serial on the Mega is pointless. You can just use hardware serial, which will allow you to communicate with the ESP8266 at 115200 baud and save memory too.
mikaeehl:
Sorry, sir, i dont get it because im a newbie in arduino and esp8266. I have tried using pins 2 and 3 of Arduino Mega with the rx/tx of ESP8266. With this case, i cant seem to send AT command to the ESP8266 using my Arduino. I dont know why.
Do you see pin 2 on the list of RX pins supported by the SoftwareSerial library for the Mega?
If you would just read and follow the documentation this would not be so difficult.
As said, a Mega has three extra hardware serial pairs (on pin 14-19).
It's even printed on the board.
To use e.g TX3 (pin14) and RX3 (pin15), add
Serial3.begin(9600); or Serial3.begin(115200); in void setup().
You talk to the MCU, not to the USB chip, so ESP TX goes to RX3 and ESP RX (via divider) goes to TX3. Then use Serial3.xxx throughout your code.
As said, never done this. Maybe someone can correct me if this is wrong.
Leo..
Thanks to everyone who helped me! I got it running now. Sorry if i have many questions. Have a good day!