How can I check if the NodeMCU ESP32 is connected to WiFi from an external source?

I have a Website that runs on Angular and Firebase. A NodeMCU ESP32 and a bunch of sensors communicate to the firebase Real-Time Database (RTDB) to send over data.

As part of the troubleshooting system, I would like to check if the NodeMCU is connected to WiFi. I have read up on the suggestion of trying to ping the device. So I printed out the IP address using:

Serial.println(WiFi.localIP());

In the cmd terminal, I then type: ping ipaddress but I get nothing in return as it cannot find the device.

So how might I go about checking if the device is connected to WiFi?

Thanks!

Whereas it is relatively simple for a ESP32 node to initiate a communication, via a WLAN, to an internet based host to deliver data etc., it is not always so easy for an internet based host to initiate a communication with a node, in this case your ESP32, within a private WLAN.

Can the ESP regularly publish its status in such a way that you can read it for your troubleshooting activity ?

What, precisely, is the error message?
What is the IP of the ESP32 and what is the IP of your PC?

The error message:

ping 192.168.1.246

Pinging 192.168.1.246 with 32 bytes of data:
General failure.
General failure.
General failure.
General failure.

Ping statistics for 192.168.1.246:
    Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),

The IP address of the ESP32 is different to the IP address of my PC

Ah that's interesting. I suppose that is the alternative, I will try to figure out a way to somehow check the timings of the updates completed by the nodemcu on firebase. Thanks!

What is the IP address of the PC?