Pages: [1]   Go Down
Author Topic: Ethernet on 1.0.4?  (Read 2524 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
God Member
*****
Karma: 26
Posts: 626
Always making something...
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I've having trouble with Ethernet on Arduino 1.0.4, but what appears to be exactly the same code works fine with 1.0.3.

Just wanted to check if anyone else is having trouble with Ethernet on 1.0.4, or if it's all on my end?
Logged

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

Mine seems to be doing ok, but I haven't tested all of my code with 1.0.4. Is there specific code you have trouble with?
Logged

0
Offline Offline
God Member
*****
Karma: 26
Posts: 626
Always making something...
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I tried both the WebServer and UdpNtpClient examples.  Both work great on 1.0.3, but both hang with 1.0.4.  I'm running on Linux 64 bit, if that matters.

Admittedly, I'm using an older hand-built Ethernet shield with Arduino Uno, and a Wiznet 812 module with Teensy.  I just ordered an official/genuine R3 Ethernet Shield, so when that arrives I can try pairing it with my Uno (which is a genuine Arduino Uno, not a clone).
Logged

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

I don't use the web server in the examples. I have my own code in the playground, and I checked it the other day. It had a couple bugs in it in relation to client.write() and the F() function used together, but that was a compiler error, not runtime.
http://playground.arduino.cc/Code/WebServerST

I just checked the UdpNtpClient directly from the IDE v1.0.4 examples, and it is running fine if I remove my SD card from the slot. Otherwise it will fail with that SD card there.

edit: This was checked on a 32 bit Ubuntu v11.10 box.
« Last Edit: March 24, 2013, 04:48:09 am by SurferTim » Logged

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

I don't use the web server in the examples. I have my own code in the playground, and I checked it the other day. It had a couple bugs in it in relation to client.write() and the F() function used together, but that was a compiler error, not runtime.
http://playground.arduino.cc/Code/WebServerST

I just checked the UdpNtpClient directly from the IDE v1.0.4 examples, and it is running fine if I remove my SD card from the slot. Otherwise it will fail with that SD card there.

edit: This was checked on a 32 bit Ubuntu v11.10 box.


Hey Tim. Thanks for the help on this.  I gave your code a try on an Ethernet shield and when I ran the Serial Monitor it gave me a "Ready".  Although, when I try to ping the IP address I get timeouts. Same with trying to access the page from a browser. 
  Just want to mention that my shield has no SD card slot on it. Only breadboard space for development. 
Logged

0
Offline Offline
God Member
*****
Karma: 26
Posts: 626
Always making something...
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I resolved my problem.  Another experimental library I had installed and even hacked a bit was conflicting with Ethernet.  When I deleted it, Ethernet started working again.
Logged

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

@Paul: Good to hear that.

@sencorp: Try this to test the SPI connection. Does it display the correct ip?
http://arduino.cc/forum/index.php/topic,156082.msg1169948.html#msg1169948

Post a link to your ethernet shield. Is the processor a w5100 or ENC28J60?
Logged

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

@Paul: Good to hear that.

@sencorp: Try this to test the SPI connection. Does it display the correct ip?
http://arduino.cc/forum/index.php/topic,156082.msg1169948.html#msg1169948

Post a link to your ethernet shield. Is the processor a w5100 or ENC28J60?


Hey Tim. Thanks for getting back.

  I gave the SPI a try.  The return on the Monitor is :

 Starting W5100
 0.0.0.0

 The processor is a ENC28J60.  (Buggar was hard to read so needed a bit of help. Photo below.  smiley-lol)

Logged

0
Offline Offline
God Member
*****
Karma: 26
Posts: 626
Always making something...
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The processor is a ENC28J60.

That's not going to work with Arduino's Ethernet library, which is designed for the (very different) W5100 chip!
Logged

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

The processor is a ENC28J60.

That's not going to work with Arduino's Ethernet library, which is designed for the (very different) W5100 chip!

So am I correct to believe that at one time it did work, but the new Librarys are now for the W5100? I did find this, http://www.geeetech.com/wiki/index.php/Arduino_ENC28J60_Ethernet_Module  Seems at one time it did work. Although I did try the Library from the link and it just would not take. 
Logged

0
Offline Offline
God Member
*****
Karma: 26
Posts: 626
Always making something...
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

So am I correct to believe that at one time it did work

Not with the Ethernet library that comes included with Arduino.

Arduino's Ethernet library has used the W5100 chip, since at least Arduino 0012 released in 2008 (I haven't used the versions earlier than 0012).
Logged

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

So am I correct to believe that at one time it did work

Not with the Ethernet library that comes included with Arduino.

Arduino's Ethernet library has used the W5100 chip, since at least Arduino 0012 released in 2008 (I haven't used the versions earlier than 0012).

Hmm. Interesting.  Thanks for that Paul. I do have another EthBoard on the way with the W5100 chip and SD card slot. I think I will just sit back and wait for that to come in later in the week. Although, I will be eyeballing this Ethernet Board to get it to work maybe somehow in the future. Cheers and Happy Easter egg day!
Logged

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

