Hi All
I have trouble connecting my Arduino Mega to my WiFi network. Here's the code in question:
#include "WiFi.h"
byte _ip[] = {192,168,0,122};
char ssid[] = "MyNetworkName";
char pass[] = "password";
void setup() {
Serial.begin(9600);
Serial.print(F("Starting Arduino. Free RAM: "));
Serial.println(freeRam());
int status = WiFi.status();
Serial.print(F("Wireless Status: "));
Serial.println(status);
Serial.print(F("Wireless Firmware Version: "));
Serial.println(WiFi.firmwareVersion());
while (status != WL_CONNECTED) {
Serial.print(F("Starting Network on SSID: "));
Serial.println(ssid);
WiFi.config(_ip);
status = WiFi.begin(ssid, pass);
for (int i=10;i>0;--i) {
Serial.print(i);
Serial.print(F(".."));
delay(1000);
}
status = WiFi.status();
Serial.print(F("Status:"));
Serial.println(status);
}
}
First of all, any calls to functions of the WiFi-Object block the process. If I add the following to the beginning of the setup function, the Library doesn't block anymore, but all calls fail, i.e. the connection is not established, the returned firmware number is empty and the status remains on 255 (WL_NO_SHIELD).
pinMode(8, OUTPUT);
digitalWrite(8, HIGH);
This modified behaviour is only observable with pin 8, all other pins lead to the same blocking behaviour. I also tried different versions (1.0.2, 1.0.5, 1.0.6 and 1.6.0) of the libraries and the firmware but that didn't help a thing. When I attach a Serial-to-USB-Cable to the debug port of the shield I only get scrambled data, nothing like a human readable message or interface.
Unfortunately I don't have an Arduino Uno for comparison testing available.
Also the example code from http://arduino.cc/en/Tutorial/ConnectWithWPA shows the same behaviour.
Does anyone have a clue, what the root cause might be?
Thank you and best regards
Stefan