如何将Arduino Micro连接到以太网模块ENC28J66并运行EtherCard BackSoon示例?
问题描述:
我有这样的arduino微(oryginal):https://www.arduino.cc/en/Main/ArduinoBoardMicro和以ENC28J66芯片组的以太网bord的克隆。以太网板如何将Arduino Micro连接到以太网模块ENC28J66并运行EtherCard BackSoon示例?
引脚配置:
- CKOUT
- /INT
- /WOL
- SO
- SI
- SCK
- /CS
- /RESET
- VCC(5V)(还可以焊接一个地方后使用3.3V)
- GND
我尝试使用连接如的几个组合运行例如BackSoon用于以太网卡库,但这个给了我“无法访问以太网控制器'
然后我这样设置: Micro | ENC28J60
- SCK - SCK
- MISO - SO
- MOSI - SI
- SS - CS
- 5V - VCC
- GND - GND
- 10 PIN - INT
该配置不会生成访问错误,但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
有人可以帮我propellery连接彼此,并运行任何样品(如BackSoon)?
是否可能将Micro和ENC28J60一起使用? 是否可以为他们使用EtherCard库?
答
长时间是从你的问题传递过来的,但我希望这可以帮助某人。
- 微 - 以太网
- SCK - SCK
- MISO - SO
- MOSI - SI
- PIN 8 - CS(图8为以太网卡,默认值10,在你的代码)
- 5V - VCC
- GND - GND