Very much so! You can use the TCPClient functionality to do it: http://docs.spark.io/#/firmware/communication-tcpclient
TCPClient client;
byte server[] = { 74, 125, 224, 72 }; // Google
This is the start of the (above) example TCPClient code. The four numbers separated by commas are where youâll put the IP (dotted quad) of the server youâre trying to connect to.
void setup()
{
Serial.begin(9600);
delay(1000);
Serial.println("connecting...");
if (client.connect(server, 80))
{
Serial.println("connected");
client.println("GET /search?q=unicorn HTTP/1.0");
client.println();
}
else
{
Serial.println("connection failed");
}
}
In this example, the client.println acts in a very similar manner to your standard serial.println function. Essentially, itâs just âprintingâ whatever is in the quotes to the IP you entered at the start. In your case, youâd want to use something like GET /ping.php HTTP/1.0
to get the desired response. Note the client.connect(server, 80) beforehand, which tells the function to connect over the standard HTTP port, 80.
void loop()
{
if (client.available())
{
char c = client.read();
Serial.print(c);
}
if (!client.connected())
{
Serial.println();
Serial.println("disconnecting.");
client.stop();
for(;;)
;
}
}
Here, the char c = client.read(); reads the response from your ping.php script into a char called c. Note that all the setup is done in void setup, however you could move the entire * if (client.connect(server, 80))* section into void loop if you wanted it to poll the PHP script on each iteration. Be sure to put a delay in there so itâs not slamming the server.
(As you can see from the example script, itâs designed to search Google and print the RAW HTML response over the serial port. You donât actually need any of the serial stuff for TCPClient, itâs just handy to have for debugging!)
Let me know if this gets you pointed in the right direction. If you need any specific advice or help, donât hesitate to ask and weâll do what we can to get you going!