我一直在努力在安装了以太网屏蔽的Arduino uno上运行以太网> DHCPAddressPrinter示例,但没有效果,每次运行它都会返回错误。
未能使用DHCP配置以太网
我尝试过各种各样的东西,比如禁用防火墙,重置板/屏蔽,首先它给了我一个ip,但那是我唯一一次关掉路由器,从那时起我就不能给以太网屏蔽分配MAC和IP。
有人知道如何解决这个问题吗?
这是我想要运行的草图
/*
DHCP-based IP printer
This sketch uses the DHCP extensions to the Ethernet library
to get an IP address via DHCP and print the address obtained.
using an Arduino Wiznet Ethernet shield.
Circuit:
* Ethernet shield attached to pins 10, 11, 12, 13
created 12 April 2011
modified 9 Apr 2012
by Tom Igoe
*/
#include <SPI.h>
#include <Ethernet.h>
// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte mac[] = {
0xDE, 0xAD, 0xBD, 0xEF, 0xFE, 0xED
};
// 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() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
// this check is only needed on the Leonardo:
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
// 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:
for(;;)
;
}
// print your local IP address:
Serial.print("My IP address: ");
for (byte thisByte = 0; thisByte < 4; thisByte++) {
// print the value of each byte of the IP address:
Serial.print(Ethernet.localIP()[thisByte], DEC);
Serial.print(".");
}
Serial.println();
}
void loop() {
}发布于 2013-05-23 01:37:33
你所连接的网络是否有一个dhcp服务器,通常路由器被设置为一个。如果没有,则必须将静态ip分配给您的arduino。
这可以像使用以太网libray那样完成。
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,0,177); // make sure this is in the subnet of your network
EthernetClient client;
Ethernet.begin(mac, ip);看起来你只需要打印ip而不是每个字节。来自Ethernet.localIp()文档
// print your local IP address:
Serial.println(Ethernet.localIP());您还可以试试webServer示例吗?然后看看是否可以导航到在浏览器中打印出来的ip (希望不是0.0.0.0)
发布于 2014-04-16 17:25:08
如果您的以太网卡有SD插槽,请确保其中没有SD卡,或者遵循本博客上的建议:http://startingelectronics.com/tutorials/arduino/ethernet-shield-web-server-tutorial/basic-web-server/。
pinMode(4, OUTPUT);
digitalWrite(4, HIGH);发布于 2015-07-06 19:20:53
对于SeedStudioV2.4,一定要使用这里找到的库:W5200
我也看到了同样的问题。我的Seeed工作室以太网屏蔽版本2.4报告了不正确的IP地址。我看到了0.0.0.0和其他奇数。我认为有趣的是,使用标准/默认的Arduino以太网屏蔽库对另一家公司的屏蔽提供任何结果,更不用说IP地址的正确格式的数字了。我通过下载我的模型的正确库和修改以太网屏蔽(参见上面的链接)来修复这个问题。
希望这能帮上忙..。麦克
https://stackoverflow.com/questions/16669888
复制相似问题