我正在尝试从示例中实现官方的Arduino Web客户端代码 住在这里:https://www.arduino.cc/en/Tutorial/WebClient, 但不幸的是,它并不适用于我。
上传此草图后我应该怎么做? 这是我改为的唯一一行:
IPAddress ip(192, 168, 1, 178);
我做的是去网址: 192.168.1.178(在我的本地网络中,其他草图在此ip中工作正常)如果我很好地理解了此代码的功能,我们会从google的服务器请求一个特定的页面,所以服务器响应并带给我们这个页面,通过我们在代码中生成的get请求。不幸的是,它不会加载任何页面。
如果我对我所说的任何内容都不对,请告诉我。
答案 0 :(得分:0)
您的以太网控制器是否完美连接?
以太网屏蔽允许您通过SPI总线将WizNet以太网控制器连接到Arduino或Genuino板。它使用引脚10,11,12和13进行与WizNet的SPI连接。以后的以太网屏蔽型号也有板载SD卡。数字引脚4用于控制SD卡上的从选择引脚。
如需帮助,这里是盾牌的示意图:Schematics
观看您的序列号。这是吗?
无法使用DHCP配置以太网
或者说这个吗?
...连接
您的路由器是使用192.168.1而不是192.168.0还是192.168.2?
是否有其他设备具有相同的IP地址?
如果无效,请尝试替换这段代码
// start the Ethernet connection:
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
// try to congifure using IP address instead of DHCP:
Ethernet.begin(mac, ip);
}
有了这个
// start the Ethernet connection:
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
// try to congifure using IP address instead of DHCP:
if(Ethernet.begin(mac, ip) == 0) {
Serial.println("Failed to configure Ethernet using IP address.
Circuit hanged.");
while(1){}
}
}
如果此代码为sais:
无法使用IP地址配置以太网。电路被绞死。
当然,如果您使用的是WiFi防护罩,此示例将无效。试试wifi盾的示例,它包含在它的库中。