Pages: [1]   Go Down
Author Topic: FEZ Connect Shield with Arduino Uno  (Read 943 times)
0 Members and 1 Guest are viewing this topic.
Germany
Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi.
I just won a FEZ Connect Shield (v 1.5). So I thougth I'd try to use it with my Arduino Uno which shouldn't be problemen I tought because the shield is build with the WIZnet w5100 microcontroler just like the original Arduino Ethernet shield. Also the pins are assigned the same way (see http://www.ghielectronics.com/downloads/FEZ/Shield/Broch_FEZ_Connect.pdf).
So I connected the shield and staret the DHCP example for Arduino. It failed.
Then I modified the sketch and assigned a hard IP address and used localIP() to query the IP byte wise. What happend was that about 3/4 of the requests returned 0. The output on my serial monitor looked like this:
Code:
192.0.127.0
0.0.127.0
192.0.0.42
192.0.0.0
I also tried to slow down the SPI clock (even though the datasheet of the w5100 sais it can handle up to 14.29MHz). It made it even worse (nearly every byte returned 0)

Anyone an idea what could be wrong?
Thanks in advance for every answer.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Then I modified the sketch and assigned a hard IP address and used localIP() to query the IP byte wise.
You want to show that modified sketch? Or would you rather we guess?

OK. I'll guess. I guess that there is a problem somewhere around the 14th character on the 37th line.
Logged

Germany
Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey. Thanks for your reply! But no reason to be so impolite...
See I went away over the weekend and didn't have the code with me. I also tought it'd rather be a hardware problem. But anyway here's the code:
Code:
#include <SPI.h>
#include <Ethernet.h>

// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte mac[] = {
  0xBC, 0xAE, 0xC5, 0x39, 0x79, 0x45 };
byte ip[] = {
  192, 168, 178, 42 };

// 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):
EthernetClient client;

void setup() {
 // Open serial communications and wait for port to open:
 Serial.begin(9600);
  // this check is only needed on the Leonardo:
   while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }

  // this is the pin that resets the FEZ Connect shield
  // pin 7 is !(rst)
  pinMode(7,OUTPUT);
  digitalWrite(7,LOW);
  delay(10);
  digitalWrite(7,HIGH);

  // start the Ethernet connection:
  Ethernet.begin(mac,ip);
  delay(2000);
  Serial.println("My IP address: ");
  while(true){
    for (byte thisByte = 0; thisByte < 4; thisByte++) {
      Serial.print(Ethernet.localIP()[thisByte], DEC);
      Serial.print(".");
  }
  delay(2000);
  Serial.println();}
}

void loop() { }

I just ran that code again. What now would happen is the following output:
Code:
My IP address:
0.255.255.255.
255.255.255.255.
255.255.255.255.
255.255.255.255.
255.255.255.255.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
  while(true){
    for (byte thisByte = 0; thisByte < 4; thisByte++) {
      Serial.print(Ethernet.localIP()[thisByte], DEC);
      Serial.print(".");
  }
  delay(2000);
  Serial.println();}
Why are you printing the address over and over?
Why is the indenting so awful?
In my not so humble opinion, every { belongs on a new line. Not a single recognized style supports the } on the same line with any other code. Every style that does have the { on the same line as the statement it goes with has the { separated from the statement byatleastonespace.
Logged

Germany
Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Why are you printing the address over and over?
To see if it changes as in the first example I posted.

Why is the indenting so awful?
Because it was a quick and dirty hacked sketch just to see if the shield works.
But jup I'm studying computer science and I know about the Java style guide and it would've probably been better to query the IP address in the loop procedure. But anyway I made that sketch run. The problem was that my USB port wouldn't provide enough power to run the shield correctly. So I connectet a DC jack.

But the DHCP example still fails. What could be the problem??
Logged

Germany
Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@PaulS: So... Did you actually want to help me or just hate a bit around?
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'd like to help you, but I've never used DHCP, so I can't.
Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 139
Posts: 5855
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I use dhcp. Try this simple test sketch.
Code:
#include <SPI.h>
#include <Ethernet.h>

byte mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02 };

void setup() {
  Serial.begin(9600);

  Serial.print("Starting w5100...");
  if(!Ethernet.begin(mac)) Serial.println("failed");
  else Serial.println("ok");

  Serial.println(Ethernet.localIP());
}

void loop() {
}

Insure on the power source select jumper you are using the 5v, not 3.3v. There is not enough power on the 3.3v pin to run the w5100. 50ma max on the 3.3v pin, and the w5100 could use 140ma.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i was having a similar issue found solution at the below link use the library they have used in the link, i think like me you are using the wrong library. If this works for you can you give this solution to others and put this solution on you post.

http://www.instructables.com/id/Add-Ethernet-to-any-Arduino-project-for-less-than-/
Logged

Pages: [1]   Go Up
Jump to: