Go Down

Topic: arduino uno clone with wiznet ethernet problem (Read 985 times) previous topic - next topic

Jan 17, 2012, 05:34 pm Last Edit: Jan 17, 2012, 05:49 pm by kasperfish Reason: 1
I purchased an arduino uno clone from china (ATmega328 , and the USB-to-serial converter chip is Atmega8U2) and a wiznet w5100 ethernet shield from ebay. I'm not able to ping my device and I'm sure my network settings are correct. I found a topic here on the forum dealing with the same issues as I do. here is a link to that topic http://arduino.cc/forum/index.php/topic,72566.75.html. it appeared that the problem was the arduino board (freeduino) and replacing it with an other uno resolved the problem.

so now my question... I uploaded the sketch below with these results:

A) arduino + ethernetshield -> led 13 not blinking
B) arduino with no shield    -> led 13 not blinking
c) if I comment out  Ethernet.begin(mac, ip, gateway, subnet) led 13 on the uno board is blinking as expected.

I have read that led 13 must  blink in case A and B (although a little dimmer in case A). Is this correct? and can I conclude that my arduino uno clone has a defect based on these findings?  or can I try something else?

I'm using arduino 1

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

byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0x59, 0x67 };  
byte ip[] = { 192, 168, 0, 2 };    
byte gateway[] = { 192, 168, 0, 1 };
byte subnet[] = { 255, 255, 255, 0 };

void setup()
{
 Serial.begin(9600);
 Ethernet.begin(mac, ip, gateway, subnet);
 pinMode(13,OUTPUT);
}

void loop()
{
 digitalWrite(13,HIGH);
 delay(500);
 digitalWrite(13,LOW);
 delay(500);
}


any help is appreciated!

peace


SurferTim

#1
Jan 17, 2012, 05:47 pm Last Edit: Jan 17, 2012, 05:50 pm by SurferTim Reason: 1
Have you tried that code without the shield and no Ethernet.begin() in the sketch?

And the V1.0 Ethernet.begin() is different than what you are using. The V1.0 requires a dns server ip in there. I have found that if you don't use dns, it really doesn't matter what ip you give it.

Here are the choices for a static ip assignment. Note after just an IP, all else require a dns ip:
Code: [Select]
void begin(uint8_t *mac_address, IPAddress local_ip);
void begin(uint8_t *mac_address, IPAddress local_ip, IPAddress dns_server);
void begin(uint8_t *mac_address, IPAddress local_ip, IPAddress dns_server, IPAddress gateway);
void begin(uint8_t *mac_address, IPAddress local_ip, IPAddress dns_server, IPAddress gateway, IPAddress subnet);


Ping first.

Have you tried that code without the shield and no Ethernet.begin() in the sketch?

yes I did, read A B C cases in my first post for the blink blink results :-) if I comment out ethernet.begin the led is blinking.


And the V1.0 Ethernet.begin() is different than what you are using. The V1.0 requires a dns server ip in there. I have found that if you don't use dns, it really doesn't matter what ip you give it.

I tried adding a dns in the Ethernet.begin function but cant ping the arduino and no blink blink

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

byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0x59, 0x67 }; 
byte ip[] = { 192, 168, 0, 2 };
byte dns[] = { 195,130,130,4 };
byte gateway[] = { 192, 168, 0, 1 };
byte subnet[] = { 255, 255, 255, 0 };

void setup()
{
  Serial.begin(9600);
  Ethernet.begin(mac, ip,dns, gateway, subnet);
  pinMode(13,OUTPUT);
}

void loop()
{
  digitalWrite(13,HIGH);
  delay(500);
  digitalWrite(13,LOW);
  delay(500);
}







SurferTim

Is there a dhcp server on that localnet? If so, try this:
Code: [Select]
#include <SPI.h>
#include <Ethernet.h>

byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0x59, 0x67 }; 

void setup()
{
  Serial.begin(9600);
  // Get ip from dhcp server.
  if(Ethernet.begin(mac)) Serial.println("dhcp ok");
  else Serial.println("No dhcp");
}

void loop()
{
}


#4
Jan 17, 2012, 06:28 pm Last Edit: Jan 17, 2012, 06:35 pm by kasperfish Reason: 1
yes there is dhcp on my wireless d-link dir-615 router  (range 192.168.0.100 - 192.168.0.199). my arduino is connected with a cable to the Ethernet port. my laptop is connected wireless.

the serial monitor is out putting dhcp ok

thank you for the quick responses!

peace

edit: the arduino does not get an ip automatically from dhcp :-(

SurferTim

That is a good sign! That means the ethernet shield is working, and the SPI is working.  :)

Now it is only a matter of software. How about this code?
Code: [Select]
#include <SPI.h>
#include <Ethernet.h>

byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0x59, 0x67 }; 
byte ip[] = { 192, 168, 0, 2 };
byte dns[] = { 195,130,130,4 };
byte gateway[] = { 192, 168, 0, 1 };
byte subnet[] = { 255, 255, 255, 0 };

void setup()
{
  Serial.begin(9600);
  Serial.println("starting setup");
  Ethernet.begin(mac, ip,dns, gateway, subnet);
  delay(2000);
  Serial.println("setup ok");
}

void loop()
{
}

Do you get "setup ok"?

yeah bro I get setup ok from the serial monitor

nothing in arp table though...
pinging -> host unreachable

SurferTim

#7
Jan 17, 2012, 06:42 pm Last Edit: Jan 17, 2012, 06:47 pm by SurferTim Reason: 1
arp table! OK! Now we are talking! Some routers do not get an arp entry until the client ip attempts a connection. That code does nothing.

Can you ping 192.168.0.2? If so, then check arp table.

Edit: My bad. Missed that. Still no ping?

Is there an arp or dhcp entry in the router from the dhcp code?

BTW, "host unreachable" is normally a routing problem. What is the ip of the computer you are attempting the ping from?

no there is no entry in the arp table nor in cmd arp -a. my laptop ip is in the dhcp range 192.168.0.195. when I connect my laptop with a cable to the router my ip is not in the wireless dhcp range but something different can't remember exactly. I guess it is something with my router...

ok, I can ping the arduino now :-)  Man man, I was very stupid...

it appears that the default gateway is different for wireless and wired connections to the router. so I adapted the sketch with the default gateway for wired connections and i'm able to ping the arduino now. it does not show up in arp-a but I guess i can handle it from here. thank you for your help!!!


peace

Go Up