1.接线方式
W5100 | ESP8266
+5V -
NSS - SS
MO - MOSI
GND - GND
RST - GPIO4
SCK - SCLK
MI - MISO
2.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()
{
}