Ping IP Address from another homenetwork device

Hello everyone,
Sry for my english 
I have my new spark since yesterday. I tried a few examples and all is working fine.
I am completely new in this. I want to check if some devices of my home network are online or not.
I have read the documentation and I found this part under the section firmware. allows you to ping an IP address and returns the number of packets received as an int.

I tried to code some lines with the command, but when I try to compile I receive an error. I think that I need the WiFi library. But I don t know where I can find, and how I can install this library.
Can someone help me please?
Thx a lot

Hi triplea, here is a sample code that worked for me. I hope it helps.

IPAddress remoteIP(192, 168, 1, 1);
int numberOfReceivedPackage = 0;

void setup() {
    // Now open your Serial Terminal, and hit any key to continue!
    while(!Serial.available()) SPARK_WLAN_Loop();
    Serial.println("Pinging started...");
    numberOfReceivedPackage =;
    Serial.println("Pinging ended ->");

void loop() {


HI @triplea

WiFi is built-in but you do need to watch the capitalization “WiFi”.

As @triuman says above you need an IP address to ping and away you go–the default is 5 tries but you can say, 10);

for 10 tries if you need to for some reason. Usually 5 is sufficient and if the host is not there, then the timeout is not too long. The return value is the number of successful pings, so greater than 0 means it worked.

One other point of note: the core will not automatically answer pings after the “deep update” patch. TI removed this functionality from the TI CC3000 to make room for other bug fixes.


hi, thx you all for your replys. I will try it immediatly :wink:
Wish you a nice day.

Hi again :slight_smile:
I tried to ping the device, but unfortunately, I don’t receive Packages, also if I can ping the device from Windows. I tried also to ping the IP-Address of Google. With Googles IP Address, the script is working fine.
This is my code:

// check IP and Publish
IPAddress remoteIP(192, 168, 178, 23);
int numberOfReceivedPackage;
unsigned long lastTime = 0UL;
String received;

void setup() {

void loop() {
    unsigned long now = millis();
    //Every 15 seconds publish if host is up or down
    if (now-lastTime>15000UL) {
        lastTime = now;
        // now is in milliseconds
        numberOfReceivedPackage =;
        if (numberOfReceivedPackage > 0) {
            received = "Host up";
        } else {
            received = "Host down";

My code is based on the code of the article: “Getting started with spark.publish()”. I receive the data on a Webpage. (also based on the spark.publish() article. Any suggestions?


I have came to same result. Once is called, Spark.publish will not work.

I found a similar thing, I could not get a ping reply from a server’s IP on my home LAN until I logged in to that device and tried to ping back to the IP of the spark. I didn’t get a reply (as spark unhelpfully doesn’t respond to pings) but I think it caused the spark to do an arp lookup and then it had the mac of the spark and the server to be able to reply. Before I did this ping back, I was not even seeing the ICMP pings coming from the spark while sniffing with tcpdump on the server. As soon as I pinged back from the server to the spark, tcpdump started showing the icmp coming in.

I know this is resurrecting any ancient thread for which I apologise but in a way it’s perhaps arguably neater than creating a whole new one?

Can anyone clarify: do Cores and/or Photons reply to TCP/IP (not Cloud!) pings? I am trying to monitor their availability and I figured running Nagios Core might do the trick!

1 Like

Hi @daneboomer

The ping that you are talking about is really called ICMP Echo and happens at a level lower than TCP/IP but that is just technical detail.

The answer is complicated: early version of the Core firmware did reply to ping requests but later versions did not. I believe Photon’s reply to ping requests but I have not tested that in a while.

It is easy to try a ping from any PC/Mac/Linux host and see. Just have your device report its IP address over serial or Particle publish and then issue the ping command. If you have multiple home routers then you must set up the routers in such a way as to allow this but that is an unusual case. Many businesses and schools block ping requests because it was used in the past as an attack point so that might block you depending on where you are trying to do this.

1 Like