0

This is my code. I am tring to make a connection to my wifi through esp8266.

#define DST_IP "192.168.1.5" // my IP
#include <SoftwareSerial.h>

SoftwareSerial mySerial(0, 1);

void setup()
{
  Serial.begin(115200);
  mySerial.begin(115200);
  while (! Serial); // Wait until Serial is ready - Leonardo
  Serial.println("AT+RST");
  delay(4000);
  Serial.println("AT+CWJAP=\"Ahmed\",\"12341234Aass\"");
  delay(4000);
  if (Serial.find("OK") )
  {
    Serial.println("1");
  }
  else
  {
    Serial.println("0");
  }
}

void loop()
{

}

This is the result of my code.

enter image description here

1 Answer 1

1
SoftwareSerial mySerial(0, 1);

try changing pin0 and pin1 with some other pins. (lets say with pin2 & pin3)

pin0 and pin1 are used by default Serial.

5
  • but pin0 and pin1 are my RX and TX .. is it true to work with any pin ?
    – Amir Hamdy
    Apr 22, 2016 at 16:18
  • yeh, pin0 and pin1 are your RX and TX. BUT they are so, only when you are using Serial. In above mentioned line of code you are initializing another serial, mySeial, to use same pins as Serial which is the cause of error.
    – ARK
    Apr 22, 2016 at 16:21
  • Thanks for replying BUT actually I use mySeial in nothing. So I removed it and still same error!
    – Amir Hamdy
    Apr 22, 2016 at 16:27
  • The point is that these pins are already used for the connection to the USB serial device proxying for the host PC. You need to connect the ESP8266 to different pins, not to these. Apr 22, 2016 at 17:55
  • Okay. I have set SoftwareSerial mySerial(0, 1); To SoftwareSerial mySerial(2, 3); But it always return 0 in the result which means it can not connect to the network.
    – Amir Hamdy
    Apr 23, 2016 at 13:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.