Arduino DHCP配置失败 [英] Arduino DHCP failed to configure

查看:184
本文介绍了Arduino DHCP配置失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用示例以太网草图作为与Arduino软件捆绑在一起的Web客户端,而不更改固件地址以外的任何东西,固件地址改为在以太网屏蔽背面的印刷地址.

I am using the example ethernet sketch for a web client that comes bundled with the Arduino software without changing a thing except for the firmware address, which I changed to the one printed on the back of the ethernet shield.

每当我将Arduino连接到我的网络并查看串行监视器时,我得到的唯一消息是它无法使用DHCP配置以太网".

Whenever I connect the Arduino to my network and view the serial monitor, the only message I get is that it "Failed to configure Ethernet using DHCP".

我为Arduino Mega 2560设置了以太网屏蔽,正确地将端口50连接到MISO,将51连接到MOSI,将52连接到SCK,将10连接到SS(也就是在以太网板上印制的ETHCS).

I have setup my Arduino Mega 2560 with an ethernet shield, correctly connecting ports 50 to MISO, 51 to MOSI, 52 to SCK, and 10 to SS (a.k.a. ETHCS as it is printed on the ethernet board).

你们知道为什么会发生此DHCP错误吗?

Do you guys have any idea why this DHCP error would be happening?

这是我的代码:

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = {  0x90, 0xA2, 0xDA, 0x00, 0x73, 0xE4 }; //ethernet mac
IPAddress server(192, 168, 1, 9); //valid server IP in my network

EthernetClient client;

void setup() {
  Serial.begin(9600);

  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");

    for(;;)
      ;
  }

  delay(1000);
  Serial.println("connecting...");

  if (client.connect(server, 80)) {
    Serial.println("connected");

    client.println("GET /search?q=arduino HTTP/1.0");
    client.println();
  } 
  else {
    Serial.println("connection failed");
  }
}

void loop()
{
  if (client.available()) {
    char c = client.read();
    Serial.print(c);
  }


  if (!client.connected()) {
    Serial.println();
    Serial.println("disconnecting.");
    client.stop();

    for(;;)
      ;
  }
}

推荐答案

为我解决此问题的解决方案是从插槽中卸下Micro SD卡,我看到您的问题与故障有关,但是其他人应该遇到此问题关闭Arduino后,取出Micro SD卡.

The solution that fixed this for me was to remove the Micro SD card from the slot, I saw your issue was related to a fault but others having this issue should remove the Micro SD card after turning off the Arduino.

这篇关于Arduino DHCP配置失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