Arduino web server with Sparkfun WiFi shield

Sample WiFi server sketch not working. The system never seems to “see” the Sparkfun’s WiFi shield. I am using the sample code included with the Arduino IDE: “WiFiWebServer.ino”, and yes, I have specified my ssid and password. However, I always get “Wifi Shield not present”. I have also downloaded the SFE library, and yes, I put it in the right place under the “libraries” folder in my Arduino implementation, so, I have the SFE sample sketches for Web_Client. The client sketch seems to work fine, since it returns the HTML code from the “www.example.com” page. What am I missing?

Note: An answer including a simple working sample sketch would be awesome answer!

Since you didn’t receive a reply on your last post, then something your doing is wrong. At least this time you posted what code you are using… But just because you posted that doesn’t mean that everyone here has it. So post the code.

I did some research and it seems like it’s always the users fault for the “sketch” isn’t working. You might want to use Google to troubleshoot your issue. I will say that it’s 100% not the sketches fault for it not working. Do you think someone would post a non working sketch? Maybe. But do you think that after all this time that someone would complain about it not working? Definitely.

1.- The “sketch not working” phrase is just to denote a problem, did not mean the original sketch was not working, if you read the whole text, I also ask: “What am I missing”??? You obviously did not read that part, but yes, I know it is not the sketch, so wasted words there, codlink.

2.- Here is the sketch that everybody has, since like I said, it is in the list of sample sketches that come with the IDE:

/*

WiFi Web Server

A simple web server that shows the value of the analog input pins.

using a WiFi shield.

This example is written for a network using WPA encryption. For

WEP or WPA, change the Wifi.begin() call accordingly.

Circuit:

  • WiFi shield attached

  • Analog inputs attached to pins A0 through A5 (optional)

created 13 July 2010

by dlf (Metodo2 srl)

modified 31 May 2012

by Tom Igoe

*/

#include <SPI.h>

#include <WiFi.h>

char ssid = “yourNetwork”; // your network SSID (name)

char pass = “secretPassword”; // your network password

int keyIndex = 0; // your network key Index number (needed only for WEP)

int status = WL_IDLE_STATUS;

WiFiServer server(80);

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);

}

String fv = WiFi.firmwareVersion();

if ( fv != “1.1.0” )

Serial.println(“Please upgrade the firmware”);

// 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);

}

server.begin();

// you’re connected now, so print out the status:

printWifiStatus();

}

void loop() {

// listen for incoming clients

WiFiClient client = server.available();

if (client) {

Serial.println(“new client”);

// an http request ends with a blank line

boolean currentLineIsBlank = true;

while (client.connected()) {

if (client.available()) {

char c = client.read();

Serial.write(c);

// if you’ve gotten to the end of the line (received a newline

// character) and the line is blank, the http request has ended,

// so you can send a reply

if (c == ‘\n’ && currentLineIsBlank) {

// send a standard http response header

client.println(“HTTP/1.1 200 OK”);

client.println(“Content-Type: text/html”);

client.println(“Connection: close”); // the connection will be closed after completion of the response

client.println(“Refresh: 5”); // refresh the page automatically every 5 sec

client.println();

client.println(“”);

client.println(“”);

// output the value of each analog input pin

for (int analogChannel = 0; analogChannel < 6; analogChannel++) {

int sensorReading = analogRead(analogChannel);

client.print("analog input ");

client.print(analogChannel);

client.print(" is ");

client.print(sensorReading);

client.println("
");

}

client.println(“”);

break;

}

if (c == ‘\n’) {

// you’re starting a new line

currentLineIsBlank = true;

}

else if (c != ‘\r’) {

// you’ve gotten a character on the current line

currentLineIsBlank = false;

}

}

}

// give the web browser time to receive the data

delay(1);

// close the connection:

client.stop();

Serial.println(“client disonnected”);

}

}

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");

}

3.- If you researched and found a sketch using the sparkfun’s WiFi shield as server, then that’s all I need. I have googled it in many ways, but I guess I am not using the right words, maybe.

4.- By the way… I know I need to use the SFE library and methods. I just don’t know how what the server related objects and methos are. I also know I am doing something wrong, otherwise I wouldn’t be asking… Don’t you think, codelink?

5.-Hey… If my questions are bothering somebody, just let me know, I guess this is not the only place I can ask questions, without offending anybody.

  1. When you stated “the sketch isn’t working,” what else would anybody think was wrong? We can’t read minds here…

  2. Yes, you are correct, it is in the examples. But, in my defense I have never used that library nor have I ever searched for it. Another thing to note is you stated you have the SFE library, to my knowledge, SFE libraries are not standard within the IDE…

  3. I Googled “WiFiWebServer” and read some threads on the Arduino forum concerning this sketch. Most people just have the IPs wrong…

  4. Nothing really to say here except it’s codlink… lol?

  5. It bothers the members here when beginners come on here and ask for help but they are unwilling to help us to help them. Example would be, why not tell us exactly what troubleshooting steps you have already taken, how it’s hooked up, what other devices are connected, etc. In your case, have you made sure your IPs are correct? What are you seeing in the serial monitor?

As you can tell, I am not experienced with the WiFi shield. But many members here are, so if they don’t respond, it means that you haven’t posted enough info for anyone to help. You may even have to write a book to trigger someone’s mind to realize what you are doing wrong. Maybe you just missed a step…

OK… Attached are several pictures showing the Arduino board and the WiFi module, each by itself, and then there is one showing the WiFi module attached to the Arduino. There s nothing else to show, codlink. After connecting the arduino via USB to the computer, I upload the mentioned sketch and I get the error saying the WiFi module is not present. If I use the SFE (Spark Fun Electronics) sample sketch to access the “www.example.com” domain as a client (using the WebClient.ino, in the SFE_CC3000_Library_master library) the system connects with no problems. Also the “ConnectionTest” sketch works fine, returning everything it should.

Again, all I am looking for is a working WiFi web server sketch that uses the SFE library (SFE_CC3000 objects), because the original web server sample sketch in the Arduino IDE does not work with the SparkFun’s CC3000 WiFi module.

I am not sure what else I can tell you. Please tell me what else you need so you do not need to “read my mind”, but only read what I write.

I see you have read the product’s comment section. Like I said before I don’t have any experience with this shield.

I did ask if you have the correct IPs. You failed to answer so I will post this bit of code. Have you changed this information with your own?

char ssid[] = "yourNetwork"; // your network SSID (name)
char pass[] = "secretPassword"; // your network password
int keyIndex = 0; // your network key Index number (needed only for WEP)

I downloaded SFE’s library and see that it doesn’t have a server example. So why are you using a sketch that doesn’t use SF’s library? Have you tried Adafruit’s library?

Google “cc3000 web server” and have a read through.

Other than that, contact SF’s tech support.