ENC28J60 and arduino pro micro

I try to connect arduino pro micro and ENC26J60 using EtherCard.h but without success =(

I connect
ETHERNET ARDUINO Micro Pro
PIN 4 (SO) PIN 14
PIN 5 (SI) PIN 16
PIN 6 (SCK) PIN 15
PIN 7 (CS) PIN 10
PIN 9 (VCC) +3.3V
PIN 10 (GND) GND
and it doesn't work
I try to set pinMode(10, OUTPUT); but it doesn't work to
any sugesstions?
with arduino uno ENC26j60 work ok

Tell us what you have.
This one ?

That one has a 5V output.

This one ?

That one runs at 8MHz.

Are you sure the library is capable to use pin 14,15,16 for the SPI interface ?
Are you sure the library sets CS to pin 10? That board uses pin 17 for SS, which is connected to the rx led.

Caltoa:
This one ?
https://www.sparkfun.com/products/10999
That one runs at 8MHz.

this one

Caltoa:
Are you sure the library is capable to use pin 14,15,16 for the SPI interface ?
Are you sure the library sets CS to pin 10? That board uses pin 17 for SS, which is connected to the rx led.

you right
I use EtherCard library and inside EtherCard.h I see that

// PIN Connections (Using Arduino UNO):
//   VCC -   3.3V
//   GND -    GND
//   SCK - Pin 13
//   SO  - Pin 12
//   SI  - Pin 11
//   CS  - Pin  8

but I can't see where I can change this pin

To use Pin 8 as CS just connect that to your ENC28J60 CS and make sure Pin17 (SS should have this value) is configured as output, otherwise SPI will not be enabled. (Don't know but maybe EtherCard does this anyway, my UIPEthernet-library does)

  • Norbert

The EtherCard use pin 8 by default.
It also sets the 'SS' to output, you don't have to do that. The pin for 'SS' depends on the microcontroller used.

To make the Ethercard use pin 10, it is the third parameter for Ethercard:begin
EtherCard::begin (const uint16_t size, const uint8_t* macaddr, uint8_t csPin)
https://github.com/jcw/ethercard/blob/master/EtherCard.cpp

In your code it will be something like this:

ether.begin(sizeof Ethernet::buffer, mymac, 10)

I altered this in enc28j60.cpp to meet my needs.
This trick came from a early version on ethercard.h libary

void ENC28J60::initSPI () {
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
    const byte SPI_SS   = 53;
    const byte SPI_MOSI = 51;
    const byte SPI_MISO = 50;
    const byte SPI_SCK  = 52;
#elif defined(__AVR_ATmega644P__) || (__AVR_ATmega1284P__)
    const byte SPI_SS   = 4;
    const byte SPI_MOSI = 5;
    const byte SPI_MISO = 6;
    const byte SPI_SCK  = 7;
#else
    const byte SPI_SS   = 10;
    const byte SPI_MOSI = 11;
    const byte SPI_MISO = 12;
    const byte SPI_SCK  = 13;
#endif
    
    pinMode(SPI_SS, OUTPUT);
    pinMode(SPI_MOSI, OUTPUT);
    pinMode(SPI_SCK, OUTPUT);   
    pinMode(SPI_MISO, INPUT);
    
    digitalWrite(SPI_MOSI, HIGH);
    digitalWrite(SPI_MOSI, LOW);
    digitalWrite(SPI_SCK, LOW);

teding:
I altered this in enc28j60.cpp to meet my needs.
This trick came from a early version on ethercard.h libary

I try in new version and add SPI declaration

void ENC28J60::initSPI () {
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
    const byte SPI_SS   = 53;
    const byte SPI_MOSI = 51;
    const byte SPI_MISO = 50;
    const byte SPI_SCK  = 52;
#else                                     //pro micro
    const byte SPI_SS   = 10; 
    const byte SPI_MOSI = 16;
    const byte SPI_MISO = 14;
    const byte SPI_SCK  = 15;
#endif
    
    pinMode(SPI_SS, OUTPUT);
    pinMode(SPI_MOSI, OUTPUT);
    pinMode(SPI_SCK, OUTPUT);   
    pinMode(SPI_MISO, INPUT);
    
    digitalWrite(SPI_MOSI, HIGH);
    digitalWrite(SPI_MOSI, LOW);
    digitalWrite(SPI_SCK, LOW);
	
	SPCR = bit(SPE) | bit(MSTR); // 8 MHz @ 16
    bitSet(SPSR, SPI2X);
	}
static void enableChip () {
    cli();
    digitalWrite(selectPin, LOW);
}

and my sketch

// Demo using DHCP and DNS to perform a web client request.
// 2011-06-08 <jc@wippler.nl> http://opensource.org/licenses/mit-license.php

#include <EtherCard.h>

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

byte Ethernet::buffer[700];
static uint32_t timer;

char website[] PROGMEM = "www.google.com";

// called when the client request is complete
static void my_callback (byte status, word off, word len) {
  Serial.println(">>>");
  Ethernet::buffer[off+300] = 0;
  Serial.print((const char*) Ethernet::buffer + off);
  Serial.println("...");
}

void setup () {
  pinMode(17, OUTPUT);
  Serial.begin(9600);
  Serial.println("\n[webClient]");

  if (ether.begin(sizeof Ethernet::buffer, mymac) == 0) 
    Serial.println( "Failed to access Ethernet controller");
  if (!ether.dhcpSetup())
    Serial.println("DHCP failed");

  ether.printIp("IP:  ", ether.myip);
  ether.printIp("GW:  ", ether.gwip);  
  ether.printIp("DNS: ", ether.dnsip);  

  if (!ether.dnsLookup(website))
    Serial.println("DNS failed");
    
  ether.printIp("SRV: ", ether.hisip);
}

void loop () {
  ether.packetLoop(ether.packetReceive());
  
  if (millis() > timer) {
    timer = millis() + 5000;
    Serial.println();
    Serial.print("<<< REQ ");
    ether.browseUrl(PSTR("/foo/"), "bar", website, my_callback);
  }
}

but somethings is wrong
i try also with ether.begin(sizeof Ethernet::buffer, mymac,10)

ntruchsess:
(Don't know but maybe EtherCard does this anyway, my UIPEthernet-library does)

Can you show me where I can change it?

Try this in your setup

  Serial.begin(9600); 
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  Serial.println("\n[webClient]");

teding:
Try this in your setup

nothing happend

I missed a bracket, hope you saw that.
But what about level conversion is the micro 5 v or 3.3 V
btw be carefull with that micro usb connector, The weight of you breadboard will ripped the connector
when if it falls .
learned the hardway :~

Serial.begin(9600); 
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
}
  Serial.println("\n[webClient]");

I made a setup with a micro and enc28j60 module
My micro running on 5 volt, dit not work directly with ENC.
So I grab a uno for 3.3v supply
All 3 modules tied up together worked. My intend is to power the micro with a asm1117-3.3v
replace/jump the voltage regular on board the micro, and make it working at 3.3V .

This is my working setup so far:
I connect
ETHERNET ARDUINO Micro Pro
PIN 4 (SO) PIN 14
PIN 5 (SI) PIN 16
PIN 6 (SCK) PIN 15
PIN 7 (CS) PIN 10
GND ---> uno GND

pin 9 UNO 3.3
pin 10 UNO GND

This is the modified part of the setup for the getDHCPandDNS example

void setup () {
  Serial.begin(57600);
    while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }
  Serial.println("\n[getDHCPandDNS]");
  
  if (ether.begin(sizeof Ethernet::buffer, mymac,10) == 0) 
    Serial.println( "Failed to access Ethernet controller");

And my modified part off the enc28j60.ccp file from the ethercard.h libary

void ENC28J60::initSPI () {
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
    const byte SPI_SS   = 53;
    const byte SPI_MOSI = 51;
    const byte SPI_MISO = 50;
    const byte SPI_SCK  = 52;
#elif defined(__AVR_ATmega644P__) || (__AVR_ATmega1284P__)
    const byte SPI_SS   = 4;
    const byte SPI_MOSI = 5;
    const byte SPI_MISO = 6;
    const byte SPI_SCK  = 7;
#elif defined(__AVR_ATmega32U4__)	
    const byte SPI_SS   = 10;
    const byte SPI_MOSI = 16;
    const byte SPI_MISO = 14;
    const byte SPI_SCK  = 15;	
	//Serial.println("__AVR_ATmega32U4__");
#else
    const byte SPI_SS   = 10;
    const byte SPI_MOSI = 11;
    const byte SPI_MISO = 12;
    const byte SPI_SCK  = 13;
#endif


//	Serial.println(MOSI);
    pinMode(SS, OUTPUT);
    digitalWrite(SS, HIGH);
    pinMode(MOSI, OUTPUT);
    pinMode(SCK, OUTPUT);   
    pinMode(MISO, INPUT);

teding:
I made a setup with a micro and enc28j60 module
My micro running on 5 volt, dit not work directly with ENC.
So I grab a uno for 3.3v supply
All 3 modules tied up together worked. My intend is to power the micro with a asm1117-3.3v
replace/jump the voltage regular on board the micro, and make it working at 3.3V .

thanks for all, then I know that it's must be some stupied problem
maybe my ethernet card crashed because before it works with Uno, but not now:)
I waiting for another:)
I connected similar like you but for MicoPro I have supply power from microusb when I connected with PC

I connected similar like you but for MicoPro I have supply power from microusb when I connected with PC

My micro is also supply by usb, but the ENC28 get his power from a UNO, because it needs 3.3 Volt.
and only the GND form UNO, Micro and ENC28 are tied together.
So for this setup two usb are plugged in the computer.

I was able to get this working with a Nano and 3.3v off of the Nano.
I am able to ping the Nano, not having any luck running the Mudbus lib on this setup. I am wondering if that is too much for the CPU to handle. I am also using the DHT lib to get temperature and humidity. I have this working on a Mega Board and the Wiznet
Ethernet chip shield. I guess I am wondering if the UIP lib does not work with the Mudbus lib or if the 328 CPU can not respond fast enough to make modbus tcp work.