I am using the WiFly shield and am wanting to connect it to my 3G Wifi Card from Verizon. I can connect using my personal laptop by simply entering the ssid and the passphrase off the back of my wifi card. When I enter those same credentials into the credentials file, the WiFly shield has trouble connecting. Anybody have any suggestions?
My code:
WiFly.begin();
if (!WiFly.join(ssid, passphrase))
{
Serial.println("Connection Failed!");
while(1)
{
Serial.println("Hang on Failure");
// Hang on failure.
}
}
#include "WiFly.h" // WiFly Library
#include "Credentials.h" // Credentials File for Wifi
Server server (80);
void setup()
{
WiFly.begin();
if (!WiFly.join(ssid, passphrase))
{
Serial.println("Connection Failed!");
while(1)
{
Serial.println("Hang on Failure");
// Hang on failure.
}
}
Serial.print("IP: ");
Serial.println(WiFly.ip());
}
void loop()
{
Client client = server.available();
if (client)
{
// an http request ends with a blank line
boolean current_line_is_blank = true;
while (client.connected())
{
if (client.available())
{
char c = client.read();
// if we've gotten to the end of the line (received a newline
// character) and the line is blank, the http request has ended,
// so we can send a reply
if (c == '\n' && current_line_is_blank)
{
// send a standard http response header
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println();
//Print data to webpage
client.print("<meta http-equiv=\"refresh\" content=\"30\">"); //refresh every 10 seconds
client.println("<title>The Plant Nanny</title>");
client.println("<h1>The Plant Nanny: Plant Monitoring System</h1>");
client.println("<h2>My Plant Data:</h2>");
client.print("<p>Temperature is ");
client.print(temp_erature);
client.print("°"); //insert degree symbol
client.print("F</p>");
client.print("<p>Humidity is ");
client.print(average);
client.print(" % RH</p>");
client.print("<p>Soil Moisture is ");
client.print(vwc);
client.print("%</p>");
client.print("<p>Sun Light is ");
client.print(sun_average);
client.print(" Lux</p>");
client.print("</div>");
break;
}
if (c == '\n')
{
// we're starting a new line
current_line_is_blank = true;
}
else if (c != '\r')
{
// we've gotten a character on the current line
current_line_is_blank = false;
}
}
}
delay(1); // give the web browser time to receive the data
client.stop();
}
}
My goal update a page (IP Address on the network) with some values. I would put the rest of the code up there but it is literally about 4200 lines of code. I don't think anybody wants to sift through that to help so I have dumbed it down (the wifi part at least).