如何将 Arduino Micro 连接到以太网模块 ENC28J66 和 运行 EtherCard BackSoon 示例?

How to connect Arduino Micro to Ethernet module ENC28J66 and run EtherCard BackSoon example?

我有这样的 arduino micro(原始):https://www.arduino.cc/en/Main/ArduinoBoardMicro 和带有 ENC28J66 芯片组的以太网 bord 的克隆。

以太网板上的引脚配置:

  1. 出局
  2. /积分
  3. /唤醒
  4. 所以
  5. SI
  6. SCK
  7. /CS
  8. /重置
  9. VCC(5V)(焊接一处后用3.3V也是可以的)
  10. 接地

我已经尝试 运行 示例 BackSoon for EtherCard library with few combination of conection but this gave me 'Failed to access Ethernet controller'

然后我这样设置: 微| ENC28J60

此配置不会生成访问错误,但 DHCP 失败。 DHCP 服务器配置肯定是好的。 即使我设置了静态 IP 地址,也没有像示例中那样来自 http 的此 IP 的响应。

我尝试 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);
  }
}

串行响应:

[backSoon]
DHCP failed
IP:  0.0.0.0
GW:  0.0.0.0
DNS: 0.0.0.0

有人可以帮我将螺旋桨连接到另一个和 运行 任何样本(如 BackSoon)吗?

Micro和ENC28J60可以一起使用吗? 是否可以为他们使用 EtherCard 库?

你的问题已经过去很长时间了,但我希望这能对某人有所帮助。

  • 微型 - 以太网
  • SCK - SCK
  • 味噌 - 所以
  • MOSI - SI
  • PIN 8 - CS(8 是以太网卡的默认值,在您的代码中是 10)
  • 5V - VCC
  • 接地 - 接地