I have arduino micro (oryginal) like this: https://www.arduino.cc/en/Main/ArduinoBoardMicro and clone of ethernet bord with ENC28J66 chipset.
Pin configuration on ethernet board:
- CKOUT
- /INT
- /WOL
- SO
- SI
- SCK
- /CS
- /RESET
- VCC (5V) (it is also possible to use 3.3V after soldering one place)
- GND
I have try to run example BackSoon for EtherCard library with few combination of conection but this gave me 'Failed to access Ethernet controller'
Then i set it like this: Micro | ENC28J60
- SCK - SCK
- MISO - SO
- MOSI - SI
- SS - CS
- 5V - VCC
- GND - GND
- 10 PIN - INT
This config don't generate access error but DHCP failed. DHCP server configuration is good for sure. Even if i set static IP address there is no respons on this IP from http like in example.
Full code of my try for dhcp:
#include <EtherCard.h>
#define STATIC 0 // set to 1 to disable DHCP (adjust myip/gwip values below)
#if STATIC
// ethernet interface ip address
static byte myip[] = { 172,16,10,222 };
// gateway ip address
static byte gwip[] = { 172,16,10,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
const 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);
while (!Serial) ;
Serial.println("\n[backSoon]");
if (ether.begin(sizeof Ethernet::buffer, mymac,10) == 0)
Serial.println( "Failed to access Ethernet controller");
#if STATIC
ether.staticSetup(myip, gwip);
#else
if (!ether.dhcpSetup())
Serial.println("DHCP failed");
#endif
ether.printIp("IP: ", ether.myip);
ether.printIp("GW: ", ether.gwip);
ether.printIp("DNS: ", ether.dnsip);
}
void loop(){
// wait for an incoming TCP packet, but ignore its contents
if (ether.packetLoop(ether.packetReceive())) {
Serial.println("got one!");
memcpy_P(ether.tcpOffset(), page, sizeof page);
ether.httpServerReply(sizeof page - 1);
}
}
Serial response:
[backSoon]
DHCP failed
IP: 0.0.0.0
GW: 0.0.0.0
DNS: 0.0.0.0
Can someone help me to propellery connect one to another and run any sample (like BackSoon)?
Is it possibile to use Micro and ENC28J60 together? Is it possibile to use EtherCard library for them?