Montemarciano, Ancona, Italia
Offline
Newbie
Karma: 0
Posts: 33
|
 |
« on: February 24, 2012, 02:48:46 pm » |
Hi to all, i'm experiencing with Arduino UNO R2 and the official Ethernet shield R2. When I upload a sketch that uses the ethernet shield, this shield crashes and the LED at pin 13 emits a faint light. I've tried to use the Arduino IDE v1.0, 0023, 0022, 0021 on both windows and linux but without any result.
Maybe this shield hardware is corrupted, and i should buy another shield?
|
|
|
|
|
Logged
|
|
|
|
|
Seattle, WA USA
Offline
Brattain Member
Karma: 316
Posts: 35519
Seattle, WA USA
|
 |
« Reply #1 on: February 24, 2012, 02:52:03 pm » |
When I upload a sketch that uses the ethernet shield, this shield crashes and the LED at pin 13 emits a faint light. Maybe this shield hardware is corrupted That or the code is bad. I'd vote for a code problem. Much cheaper to fix.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Tesla Member
Karma: 50
Posts: 6552
Arduino rocks
|
 |
« Reply #2 on: February 24, 2012, 02:59:55 pm » |
and the LED at pin 13 emits a faint light That is the on/off timing signal that is used by the shield on pin 13.
|
|
|
|
|
Logged
|
|
|
|
|
Montemarciano, Ancona, Italia
Offline
Newbie
Karma: 0
Posts: 33
|
 |
« Reply #3 on: February 24, 2012, 03:12:24 pm » |
That or the code is bad. I'd vote for a code problem. Much cheaper to fix. Well, all the sketches i've uploaded are examples where i've changed only the MAC address to suit with the MAC printed in the WizNet, and them crashes. So i don't think that the problem is the code. That is the on/off timing signal that is used by the shield on pin 13. I can't understand this. Can you explain me this more in detail?
|
|
|
|
« Last Edit: February 24, 2012, 03:14:59 pm by elQuero »
|
Logged
|
|
|
|
|
Seattle, WA USA
Offline
Brattain Member
Karma: 316
Posts: 35519
Seattle, WA USA
|
 |
« Reply #4 on: February 24, 2012, 03:22:46 pm » |
I can't understand this. Can you explain me this more in detail? It means that pin 13 is used by the ethernet shield. Any attempt to use pin 13 for anything else will screw up the communications with the ethernet shield. Regardless of where you got the code, post it. We don't want to guess what you are doing.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Tesla Member
Karma: 50
Posts: 6552
Arduino rocks
|
 |