Well Now I am really confused. Not sure what went wrong with the Ethernet code I was using before. I would compile it and even upload it to the Uno and everything was fine. (All but the Shield with the incorrect chip).  The new Shield came in, and I have been trying to upload the code to give it a test, although I keep getting the following errors.

This is the Code I am using:

Code:
#include <SPI.h>
#include <Ethernet.h>

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,1, 177);

// Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 80 is default for HTTP):
EthernetServer server(80);

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


  // start the Ethernet connection and the server:
  Ethernet.begin(mac, ip);
  server.begin();
  Serial.print("server is at ");
  Serial.println(Ethernet.localIP());
}


void loop() {
  // listen for incoming clients
  EthernetClient 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");
          client.println();
          client.println("<!DOCTYPE HTML>");
          client.println("<html>");
                    // add a meta refresh tag, so the browser pulls again every 5 seconds:
          client.println("<meta http-equiv=\"refresh\" content=\"5\">");
          // 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");
  }
}



And here are the errors.


In file included from C:\Documents and Settings\Administrator\My Documents\Arduino\libraries\ENC28J60/Ethernet.h:5,
                 from WebServer.ino:19:
C:\Documents and Settings\Administrator\My Documents\Arduino\libraries\ENC28J60/Client.h:22: error: conflicting return type specified for 'virtual void Client::write(uint8_t)'
C:\Documents and Settings\Administrator\My Documents\Downloads\arduino-1.0.4-windows\arduino-1.0.4\hardware\arduino\cores\arduino/Print.h:48: error:   overriding 'virtual size_t Print::write(uint8_t)'
C:\Documents and Settings\Administrator\My Documents\Arduino\libraries\ENC28J60/Client.h:24: error: conflicting return type specified for 'virtual void Client::write(const uint8_t*, size_t)'
C:\Documents and Settings\Administrator\My Documents\Downloads\arduino-1.0.4-windows\arduino-1.0.4\hardware\arduino\cores\arduino/Print.h:53: error:   overriding 'virtual size_t Print::write(const uint8_t*, size_t)'
In file included from C:\Documents and Settings\Administrator\My Documents\Arduino\libraries\ENC28J60/Ethernet.h:6,
                 from WebServer.ino:19:
C:\Documents and Settings\Administrator\My Documents\Arduino\libraries\ENC28J60/Server.h:16: error: conflicting return type specified for 'virtual void Server::write(uint8_t)'
C:\Documents and Settings\Administrator\My Documents\Downloads\arduino-1.0.4-windows\arduino-1.0.4\hardware\arduino\cores\arduino/Print.h:48: error:   overriding 'virtual size_t Print::write(uint8_t)'
C:\Documents and Settings\Administrator\My Documents\Arduino\libraries\ENC28J60/Server.h:18: error: conflicting return type specified for 'virtual void Server::write(const uint8_t*, size_t)'
C:\Documents and Settings\Administrator\My Documents\Downloads\arduino-1.0.4-windows\arduino-1.0.4\hardware\arduino\cores\arduino/Print.h:53: error:   overriding 'virtual size_t Print::write(const uint8_t*, size_t)'
WebServer:25: error: 'IPAddress' does not name a type
WebServer:30: error: 'EthernetServer' does not name a type
WebServer.ino: In function 'void setup()':
WebServer:41: error: 'ip' was not declared in this scope
WebServer:42: error: 'server' was not declared in this scope
WebServer:44: error: 'class EthernetClass' has no member named 'localIP'
WebServer.ino: In function 'void loop()':
WebServer:50: error: 'EthernetClient' was not declared in this scope
WebServer:50: error: expected `;' before 'client'
WebServer:51: error: 'client' was not declared in this scope


 I am thinking that somehow I may have mixed up some of the old library files with the newer current ones? I am not sure, and any help would be appreciated.

Logged

0
Offline Offline
God Member
*****
Karma: 26
Posts: 626
Always making something...
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

and any help would be appreciated.

Simply download another copy of Arduino and unzip it to a new location, so it won't use any of the old one's files.

If you installed that other Ethernet library in your sketchbook folder, delete it.

Restart Arduino, since it scans the list of libraries at startup.
Logged

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

and any help would be appreciated.

Simply download another copy of Arduino and unzip it to a new location, so it won't use any of the old one's files.

If you installed that other Ethernet library in your sketchbook folder, delete it.

Restart Arduino, since it scans the list of libraries at startup.

Thanks for that Paul. I ended up digging deeper and found it was pulling two different ethernet.h files. All sorted. It is getting an IP address now. I did want to note something just to see if anyone else has this problem. I have to upload the sketch to the uno without the ether shield first. Once the sketch is uploaded and the shield is connected along with the network cable, the USB connection to the UNO on com port 4, vanishes. The only way to get the PC (Win 64) to see the Uno again is to do a full PC restart.  Not to big of a deal, a bit of a hassle and makes development of the sketch and testing slow.  Just wondering if anyone else out there may have been having this same issue?

Cheers.
Logged

Pages: [1]   Go Up
Jump to: