TAIDONG - 2020年12月
https://www.zhangtaidong.cn/2020/12/
TAIDONG's Blog
-
ESP8266与W5100以太网模块通讯
https://www.zhangtaidong.cn/archives/134/
2020-12-16T20:20:00+08:00
1.接线方式W5100 | ESP8266+5V - NSS - SSMO - MOSIGND - GNDRST - GPIO4SCK - SCLKMI - MISO2.ESP8266 Arduino 源代码/*
A simple server that answer the ping message.
Using an ESP8266 .
*/
/* Circuit:
* Ethernet shield attached to pins :
* D6: GPIO12 - MISO
* D7: GPIO13 - MOSI
* D8: GPIO15 - CS
* D5: GPIO14 - SCLK
*/
#include <SPI.h>
#include <Ethernet.h>
#define MACADDRESS 0xDE, 0xAD, 0xBE, 0xEF, 0xDE, 0xED
IPAddress ip(192,168,6,29);
IPAddress gateway(192, 168, 6, 1);
IPAddress subnet(255, 255, 255, 0);
// telnet defaults to port 23
EthernetServer server(23);
#define RST 4 //W5100 RST
void setup()
{
pinMode(BUILTIN_LED, OUTPUT);
pinMode(RST, OUTPUT);
digitalWrite(RST,HIGH); //Reset this module
delay(200);
digitalWrite(RST,LOW);
delay(200);
digitalWrite(RST,HIGH);
delay(200);
Serial.begin(115200);
Serial.println();
byte mac[] = { MACADDRESS };
Ethernet.begin(mac, ip, gateway, subnet);
// print your local IP address:
Serial.print("My IP address: ");
Serial.println(Ethernet.localIP());
server.begin();
}
void loop()
{
}