我目前正在尝试打开和关闭网络客户端中的 LED,因此我需要获取 IP 地址,但它没有打印,而是这是我收到的输出:
首先:0x8(TG1WDT_SYS_RESET),启动:0x12(SPI_FAST_FLASH_BOOT) 配置sip:0,SPIWP:0xee clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00 模式:DIO,时钟分频:1 负载:0x3fff0030,长度:1344 负载:0x40078000,长度:13964 负载:0x40080400,长度:3600 条目 0x400805f0 2019 年 7 月 29 日 12:21:46
我目前使用 w5500 作为以太网模块,使用 ESP Wroom 32 作为微控制器。我还认为它是在w5500和ESP32的电线连接中。引脚为 SCLK-gpio18、SCS-gpio5、MOSI-gpio23、MISO-gpio19、INT-EN、RST-gpio26。看起来是什么问题?
这是我的代码:
#include <SPI.h>
#include <Ethernet.h>
int led = 4;
// MAC address should be unique for each device on the network
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
EthernetServer server(80);
String readString;
void setup() {
// Start serial communication for debugging
Serial.begin(115200);
pinMode(led, OUTPUT);
// Attempt to configure Ethernet using DHCP
Ethernet.begin(mac);
server.begin();
Serial.print("Server is at ");
Serial.println(Ethernet.localIP());
}
void loop() {
// Your main code goes here
EthernetClient client = server.available();
if (client) {
while (client.connected()) {
if (client.available()) {
char c = client.read();
Serial.print(c);
if (readString.length() < 100) {
readString += c;
}
if (c == '\n') {
Serial.print(readString);
client.println("<HTTP/1.1 200 OK>");
client.println("<Connection-Type: text/html>");
client.println("<Connection: close>");
client.println();
client.println("<!DOCTYPE html>");
client.println("<html>");
client.println("<head>");
client.println("<title>Webserver</title>");
client.println("</head>");
client.println("<body>");
client.println("<a ref=\"/?button1on\"\"><button>LED ON</button></a>");
client.println("<a ref=\"/?button2off\"\"><button>LED OFF</button></a>");
client.println("<body style=background-color:powderblue>");
delay(1);
client.stop();
if (readString.indexOf("?buttton1on") > 0) {
digitalWrite(led, HIGH);
}
if (readString.indexOf("?buttton2off") > 0) {
digitalWrite(led, LOW);
}
readString = "";
}
}
}
}
}
我尝试这样做https://community.m5stack.com/topic/3068/lan-module-w5500-with-poe-compilation-error 因为之前以太网服务器是问题所在,但现在我不知道了。
转换为字符串:
Serial.println(Ethernet.localIP().toString());