« Reply #5 on: February 24, 2012, 03:35:08 pm » |
Below is some simple client test code you can try. Don't change the mac address. "and them crashes" doesn't indicate much hope of getting more technical detail of your setup. //zoomkat 12-08-11 //simple client test //for use with IDE 1.0 //open serial monitor and send an e to test //for use with W5100 based ethernet shields //note that the below bug fix may be required // http://code.google.com/p/arduino/issues/detail?id=605
#include <SPI.h> #include <Ethernet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address byte ip[] = { 192, 168, 1, 102 }; // ip in lan assigned to arduino //byte gateway[] = { 192, 168, 1, 1 }; // internet access via router //byte subnet[] = { 255, 255, 255, 0 }; //subnet mask byte myserver[] = { 208, 104, 2, 86 }; // zoomkat web page server IP address EthernetClient client; //////////////////////
void setup(){
Ethernet.begin(mac, ip); //Ethernet.begin(mac, ip, subnet, gateway); Serial.begin(9600); Serial.println("Better client test 12/01/11"); // so I can keep track of what is loaded Serial.println("Send an e in serial monitor to test"); // what to do to test }
void loop(){ // check for serial input if (Serial.available() > 0) //if something in serial buffer { byte inChar; // sets inChar as a byte inChar = Serial.read(); //gets byte from buffer if(inChar == 'e') // checks to see byte is an e { sendGET(); // call sendGET function below when byte is an e } } }
//////////////////////////
void sendGET() //client function to send/receive GET request data. { if (client.connect(myserver, 80)) { //starts client connection, checks for connection Serial.println("connected"); client.println("GET /~shb/arduino.txt HTTP/1.0"); //download text client.println(); //end of get request } else { Serial.println("connection failed"); //error message if no client connect Serial.println(); }
while(client.connected() && !client.available()) delay(1); //waits for data while (client.connected() || client.available()) { //connected or data available char c = client.read(); //gets byte from ethernet buffer Serial.print(c); //prints byte to serial monitor }
Serial.println(); Serial.println("disconnecting."); Serial.println("=================="); Serial.println(); client.stop(); //stop client
}
|
|
|
|
|
Logged
|
|
|
|
|
Montemarciano, Ancona, Italia
Offline
Newbie
Karma: 0
Posts: 33
|
 |
« Reply #6 on: February 25, 2012, 04:56:41 am » |
Now i'm at school, so I'll test this code this afternoon. "and them crashes" doesn't indicate much hope of getting more technical detail of your setup If you are referring to the few technical details that i've provided, i'm sorry but i can't understand the problem because the same sketches were ok two months ago. I've also tryed with another ethernet shield and i get the same results.
|
|
|
|
|
Logged
|
|
|
|
|
Miramar Beach, Florida
Offline
Faraday Member
Karma: 50
Posts: 3451
|
 |
« Reply #7 on: February 25, 2012, 07:04:18 am » |
Did you try zoomkat's code? Did you see the note in the code about the bug fix? That will cause the Arduino to stay in a "while(client.available())" loop forever. http://code.google.com/p/arduino/issues/detail?id=605
|
|
|
|
|
Logged
|
|
|
|
|
Montemarciano, Ancona, Italia
Offline
Newbie
Karma: 0
Posts: 33
|
 |
« Reply #8 on: February 25, 2012, 09:43:15 am » |
Well, i've tryed the zoomkat code and it is ok, the output is regular. So i've tryed first to change the MAC address whit my Ethernet Shield address and there isn't any issue. Then i've tryed to start the DHCP procedure by sobstituting Ethernet.begin(mac, ip); with Ethernet.begin(mac); and the shield crashes. So i think that the problem is the DHCP library. I've also experienced a loop in receiving data, because i use the linux compiler (i use lubuntu) for avr. But the ethernet shield begins correctly, that was my problem. So how can I fix this DHCP issue? Maybe i sould review the DHCP library code, or there is an updated version?
|
|
|
|
|
Logged
|
|
|
|
|
Miramar Beach, Florida
Offline
Faraday Member
Karma: 50
Posts: 3451
|
 |
« Reply #9 on: February 25, 2012, 09:48:33 am » |
Is there a dhcp server on the localnet? If the dhcp part is failing, it is not getting an ip from a dhcp server. It may take around a minute to timeout. if(Ethernet.begin(mac) == 0) { Serial.println("No dhcp"); }
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Tesla Member
Karma: 50
Posts: 6552
Arduino rocks
|
 |
« Reply #10 on: February 25, 2012, 12:53:28 pm » |
More test code similar to the first I posted. //zoomkat 2-13-12 //DNS and DHCP-based web client test code //for use with IDE 1.0 //open serial monitor and send an e to test //and to see test result //for use with W5100 based ethernet shields //browser equivelant URL: //http://web.comporium.net/~shb/arduino.txt //note that the below bug fix may be required // http://code.google.com/p/arduino/issues/detail?id=605
#include <SPI.h> #include <Ethernet.h> byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address char serverName[] = "web.comporium.net"; // zoomkat's test web page server EthernetClient client;
//////////////////////
void setup(){ Serial.begin(9600); Serial.println("DNS and DHCP-based web client test 2/13/12"); // so I can keep track of what is loaded Serial.println("Send an e in serial monitor to test"); // what to do to test // start the Ethernet connection: if (Ethernet.begin(mac) == 0) { Serial.println("Failed to configure Ethernet using DHCP"); // no point in carrying on, so do nothing forevermore: while(true); } // print your local IP address: Serial.print("Arduino IP address: "); for (byte thisByte = 0; thisByte < 4; thisByte++) { // print the value of each byte of the IP address: Serial.print(Ethernet.localIP()[thisByte], DEC); Serial.print("."); } Serial.println(); Serial.println(); }
void loop(){ // check for serial input if (Serial.available() > 0) //if something in serial buffer { byte inChar; // sets inChar as a byte inChar = Serial.read(); //gets byte from buffer if(inChar == 'e') // checks to see byte is an e { sendGET(); // call sendGET function below when byte is an e } } }
//////////////////////////
void sendGET() //client function to send/receive GET request data. { if (client.connect(serverName, 80)) { //starts client connection, checks for connection Serial.println("connected"); client.println("GET /~shb/arduino.txt HTTP/1.0"); //download text client.println(); //end of get request } else { Serial.println("connection failed"); //error message if no client connect Serial.println(); }
while(client.connected() && !client.available()) delay(1); //waits for data while (client.connected() || client.available()) { //connected or data available char c = client.read(); //gets byte from ethernet buffer Serial.print(c); //prints byte to serial monitor }
Serial.println(); Serial.println("disconnecting."); Serial.println("=================="); Serial.println(); client.stop(); //stop client
}
|
|
|
|
|
Logged
|
|
|
|
|
Montemarciano, Ancona, Italia
Offline
Newbie
Karma: 0
Posts: 33
|
 |
« Reply #11 on: February 26, 2012, 10:32:58 am » |
Well, i think that this image will explain what i meen for "faint light"  By elquero93 at 2012-02-26 In this photo you can see the led at pin13 light emitted when i try to run the last zoomkat sketch. This light is emitted all times that I try to call the DHCP procedure, and is continously emitted up to I unplug the Arduino, so I think that the problem is the DHCP library.
|
|
|
|
|
Logged
|
|
|
|
|
Miramar Beach, Florida
Offline
Faraday Member
Karma: 50
Posts: 3451
|
 |
« Reply #12 on: February 26, 2012, 10:37:54 am » |
And what did the serial monitor say? Failed to configure Ethernet using DHCP or Arduino IP address: 192.168.0.22
|
|
|
|
|
Logged
|
|
|
|
|
Montemarciano, Ancona, Italia
Offline
Newbie
Karma: 0
Posts: 33
|
 |
« Reply #13 on: February 26, 2012, 10:43:11 am » |
Ohw, I forgot to say that the serial monitor doesn't say nothing, i can only see serial output before Ethernet.begin(mac);
|
|
|
|
|
Logged
|
|
|
|
|
Miramar Beach, Florida
Offline
Faraday Member
Karma: 50
Posts: 3451
|
 |
« Reply #14 on: February 26, 2012, 10:46:24 am » |
And how long do you wait for the response? I usually do not quote myself, but... Is there a dhcp server on the localnet? If the dhcp part is failing, it is not getting an ip from a dhcp server. It may take around a minute to timeout.
|
|
|
|
|
Logged
|
|
|
|
|
|