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

查看:30
本文介绍了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天全站免登陆