Arduino wifi shield

Arduino shields
Berichten: 68
Geregistreerd: 10 Apr 2013, 11:51

Arduino wifi shield

Berichtdoor Enschot » 20 Apr 2013, 11:58

Hallo allemaal,

ik ben een nieuweling, en heb een arduino uno met origineel wifi shield aangeschaft.
ik ben hier al enige tijd mee aan het stoeien, maar krijg het niet betrouwbaar werkend.
Ik wil het arduino uno boardje later besturen d.m.v. een programma geschreven in delphi.
Omdat ik al heel wat programmeer ervarig heb ben ik meteen begonnen om een server in delphi te schrijven, en een programmatje in c voor mijn arduino om wat data naar mijn server te sturen.
Dir werkte natuurlijk niet meteen, en daarom heb ik eerst maar geprobeert om wat data naar de internet explorer te zenden met onderstaand programmatje.

het programma werkt op zich wel, maar is niet erg betrouwbaar.
Het programma laat steeds op een lege internetpagina de 6 analoge waardes zien van de analoge poorten van mijn arduino uno printje.
regelmatig wordt echter de data verminkt, en mis ik stukken van de regels die worden weergegeven, en na 3 of 4 blokken stopt het programma.

Hopelijk kan iemand dit probleem voor mij oplossen.
Ik hoop dat ik een hele domme fout heb gemaakt, die simpel is op te lossen.

grtz frans


/*
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[] = "Ziggo446F8"; // your network SSID (name)
char pass[] = "KCk7KuczEW76"; // 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);
}

// 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("<!DOCTYPE HTML>");
client.println("<html>");
// 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("<br />");
}
client.println("</html>");
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(1000);

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

Advertisement

Berichten: 68
Geregistreerd: 10 Apr 2013, 11:51

Re: Arduino wifi shield

Berichtdoor Enschot » 14 Mei 2013, 19:39

Het probleem is opgelost.
Het bovenbeschreven probleem had meerdere oorzaken, maar de hoofd oorzaak was toch een defect Wifi shield. Nadat ik het printje had vervangen door een nieuw exemplaar waar ik maar liefst 3 weken op heb moeten wachten kon ik het programma uren zonder problemen laten werken.
Een ander probleem was onder andere de voeding die ik voor de UNO gebruikte. Ik had hier een van de standaard snoervoedingen gebruikt die ik nog een aantal had liggen, maar die gigantisch in elkaar storten als je deze gaat belasten. het heeft dagen geduurd voor ik dit in de gaten had.
Verder gaf mijn internet repeater problemen. Hoewel deze een sterker signaal afgaf dan mijn router weigerde het wifi shield te werken wanneer ik het via de repeater probeerde.
verder is het zo dat de hostnaam hoofdletter gevoelig is, waardoor ik soms wel een hoofdletter gebruikte, en andere keren weer niet.

Omdat ik met meerdere problemen te maken had was het erg moeilijk om de vinger op de zere plek te leggen, maar nu werkt het Wifi shield perfect. :D :P :lol:

grtz frans

Berichten: 13
Geregistreerd: 17 Jul 2013, 23:06

Re: Arduino wifi shield

Berichtdoor compukit » 17 Jul 2013, 23:17

ik heb het nog iets anders ik heb ook probleme er me ik krijg totaal niks te zien.
dit is mijn aan passing aan de sampel van adruino niks raars want ik ken er eignelijk niks van :$.
maar het wifi shield is pas nieuw dus daar 'zou' niks mis me moeten zijn .
dit is het programa

#include <WiFi.h>
#include <WiFiClient.h>
#include <WiFiServer.h>
#include <WiFiUdp.h>

/*
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[] = "compukit's netwerk"; // your network SSID (name)
char pass[] = "ga ik hier niet zeten "; // 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);
}

// 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("<!DOCTYPE HTML>");
client.println("<html>");
// 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("<br />");
}
client.println("</html>");
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");
}

kan me iemand zegen of er soms iets niet klopt of dat het toch wat hardware matig is.
ik ga morgen mijn 2de adruino los halen van mijn floppy driver projeckt en daar me proberen meschiens ligt het wel aan mijn adruino.
alvast bedankt.
Daniel
leef nu het kan want voor je het weet is het te laat :)

Berichten: 1
Geregistreerd: 10 Dec 2013, 13:32

Re: Arduino wifi shield

Berichtdoor erum » 10 Dec 2013, 13:34

Kan je niet op de Mega de ethernet shield prikken en daarbovenop weer het TFT shield ?.
het is mij nog steeds onduidelijk of je nu een probleem hebt met deze combi , of een software 'probleem' om deze tegelijkertijd te gebruiken.

Berichten: 13
Geregistreerd: 17 Jul 2013, 23:06

Re: Arduino wifi shield

Berichtdoor compukit » 10 Dec 2013, 19:12

Ik had het andwoord op mijn vraag gevonde door gewoon wat te proberen weet alleen niet meer wat het was ik weet wel dat het met de regels pass staad volgens mij was het zo dat ik maar een regel had aan gepast zodat die wel verbinding maakde maar verder niks of het was dat ik niet pass moest gebruike maar een andere term .(moet nog maar eens gaan zoeken want mijn lap waar het op stond is kappt dus ben ik dat kwijd denk ik)
compukit schreef:ik heb het nog iets anders ik heb ook probleme er me ik krijg totaal niks te zien.
dit is mijn aan passing aan de sampel van adruino niks raars want ik ken er eignelijk niks van :$.
maar het wifi shield is pas nieuw dus daar 'zou' niks mis me moeten zijn .
dit is het programa

#include <WiFi.h>
#include <WiFiClient.h>
#include <WiFiServer.h>
#include <WiFiUdp.h>

/*
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[] = "compukit's netwerk"; // your network SSID (name)
char pass[] = "ga ik hier niet zeten "; // 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);
}

// 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("<!DOCTYPE HTML>");
client.println("<html>");
// 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("<br />");
}
client.println("</html>");
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");
}

kan me iemand zegen of er soms iets niet klopt of dat het toch wat hardware matig is.
ik ga morgen mijn 2de adruino los halen van mijn floppy driver projeckt en daar me proberen meschiens ligt het wel aan mijn adruino.
alvast bedankt.
Daniel
leef nu het kan want voor je het weet is het te laat :)

Terug naar Shields

Wie is er online?

Gebruikers in dit forum: Geen geregistreerde gebruikers en 5 gasten