Go Down

Topic: Can connect to esp8266 AP which is connected to Arduino UNO but no response (Read 176 times) previous topic - next topic

AliKHalili



I am new to arduino and am trying to connect the esp8266 to arduino UNO and send commands to the arduino using an android phone. I have double, triple checked the connections and I am sure they are 100% correct. I have connected esp GND to arduino GND, esp VCC to arduino 5V, esp TX to arduino SoftwareSerial RX and esp RX to arduino SerialSoftware TX and CH_PD to 5V. I can connect to esp using my phone but I can't send commands to it. I am using TCP/UDP Terminal on android to test the connection. Phone is connected to the AP but in the app it is not. I configured the app with 192.168.4.1 IP and 333 Port and I know that app works correctly because I have tested its integrity several times before. I have searched so much and tried so many but non worked. While I was searching I came across this that the problem is from baudrate. Meaning that the arduino apparently can't keep up with the esp8266 speed when SoftwareSerialed. I am sure that there is a way to achieve what I am trying to do, I mean there must be. I have also searched about how to reduce the esp8266 baudrate but many have reported that doing it have bricked their esp8266. Below is my sloppy code:

Code: [Select]
#include <SoftwareSerial.h>
SoftwareSerial ESP8266(2,3);

boolean FAIL_8266 = false;

#define BUFFER_SIZE 128
char buffer[BUFFER_SIZE];

void setup() {

  Serial.begin(9600);
  ESP8266.begin(115200);  // change this value to your wifi module (esp8266) baud rate

  do{
  ESP8266.println("AT");
    delay(1000);
    if(ESP8266.find((char*)"OK"))
    {
      Serial.println("Module is ready");
      delay(1000);

      //configure ESP as AP
      Serial.println("AT+CWMODE=2");
      delay(1000);

      //Set multi connections
      Serial.println("AT+CIPMUX=1");
      delay(1000);

      Serial.println("Server setup finish");
      delay(1000);

      FAIL_8266 = false;

    }
    else{
      Serial.println("Module have no response.");
      delay(500);
      FAIL_8266 = true;
    }
  }while(FAIL_8266);

  ESP8266.setTimeout(100);

}

void loop() {

  if(ESP8266.available()){
    String msg = ESP8266.readString();
    Serial.println("MSG: "+msg);
  }
}


I am also not sure that my code is 100% correct or not, so if it has any CRITICAL problems, please do let me know.
Now, any ideas on how to connect Arduino UNO and esp8266 and then send commands to the arduino using android?

pert

SoftwareSerial doesn't work reliably at 115200. You need to use the appropriate AT command to reduce the communication speed of the AT firmware on your ESP8266 to 9600. Your thing doesn't work now, so even if you do "brick" it when trying to reduce the baud rate, you're no worse off.

AliKHalili

I flashed my esp8266 and now it is working! Thanks for the assist. ;)

pert


Go Up