0

I have an ESP8266 module connected to my Arduino Mega 2560. I sketched a simple code to pass whatever command I typed from the Serial Monitor to ESP8266 and vice versa:

void setup() {
  Serial.begin(115200);
  Serial2.begin(115200);
}

void loop() {
  if (Serial.available())
  {
    Serial2.write(Serial.read());
  }

  if (Serial2.available())
  {
    Serial.write(Serial2.read());
  }
}

So from here on I just type my AT commands inside Serial Monitor and receive the output also inside Serial Monitor. Managed to connect into a wifi network using the command:

AT+CWJAP="SSID","password"

And obtain my ESP8266 module's IP address using the command:

AT+CIFSR

+CIFSR:APIP,"192.168.4.1"
+CIFSR:APMAC,"5e:cf:7f:c2:ce:30"
+CIFSR:STAIP,"192.168.1.103"
+CIFSR:STAMAC,"5c:cf:7f:c2:ce:30"

OK

Problem is, whenever I run CMD and "ping 192.168.4.1" or "ping 192.168.1.103" from my PC which is connected to the same network, I will get "request timed out". Pinging my own PC's IP gets me a reply. What is wrong here? Totally clueless... :-/

EDIT My PC's IP address is 192.168.56.1

  • And are those IP addresses actually on the same subnet as your computer? – Majenko Sep 7 '16 at 11:16
  • What is your computers IP address. You will not be able to ping one of the addresses unless you have set the subnet mast to 16(ish) bits (255.255.0.0) – Code Gorilla Sep 7 '16 at 12:07
0

The IP address 192.168.4.1 is the default IP address used by the ESP8266 when it is running as an access point. You can ignore that, it doesn't actually exist.

You need to make sure that you are actually connected to the access point by issuing AT+CWJAP? which should respond with the access point name an OK if it is connected.

Secondly you need to make sure that you are on the same network segment as your ESP8266 - that is, the same subnet. If your computer isn't on an address in the range 192.168.1.1 to 192.168.1.254, and your subnet mask is set to (what is usually the default) 255.255.255.0, then you won't be able to communicate unless there is an appropriate route between the subnets.

Also some wireless routers impose client separation on the WiFi channel, which means that WiFi devices cannot talk to each other, and LAN devices cannot talk to the WiFi devices. This is usually something that can be disabled in the router's configuration.

1

First, you need to confirm that your PC's wireless connection is on the same IP subnet as the ESP8266. At the CMD prompt, type:

ipconfig /a

and look for the wireless adapter. Hopefully the IP address will start with 192.168.1.... It should but there's no harm in checking!

Second, check that your WiFi router hasn't disabled pinging between its clients - some do (mine did, until I threw it out...). Do you have a smartphone or other WiFi device? If so, find out its IP address (hopefully also 192.168.1....) and confirm that you can ping it.

Pinging your own address isn't very useful. Normally it detects the fact that it's its own address, and replies with no attempt at sending over the air.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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