WiFi Shield issues using WiFiClient/WiFiServer/WiFiUdp


This is my first attempt at using an Arduino, so please be kind.

I’ve just bought an Uno R3 and WiFi shield. I’ve tried “ConnectWithWPA” and that works fine - device gets assigned the IP address Next I went on to try WiFiWebServer, that didn’t seem to do anything, so I tried WiFiSendReceiveUDPString, then WiFiWebClient and again back to WiFiWebServer. Each time I try one of the examples I see nothing in the serial monitor log that indicates the Arduino has received a message.

So, example sketch:

#include <SPI.h>
#include <WiFi.h>

char ssid[] = "ssid";     //  your network SSID (name)
char pass[] = "password";  // your network password
int status = WL_IDLE_STATUS;     // the Wifi radio's status
char server[] = "www.google.com";    // name address for Google (using DNS)

WiFiClient client;

unsigned long time = millis();

void setup() {

  Serial.println("About to connect to Google");

  if (client.connect(server, 80)) {
    Serial.println("connected to server");
    // Make a HTTP request:
    client.println("GET /search?q=arduino HTTP/1.1");
    client.println("Host: www.google.com");
    client.println("Connection: close");

void connectToWiFi()

  // attempt to connect to Wifi network:
  while ( status != WL_CONNECTED) {
    Serial.print("Attempting to connect to WPA SSID: ");
    // Connect to WPA/WPA2 network:    
    status = WiFi.begin(ssid, pass);


  Serial.print("Connected to the network");

void loop() {

  // if there are incoming bytes available
  // from the server, read them and print them:

  while (client.available()) {
    char c = client.read();


  // if the server's disconnected, stop the client:
  if (!client.connected()) {
    Serial.println("disconnecting from server.");

    // do nothing forevermore:

void printTime()
  unsigned long currentTime = millis();
  if ((currentTime - time) > 10000)
    Serial.print("Time: ");
    time = currentTime;

void printWifiData() {
  // print your WiFi shield's IP address:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");

And the output on the serial monitor is:

Attempting to connect to WPA SSID: xyz
Connected to the networkIP Address:
About to connect to Google
Time: 35821

disconnecting from server.

I’m making a bit of a guess here, but since the client, server and udp example doesn’t work, the shield might need something doing to it? Also, I can ping the device ok. Any ideas on what might be wrong (with the code or device)?

Thank you

void connectToWiFi()

Not related to your problem, but initializing Serial has nothing to do with connecting to the WiFi network. Therefore, this does not belong in this function.

True - I only realised that myself after I removed a println before connectToWiFi that didn't work.

Ahh... I found a post on another forum that mentioned downgrading to v1.0.3 and at first thought it was a firmware change, but it's just a case of downloading version 1.0.3 of the IDE. The example works now :-)

What's different with v1.0.5 of the IDE that causes the WiFi to not work* correctly?

Thanks Victoria

  • For some people