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.
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,
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.
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.
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().
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).
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.
////
//
// General code from http://www.pushingbox.com for Arduino + Ethernet Shield (official) v1.2
//
////
#include <SPI.h>
#include <UIPEthernet.h>
/////////////////
// MODIFY HERE //
/////////////////
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() {
Serial.begin(9600);
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:
while(true);
}
else{
Serial.println("Ethernet ready");
// print the Ethernet board/shield's IP address:
Serial.print("My IP address: ");
Serial.println(Ethernet.localIP());
}
// give the Ethernet shield a second to initialize:
delay(1000);
}
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
sendToPushingBox(DEVID1);
}
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(DEBUG){Serial.print(c);}
}
// if there's no net connection, but there was one last time
// through the loop, then stop the client:
if (!client.connected() && lastConnected) {
if(DEBUG){Serial.println();}
if(DEBUG){Serial.println("disconnecting.");}
client.stop();
}
lastConnected = client.connected();
}
//Function for sending the request to PushingBox
void sendToPushingBox(char devid[]){
client.stop();
if(DEBUG){Serial.println("connecting...");}
if (client.connect(serverName, 80)) {
if(DEBUG){Serial.println("connected");}
if(DEBUG){Serial.println("sendind request");}
client.print("GET /pushingbox?devid=");
client.print(devid);
client.println(" HTTP/1.1");
client.print("Host: ");
client.println(serverName);
client.println("User-Agent: Arduino");
client.println();
}
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.
cpu20:
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...
I used the "old" due library from your releases. But now that I use the latest release I get a whole bunch of errors...
The most frequent one is this:
C:\Program Files (x86)\Arduino\libraries\UIPEthernet\src\UIPClient.cpp:246:30: error: 'class UIPEthernetClass' has no member named 'network'
cpu20:
Did I do something wrong installing the library?
Good question, I just tried the 1.57 download I linked before in fresh installed Arduino-1.5.7 IDE (on Linux though...) by coying the UIPEthernet-folder to the library-folder of the Arduino install. All examples compiled fine...
on my install UIPClient.cpp is located here:
/home/norbert/bin/arduino-1.5.7/libraries/UIPEthernet/src/UIPClient.cpp
from my understanding your Windows-install directories seem to be equivalent. Is it possible that you just copied the new files into the old location so you now have a mixed install?
It would surprise me that linux and windows would be such a big difference. I completely deleted the UIPEthernet folder and then installed the new one. I can't compile any example. I then rolled back to v1.5.5IDE to see if that helps but the same errors appear... And here everything was fresh. A whole new librarie folder.
I can compile everything you wrote before v1.56. But in v1.56 I get less errors then in 1.57. Those errors are conversion errors.
If you compile your libraries on linux in arduino IDE do you select the arduino due programming port as device?
I will look further into these errors. Why it says that there is no network class...
I am new to Arduino and precisely the DUE and wants to let the DUE runinter alia as a Web server with the ENC28J60-board.
I use the files from ntruchsess. (Many thanks to ntruchsess)
But I have a problem. Think it has something to do with the SPI.
In itself, the connection is established. But the construction and connection of the HTML page is not correct / good.