Ethernet Module (HCARDU0028)

Wireless and wired modules including Bluetooth, Ethernet, and IR kits.
admin
Site Admin
Posts: 790
Joined: Sun Aug 05, 2012 4:02 pm

Re: Ethernet Module (HCARDU0028)

Post by admin » Thu Jun 06, 2013 8:18 pm

The WConstants.h is an old file that is no longer included in the Arduino environment. It has now been replaced with Arduino.h. This would hint that the libraries are out of date but they seem to be working fine in my environment. I'm downloading the latest Arduino environment and will I create a clean install to confirm that the libraries are still ok.

Dixo
Posts: 13
Joined: Thu Jun 06, 2013 4:20 pm

Re: Ethernet Module (HCARDU0028)

Post by Dixo » Thu Jun 06, 2013 8:22 pm

Hi

Yes blink compiles and works fine.

Let me download the latest arduino and see what happens. I downloaded 1.0.1 in summer last year so thought it was reasonably up to date. but you have a higer version than me so maybe its a versioning issue.

I'll download the latest and report back.

Thanks for your support!

Dixo
Posts: 13
Joined: Thu Jun 06, 2013 4:20 pm

Re: Ethernet Module (HCARDU0028)

Post by Dixo » Thu Jun 06, 2013 8:32 pm

Hi

I've downloaded v1.0.4 like you use and I'm still getting the same errors:
Image

admin
Site Admin
Posts: 790
Joined: Sun Aug 05, 2012 4:02 pm

Re: Ethernet Module (HCARDU0028)

Post by admin » Thu Jun 06, 2013 8:52 pm

Yes I can replicate this now with a clean environment. I suspect the libraries may be out of date. I'm going to work on this now and figure out why in my environment they work ok.

Dixo
Posts: 13
Joined: Thu Jun 06, 2013 4:20 pm

Re: Ethernet Module (HCARDU0028)

Post by Dixo » Thu Jun 06, 2013 9:13 pm

Ok thanks. IF you find why it works properly on your 1.0.4 (eg you have some special files) any chance you'd help me out with copies? - That would be fab!

admin
Site Admin
Posts: 790
Joined: Sun Aug 05, 2012 4:02 pm

Re: Ethernet Module (HCARDU0028)

Post by admin » Thu Jun 06, 2013 9:27 pm

It appears that this version of the library is no longer maintained. The current maintained version is now called etherCard. There is already a copy of this library posted in our forum with an example sketch:

http://forum.hobbycomponents.com/viewto ... =46&t=1374

Although this was written for a Microduino module, it will work fine with your module as they both use the same ENC28J60 controller. Until I get the sketch posted here to work with the new library could you try the library and sketch at the link above? You will need to make one change to your set up. The new library assumes that the CS pin is connected to D8, not D10. Apart from that it would work fine with your module.

Dixo
Posts: 13
Joined: Thu Jun 06, 2013 4:20 pm

Re: Ethernet Module (HCARDU0028)

Post by Dixo » Thu Jun 06, 2013 9:39 pm

admin wrote:The new library assumes that the CS pin is connected to D8, not D9. Apart from that it would work fine with your module.
But the CS pin isn't connected to D9 using the old files? - This is from the sample code you provided for the module:
CONNECTIONS:

ETHERNET MODULE ARDUINO BOARD
PIN 1 (CLK OUT) N/A
PIN 2 (INT) N/A
PIN 3 (WOL) N/A
PIN 4 (SO) DIO 12
PIN 5 (SI) DIO 11
PIN 6 (SCK) DIO 13
PIN 7 (CS) DIO 10
PIN 8 (RES) N/A
PIN 9 (VCC) +3.3V
PIN 10 (GND) GND

As you can see CS is connected to pin 10!

Now I'm not sure if you mean it should be connected to pin 9 or pin 8 lol

admin
Site Admin
Posts: 790
Joined: Sun Aug 05, 2012 4:02 pm

Re: Ethernet Module (HCARDU0028)

Post by admin » Thu Jun 06, 2013 9:44 pm

Sorry, I spotted the typo and corrected it before your last post. It was connected to D10 but now should be connected to D8.

Dixo
Posts: 13
Joined: Thu Jun 06, 2013 4:20 pm

Re: Ethernet Module (HCARDU0028)

Post by Dixo » Thu Jun 06, 2013 10:11 pm

Hi

Sorry I realised after posting the pins were listed in the other topic!

Right, code using EtherCard compiles and uploads without fault. The problem now is that by browsing to the ip I've set (192.168.0.70 with gateway as 192.168.0.1) I get a page timeout.

I know the ethernet module is working as the green light on the lan socket is on and whenever there is activity on the network the orange one lights up so it is seeing traffic but just not responding when it should. I've double checked the connections too :?

Dixo
Posts: 13
Joined: Thu Jun 06, 2013 4:20 pm

Re: Ethernet Module (HCARDU0028)

Post by Dixo » Thu Jun 06, 2013 10:55 pm

Right I've got a bit fed up with this so decided to do a quick debug..

Code: Select all

// Present a "Will be back soon web page", as stand-in webserver.
// 2011-01-30 <jc@wippler.nl> http://opensource.org/licenses/mit-license.php
 
#include <EtherCard.h>

#define STATIC 1  // set to 1 to disable DHCP (adjust myip/gwip values below)

#if STATIC
// ethernet interface ip address
static byte myip[] = { 192,168,0,70 };
// gateway ip address
static byte gwip[] = { 192,168,0,1 };
#endif

// ethernet mac address - must be unique on your network
static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };

byte Ethernet::buffer[500]; // tcp/ip send and receive buffer

char page[] PROGMEM =
"HTTP/1.0 503 Service Unavailable\r\n"
"Content-Type: text/html\r\n"
"Retry-After: 600\r\n"
"\r\n"
"<html>"
  "<head><title>"
    "Service Temporarily Unavailable"
  "</title></head>"
  "<body>"
    "<h3>This service is currently unavailable</h3>"
    "<p><em>"
      "The main server is currently off-line.<br />"
      "Please try again later."
    "</em></p>"
  "</body>"
"</html>"
;

void setup(){
  Serial.begin(57600);
  Serial.println("\n[backSoon]");
  Serial.println("starting");
  if (ether.begin(sizeof Ethernet::buffer, mymac) == 0) 
    Serial.println( "Failed to access Ethernet controller");
    
Serial.println("0");

if (STATIC)
{
  Serial.println("1");
  ether.staticSetup(myip, gwip);
}
else
{
  Serial.println("2");
  if (!ether.dhcpSetup())
    Serial.println("DHCP failed");
}

Serial.println("3");
  ether.printIp("IP:  ", ether.myip);
  ether.printIp("GW:  ", ether.gwip);  
  ether.printIp("DNS: ", ether.dnsip);  
}

void loop(){
  Serial.println("4");
  // wait for an incoming TCP packet, but ignore its contents
  if (ether.packetLoop(ether.packetReceive())) {
    memcpy_P(ether.tcpOffset(), page, sizeof page);
    ether.httpServerReply(sizeof page - 1);
  }
}
The only thing I'm getting from the serial is:

[backSoon]
starting
Nothing else prints to the serial so the code is hanging or crashing somewhere or the module is faulty. Either way it's not getting past this code:

Code: Select all

  if (ether.begin(sizeof Ethernet::buffer, mymac) == 0) 
    Serial.println( "Failed to access Ethernet controller");
I'm off to bed.. maybe fresh eyes will spot something tomorrow.

Post Reply