I can't figure out, why wifly shield is not connecting.
It looks like the code does not go past the below loop.
if (!WiFly.join(ssid, passphrase)) {
Serial.print("ifError");
while (1) {
Serial.print("Error");
}
}
Below is my simple "hello world" webserver code!
#include "WiFly.h"
char passphrase[] = "xxxx-xxxx-xxxx";
char ssid[] = "***** test wireless";
Server server(80);
void setup() {
Serial.begin(9600);
Serial.println("Setting up");
WiFly.begin();
Serial.println("WiFly started");
if (!WiFly.join(ssid, passphrase)) {
Serial.print("ifError");
while (1) {
Serial.print("Error");
}
}
Serial.println("Can u reach me ?");
Serial.print("IP: ");
Serial.println(WiFly.ip());
// myservo.attach(5);
server.begin();
}
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();
Serial.print(c);
// 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();
client.print("Hello World!");
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;
}
}
}
// give the web browser time to receive the data
delay(100);
client.stop();
}
}
Serial Monitor shows below and nothing else after that :-
Setting up
WiFly started
I checked my wlan auth, wlan phrase, wlan join. All the setting seem to be fine. when I run the "SpiUartTerminal" and save and reboot it connects to WiFly fine! says "associated" !!
You haven't defined which WiFly shield you're using (there are some which communicates by UART, some by SPI) and you haven't provided a link to the library you're using. Too much guess work for the community really help you.
I am using TeraTerm VT instead of Arduino serial monitor.
get ip
IF=DOWN
DHCP=ON
IP=0.0.0.0:80
NM=0.0.0.0
GW=0.0.0.0
HOST=0.0.0.0:2000
PROTO=TCP,
MTU=1524
FLAGS=0x7
BACKUP=0.0.0.0
<2.23> get wlan
SSID=spandy test wireless
Chan=0
ExtAnt=0
Join=0
Auth=OPEN
Mask=0x1fff
Rate=12, 24 Mb
Linkmon=1
Passphrase=****-****-y9i0
<2.23> scan
<2.23>
SCAN:Found 1
Num SSID Ch RSSI Sec MAC Address Suites
1 spandy test wireless 01 -36 WPAv1 98:fc:11:a8:ad:af TKIPM-TKIP 3104 0
join
Auto-Assoc spandy test wireless chan=1 mode=WPA1 SCAN OK
Joining spandy test wireless now..
<2.23> Associated!
DHCP: Start
show net
SSid=spandy test wireless
Chan=1
Assoc=OK
Rate=12, 24Mb
Auth=OK
Mode=WPA1
DHCP=FAIL
Boot=0
Time=OK
Links=2
<2.23>
<2.23> Disconn from spandy test wireless,LOST-AP
any idea why DHCP fails? and after awhile it is disconnected.
I was working Arduino 0023 yesterday today I started working in Arduino 1.0
The code I am using at the moment:
#include <SPI.h>
#include <WiFly.h>
char passphrase[] = "****-****-y9i0";
char ssid[] = "spandy test wireless";
WiFlyServer server(80);
void setup() {
Serial.begin(9600);
Serial.println("Setting up");
WiFly.begin();
Serial.println("WiFly started");
if (!WiFly.join(ssid, passphrase)) {
//Serial.print("ifError");
while (1) {
Serial.print("if_Error");
}
}
Serial.println("Can u reach me ?");
Serial.print("IP: ");
Serial.println(WiFly.ip());
// myservo.attach(5);
server.begin();
}
void loop() {
WiFlyClient 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();
Serial.print(c);
// 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();
client.print("Hello World!");
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;
}
}
}
// give the web browser time to receive the data
delay(100);
client.stop();
}
}
On the serial monitor or TeraTerm VT
Setting up
WiFly started
if_Errorif_Errorif_Errorif_Errorif_Errorif_Errorif_Errorif_Errorif_Errorif_Errorif_Errorif_Errorif_Errorif_Error
It is stuck in that loop because DHCP is failing! any suggestions on what I am doing wrong.??
Please help
Are you sure you use the current version of the library? The new version has timeouts for all functions and join() must return after some time. Can you check that you're using that version. It's important also because only the new version does support the SPI version of the shield (which you have).
I have checked, I am using the latest version of the library.
So since then I have been running "SpiUartTerminal" to manually connect to the WiFi first.
(I am using TeraTerm VT instead of Arduino serial monitor)
get wlan
SSID=TechnicalTest
Chan=0
ExtAnt=0
Join=0
Auth=WPA2
Mask=0x1fff
Rate=12, 24 Mb
Linkmon=1
Passphrase=5*****8085
<2.23> scan
<2.23>
SCAN:Found 1
Num SSID Ch RSSI Sec MAC Address Suites
1 TechnicalTest 11 -31 WPA2PSK 00:60:64:3e:07:1c AESM-AES 310c 0
join
Auto-Assoc TechnicalTest chan=11 mode=WPA2 SCAN OK
Joining TechnicalTest now..
<2.23> Associated!
DHCP: Start
DHCP in 17ms, lease=86400s
IF=UP
DHCP=ON
IP=192.168.2.167:80
NM=255.255.255.0
GW=192.168.2.254
Listen on 80
show net
SSid=TechnicalTest
Chan=11
Assoc=OK
Rate=12, 24Mb
Auth=OK
Mode=WPA2
DHCP=OK,renew=64792
Boot=242017
Time=FAIL
Links=1
[b]<2.23> Disconn from TechnicalTest,LOST-AP[/b]
disconnects after 30 sec or so.
Nothing wrong with Wifi AP. I am have connected my phone to it and it works fine!
You probably should set wlan linkmon to a value greater than 1. If it's greater than 0 the WiFly checks the connection to the AP once a second. If the value is 1 (as it is for your module) one failure is enough to terminate the connection. Try setting it to 10 or so.