New to Arduino and WiFly

I am trying to run a simple sketch through an Arduino Pro Mini connected to the WiFly using the WiFlySerial library. I am VERY new to this and I’m using some code I have pulled from other sketches. I have included my .ino file…

All I want to do is call a local server ( and pull some data from the response.

This is the serial monitor of it when I upload and run it…

Starting Light Manager.
Free memory:915
Setting up WiFly
Starting WiFly...WiFlySerial v1.08 Free memory:901
MAC: 00:06:66:52:68:97
WiFly Sensors: 1
WiFly Temp: 1After Setup mem:901
Debug options:
Press '1' to send a test tweet
Press '2' to print current readings
Press '[' to access WiFly terminal to send commands to WiFly module

Beginning of Loop RAM:915
GET request:GET /api/newdeveloper/lights/3 HTTP/1.1
Connection: close

RAM: 657
Get request sent
Closing connection.

I was expecting to see the following response (which is what I get when I put in a browser):

{"state": {"on":false,"bri":0,"hue":0,"sat":0,"xy":[0.0000,0.0000],"ct":0,"alert":"none","effect":"none","colormode":"hs","reachable":true}, "type": "Extended color light", "name": "Living room", "modelid": "LCT001", "swversion": "65003148", "pointsymbol": { "1":"none", "2":"none", "3":"none", "4":"none", "5":"none", "6":"none", "7":"none", "8":"none" }}

Can anyone explain why this code:

while (  TimeOut > millis() && WiFly.isConnectionOpen() ) 
      if (  WiFly.available() > 0 ) {
        Serial << (char);

is not returning the response that I am showing above? It seems to be establishing a connection, but no response is being written to the serial monitor. Any help would be appreciated!

ManageLights.ino (10.5 KB)

  strRequest << F("GET ") << MY_SERVER_GET_URL 
     << F(" HTTP/1.1") << "\n"
     << F("Host: ") << MY_SERVER_GET << "\n"
     << F("Connection: close") << "\n"
     << "\n\n";

Lines in networking code usually end in “\r\n” and not only “\n”. It depends on the server you’re requesting the page from if it answers your request without getting correct data.

Okay, I tried adding the \r, but it didn’t seem to make any difference. I still seem to get no response.

  strRequest << F("GET ") << MY_SERVER_GET_URL 
     << F(" HTTP/1.1") << "\r\n"
     << F("Host: ") << MY_SERVER_GET << "\r\n"
     << F("Connection: close") << "\r\n"
     << "\r\n\r\n";

Any other suggestions?

I tried another thing… I put a serial output displaying the WiFly.isConnectionOpen() and WiFly.available() variables in the following while loop:

while (  TimeOut > millis() && WiFly.isConnectionOpen() ) 
      if (  WiFly.available() > 0 ) {
        Serial << (char);

It seems that the connection remains open during the while loop, but the available is 0, which would explain why no response data is being sent to the serial monitor. What does that mean? What does WiFly.available() check?

What does that mean? What does WiFly.available() check?

It checks how many bytes already arrived in the buffer. A value of 0 usually means that the server didn't respond.

Are you able to sniff the network traffic on your server with a tool like WireShark ( If so, check what's actually being sent and compare to your expectations.

Just a suggestion. I found that the WiFly manual provided a good detail. I've shared a WiFly communicator library (actually a fork from the Seeed WiFishield library).With that library you can use the native commands from the WiFly.

More info: Arduino Leonardo WiFly communicator library ⋆ Kasper Kamperman
GitHub - kasperkamperman/WiFly_communicator

The Wifly can be buggy sometimes with data and opening and closing connections.

How can I test what the server is or isn't responding given what the WiFly is sending? Is the get request string the data being sent to the server?

Will Wireshark enable me to see how the server responds?

It seems that Wireshark has to be installed on the server. Is that right?

That will be impossible since the “server” I am connecting to is actually the Phillips Hue bridge and not an actual server. It provides a simple API as you can see at this link…

WireShark has to be installed on a computer that gets the full network traffic. This might be any computer on a mirroring port of a switch or if everything is connected to a hub it works too.

Have you tried to use the telnet command to send the same data to the server?

telnet 80

Then send the data ("\r\n" is just hitting the return key). What do you get? Please post it.

I haven't tried that yet. I will give that a try later today. Thanks

I tried to telnet to the bridge ( and I get "Connection closed by foreign host."

Is there any other way that I can send the data to the bridge manually?

Did you try the command I posted or did you type your own command? My command connects to port 80, did yours too?

If you used my command and got this error message you probably also cannot connect with a browser from that computer.