Go Down

Topic: Arduino +ESP8266 problem (Read 137 times) previous topic - next topic

Vitor_Borba

Mar 23, 2019, 12:10 pm Last Edit: Mar 23, 2019, 12:20 pm by Vitor_Borba
Hi, I have a problem with sending AT command from Arduino Mega to ESP8266.  
Below my code:
Code: [Select]
#include <SoftwareSerial.h>

SoftwareSerial mySerial(19, 18); // RX, TX

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }


  Serial.println("Goodnight moon!");

  // set the data rate for the SoftwareSerial port
  mySerial.begin(9600);
  mySerial.println("AT+CIPMUX=1");
}

void loop() { // run over and over
  if (mySerial.available()) {
    Serial.write(mySerial.read());
  }
  if (Serial.available()) {
    mySerial.write(Serial.read());
  }
}



Connection between Arduino and ESP ,

                            RX1 -  TX
                            TX1 - RX
                            3,3v - VCC,CH_EN
                            GND - GND
If I connect ESP to USB UART converter and I use serial port then i have communication and i can send AT command and ESP responds.
If you have any advice please reply.

Juraj

#1
Mar 23, 2019, 02:02 pm Last Edit: Mar 23, 2019, 02:03 pm by Juraj
why do you use SoftwareSerial on Mega with 4 Serials?
and you connect receive to receive and transmit to transmit pin?

Vitor_Borba

So, should i use MultiSerialMega or somethig other?
I connect Rx from Arduino to Tx ESP and Tx Arduino to Rx ESP.

Juraj

Mega has Serial, Serial1, Serial3, Serial3. on the board are labels for TX and RX 1 to 3. so wire the esp8266 to Serial3 and don't use SoftwareSerial.

Vitor_Borba

Ok. Problem is solved. Thanks

Go Up