Go Down

Topic: Wifi-shield is making me insane (Read 290 times) previous topic - next topic

jtpek

I've tried to get my new wifi-shield to work the whole day without success. Also I haven't found any helpful topics considering my problem. So I have to start a new topic..

I have found available networks succesfully AND I've been able to connect to them, too. For example I've tried the "connect with WPA"-example and got:

Code: [Select]
Attempting to connect to WPA SSID: Elisa-c...
You're connected to the networkSSID: Elisa-c....
BSSID: 0:C:.............
signal strength (RSSI):-54
Encryption Type:4

IP Address: 19............
19.............
MAC address: 78.............


However I'm not able to send or receive. I tried the example "WifiWebClient" without success. Here is the code I used:

Code: [Select]
#include <SPI.h>
#include <WiFi.h>

char ssid[] = "xxxxxxxxxxx"; //  your network SSID (name)
char pass[] = "xxxxxxxxxxx";    // your network password (use for WPA, or use as key for WEP)
int keyIndex = 0;            // your network key Index number (needed only for WEP)

int status = WL_IDLE_STATUS;
// if you don't want to use DNS (and reduce your sketch size)
// use the numeric IP instead of the name for the server:
//IPAddress server(74,125,232,128);  // numeric IP for Google (no DNS)
char server[] = "www.google.com";    // name address for Google (using DNS)

// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):
WiFiClient client;

void setup() {
  //Initialize serial and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }

  // check for the presence of the shield:
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present");
    // don't continue:
    while(true);
  }

  // attempt to connect to Wifi network:
  while (status != WL_CONNECTED) {
    Serial.print("Attempting to connect to SSID: ");
    Serial.println(ssid);
    // Connect to WPA/WPA2 network. Change this line if using open or WEP network:   
    status = WiFi.begin(ssid, pass);

    // wait 10 seconds for connection:
    delay(10000);
  }
  Serial.println("Connected to wifi");
  printWifiStatus();

  Serial.println("\nStarting connection to server...");
  // if you get a connection, report back via serial:
  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");
    client.println();
  }
}

void loop() {
  // if there are incoming bytes available
  // from the server, read them and print them:
  while (client.available()) {
    char c = client.read();
    Serial.write(c);
  }

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

    // do nothing forevermore:
    while(true);
  }
}


void printWifiStatus() {
  // print the SSID of the network you're attached to:
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

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

  // print the received signal strength:
  long rssi = WiFi.RSSI();
  Serial.print("signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
}


..serial output:

Code: [Select]
Attempting to connect to SSID: Elisa-c...
Connected to wifi
SSID: Elisa-c...
IP Address: 19..................
signal strength (RSSI):-57 dBm

Starting connection to server...

disconnecting from server.


So I can connect to the network, but nothing else.

Also I tried to use xively today, but the problem was the same. The code I used :

Code: [Select]
/*
##Xively WiFi Sensor Tutorial##
This sketch is designed to take sensors (from photocell) and upload the values to Xively
at consistant intervals. At the same time it gets a setable value from Xively to adjust the brigthness
of an LED. This sketch is reusable and can be adapted for use with many different sensors.
Derived from Xively Ardino Sensor Client by Sam Mulube.
By Calum Barnes 3-4-2013
BSD 3-Clause License - [http://opensource.org/licenses/BSD-3-Clause]
Copyright (c) 2013 Calum Barnes
*/
#include <SPI.h>
#include <WiFi.h>
#include <HttpClient.h>
#include <Xively.h>

char ssid[] = "Elisa-c..."; // your network SSID (name)
char pass[] = "7........................"; // your network password (use for WPA, or use as key for WEP)
//int keyIndex = 0; // your network key Index number (needed only for WEP)

int status = WL_IDLE_STATUS;

// Your Xively key to let you upload data
char xivelyKey[] = "XGP........................................................................";
//your xively feed ID
#define xivelyFeed 1.....................
//datastreams
char sensorID[] = "paineanturi";
char ledID[] = "LED_CHANNEL";

// Analog pin which we're monitoring (0 and 1 are used by the Ethernet shield)
#define sensorPin A0
//led connected pin
#define ledPin 9

// Define the strings for our datastream IDs
XivelyDatastream datastreams[] = {
XivelyDatastream(sensorID, strlen(sensorID), DATASTREAM_FLOAT),
XivelyDatastream(ledID, strlen(ledID), DATASTREAM_FLOAT),
};
// Finally, wrap the datastreams into a feed
XivelyFeed feed(xivelyFeed, datastreams, 2 /* number of datastreams */);

WiFiClient client;
XivelyClient xivelyclient(client);

void printWifiStatus() {
// print the SSID of the network you're attached to:
Serial.print("SSID: ");
Serial.println(WiFi.SSID());

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

// print the received signal strength:
long rssi = WiFi.RSSI();
Serial.print("signal strength (RSSI):");
Serial.print(rssi);
Serial.println(" dBm \n");
}
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
//pin setup
pinMode(sensorPin, INPUT);
pinMode(ledPin, OUTPUT);
Serial.println("Starting single datastream upload to Xively...");
Serial.println();

// attempt to connect to Wifi network:
while ( status != WL_CONNECTED) {
Serial.print("Attempting to connect to SSID: ");
Serial.println(ssid);
status = WiFi.begin(ssid, pass);
// wait 10 seconds for connection:
delay(10000);
}
Serial.println("Connected to wifi");
printWifiStatus();
}

void loop() {
//adjust LED level. set from Xively
int getReturn = xivelyclient.get(feed, xivelyKey); //get data from xively
if(getReturn > 0){
Serial.println("LED Datastream");
Serial.println(feed[1]);
}else Serial.println("HTTP Error");
//write value to LED - change brightness
int level = feed[1].getFloat();
if(level < 0){
level = 0;
}else if(level > 255){
level = 255;
}
//actually write the value
digitalWrite(ledPin, level);
///////////////////////////////////////////////////////
//read sensor values
int sensorValue = analogRead(sensorPin);
datastreams[0].setFloat(sensorValue);
//print the sensor valye
Serial.print("Read sensor value ");
Serial.println(datastreams[0].getFloat());

//send value to xively
Serial.println("Uploading it to Xively");
int ret = xivelyclient.put(feed, xivelyKey);
//return message
Serial.print("xivelyclient.put returned ");
Serial.println(ret);
Serial.println("");
//delay between calls
delay(15000);
}


..serial:
Code: [Select]

Starting single datastream upload to Xively...

Attempting to connect to SSID: Elisa-c......
Connected to wifi
SSID: Elisa-c6f0
IP Address: 19.......
signal strength (RSSI):-54 dBm

HTTP Error
Read sensor value 627.00
Uploading it to Xively
xivelyclient.put returned -1


So, I'm a beginner and I would appreciate any help. Do I have to update my wifi's firmware? Or is there some other problem? I'm quite unsure with the firmware update, because all the tutorials are quite confusing and I'm afraid of braking the shield.

One more thing..I've noticed the blue light is not blinking at all..

Thank you very much for help!

ƎR

yes you have to upgrade the firmware
http://arduino.cc/en/Hacking/WiFiShieldFirmwareUpgrading
Riccardo Ertolupi of the Vicenza Thunders Team: http://www.VicenzaThunders.com

Go Up