Go Down

Topic: Problems with Arduino DUE and ENC28J60. (Read 15057 times) previous topic - next topic


Hi people


First to say sorry about my English.

I need some help, I want to begin using Arduino, I was working with Microchip, but I need more speed and I/O Ports, so I just bougth an Arduino DUE. CortexM3 ARM based board.

The question is that I have a few Enc28j60 Modules and I wish to use it with my new Arduino due, So I was searching in the web And I can´t find any working example.

I just tried with a few examples but having problems.

Please help me, I don´t want to go back to Microchip.

A big hug from Colombia.



Poke through https://github.com/jcw/ethercard

The library includes examples.


Many thanks,

I already was tried these one,but when I try to compile examples I have problems with AVR files, then when I try to show to the compiler, where de files are,

It shows another kind of error.

=( =(


You need to tell us what the error is.


Basically only official sketches that runs over Arduino UNO can run directly (or with few effort) on Arduino DUE, this because the Arduino core (the libraries) was migrated for the ARM CPU used in the DUE. Every other Arduino sketch won't run without a porting.

Some non-official Arduino sketches that runs UNO may run also on DUE, it depends if they are based on custom libraries or if are based only on the Arduino core, in the latter case it should run. The EtherCard library has an its own SPI driver (doesn't use the Arduino ones) and this is creating your problems.

I've never been in detail with ARM, so I don't know if there are others to be considered. As minimum you need to review all pins assignment and all direct access to register and interrupts, it should be not so hard, because the library doesn't use a lot of those.

I can try to help if you want.

Souliss - Open-source Distributed Home Automation with Arduino and Android

Follow at @soulissteam



Thanks Dario.

You are so nice trying to explain the problem.

And exactly if I try to compile the code built in Arduino examples, it compiles well, but when I change to my Arduino DUE. it crash.

I have downloaded a lot of examples (there are many of them), but I can´t find any for the DUE.

If you want to help me, I really would appreciate it.

So, what is the next step?

Best regards.


P.D: Spanish is my language, so my apologies.


English isn't mine :)

First step is to have a look to the official SPI drivers and port your code using that drivers instead of the one included in Ethercard (or any other that you are using), then look if you have still compilation errors and move forward.

Souliss - Open-source Distributed Home Automation with Arduino and Android

Follow at @soulissteam



This will probably cause problems with SPI devices connected to a Due.
The Due needs an additional parameter to continue sending additional bytes over the SPI. Otherwise, it deactivates the SPI slave select after each call to SPI.transfer().



Sorry I was working and I have not time to test your teory.

I think this weekend I will.

Thanks a lot.




Ok I can´t wait,

I go to this page, http://tecnotinker.blogspot.com/2012/07/uso-del-modulo-ethernet-enc28j60-con.html , he says it works with Arduino UNO, I try to compile it with my Arduino DUE, and again error.

The next image shows that the picture are like´s an attachment.

Thanks a lot.



Jan 09, 2014, 06:51 pm Last Edit: Jan 09, 2014, 06:55 pm by ntruchsess Reason: 1
just got ENC28J60 running with Arduino DUE with UIPEthernet-library.
Not release or merged in branch master yet, code resides in branch 'due'. (You can download complete branch as zip-file).
To install first unzip, then add the library by going to 'sketch'->'import library'->'add library', then navigate to the directory you have unzipped the library to and select directory 'UIPEthernet', then click 'open'. Afterwards you will find new examples (AdvancedChatServer, EchoServer, TcpClient, TcpServer, UdpClient and UdpServer) for UIPEthernet in 'file'->'examples'->'UIPEthernet'

I use Arduino 1.5.5, the ENC28J60 is connected to SPI on ICSP-header, CS is connected to pin 10.

Examples from UIPEthernet run without modifications, WebServer-example from Ethernet-lib runs by replacing include 'Ethernet.h' by 'UIPEthernet.h' (not removing the SPI.h, as this is required on DUE).

Have fun!

- Norbert


Hi Norbert

First I wish to thank you for your library.

I'm trying to use it with Arduino DUE, but I have a problem:
I only can make it work if I connect the ENC28j60 CS to pin 52 , but I wish to use pin 10 for CS.

To make it work on pin 52 I also have to change line 30 in Enc28J60Network.h from #define ENC28J60_CONTROL_CS   SS
to #define ENC28J60_CONTROL_CS  52. In this line I have tried change 52 to 10, but if I do that it stops working.

What I'm doing wrong, or for now it only works on a DUE with CS connected to pin 52?

I have connect ENC28j60 on Arduino Due SPI header.



@ntruchsess could you help me getting your library work for the arduino send e-mail sketch? When I upload the sketch with your library it says connected and then prints an endless line of ÿÿÿ... I don't know what I am doing wrong.
I also use a ENC28J60.


When I upload the sketch with your library it says connected and then prints an endless line of ÿÿÿ... I don't know what I am doing wrong.

I don't know either. And without seeing the sketch you upload this ain't change.


Aug 16, 2014, 11:50 am Last Edit: Aug 16, 2014, 01:41 pm by cpu20 Reason: 1
Code: [Select]
// General code from http://www.pushingbox.com for Arduino + Ethernet Shield (official) v1.2

#include <SPI.h>
#include <UIPEthernet.h>

byte mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02 };   // Be sure this address is unique in your network
IPAddress ip(192,168,1, 20);
IPAddress gateway(192,168,1, 1);
IPAddress subnet(255, 255,255, 0);

//Your secret DevID from PushingBox.com. You can use multiple DevID  on multiple Pin if you want
char DEVID1[] = "PushBoxCode ";        //Scenario : "The mailbox is open"

//Numeric Pin where you connect your switch
uint8_t pinDevid1 = 3; // Example : the mailbox switch is connect to the Pin 3

// Debug mode
boolean DEBUG = true;
//   End    //

char serverName[] = "api.pushingbox.com";
boolean pinDevid1State = false;                // Save the last state of the Pin for DEVID1
boolean lastConnected = false;                 // State of the connection last time through the main loop

// 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() {
 pinMode(pinDevid1, INPUT);
 // 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:
   Serial.println("Ethernet ready");
   // print the Ethernet board/shield's IP address:
   Serial.print("My IP address: ");
 // give the Ethernet shield a second to initialize:

void loop()
     // Listening for the pinDevid1 state
     if (digitalRead(pinDevid1) == HIGH && pinDevid1State == false) // switch on pinDevid1 is ON
       if(DEBUG){Serial.println("pinDevid1 is HIGH");}
       pinDevid1State = true;
       //Sending request to PushingBox when the pin is HIGHT
      if (digitalRead(pinDevid1) == LOW && pinDevid1State == true) // switch on pinDevid1 is OFF
       if(DEBUG){Serial.println("pinDevid1 is LOW");}
       pinDevid1State = false;
       //Sending request to PushingBox when the pin is LOW
       //sendToPushingBox(DEVID1);    //Here you can run an other scenario by creating a DEVID2 variable
     //DEBUG part
     // this write the respons from PushingBox Server.
     // You should see a "200 OK"
     if (client.available()) {
       char c = client.read();
     // if there's no net connection, but there was one last time
     // through the loop, then stop the client:
     if (!client.connected() && lastConnected) {
     lastConnected = client.connected();

//Function for sending the request to PushingBox
void sendToPushingBox(char devid[]){

 if (client.connect(serverName, 80)) {

   if(DEBUG){Serial.println("sendind request");}
   client.print("GET /pushingbox?devid=");
   client.println(" HTTP/1.1");
   client.print("Host: ");
   client.println("User-Agent: Arduino");
 else {
   if(DEBUG){Serial.println("connection failed");}

This is my current output:

I could get to connecting by changing something in the UIPClient.cpp file. I changed in the available function the return -1 to return 0. This got me to connecting...

Edit: I found that in the file Dns.cpp the progam get stuck. Trough the function Client.connect the program get to ProcessResponse in the Dns.cpp file. Here it gets stuck in the while loop on line 325. I have no idea why but that's why it never connects.

Go Up