
ESP8266 Use W5100 And W5500 Ethernet Module
summary
Experimental projects , I hope to use an Ethernet module to realize Ethernet communication , Not used WiFi The Internet , But with wired Ethernet .
Use a ESP8266 Module as the main processor , use Arduino IDE Make a development environment . First, I chose a W5500 The module is connected to Ethernet . Result passed SPI Connect W5500, You don’t succeed . The program can’t run . No other libraries have been added , I feel now Arduino Not very friendly , Downloading the program is very slow . I bought another one on a treasure W5100 modular .( Because look Ethernet.h and Ethernet.cpp Discovery and Library W5100 Module compatible . This experiment , Everything is all right , Share the usage here .
Program
/* 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()
{
}
attachment
Module and ESP8266 Don’t make mistakes on the connection and succeed at one time
W5100 | ESP8266 |
---|---|
+5V | |
NSS | SS |
MO | MOSI |
GND | GND |
RST | GPIO4 |
SCK | SCLK |
MI | MISO |
result
Successful experiment , Ethernet and can be used ESP8266 Communication .
Experience
Use W5500 I don’t know why it always crashes . No reaction . The watchdog doesn’t work . use ESP32 and W5500 Experiments were carried out ,ESP32 Unable to host , The reason is that the library used is C: install Arduino IDElibrariesEthernet There is a problem with the header file in the directory , Out of commission EthernetServer myServer(23); Defining variables . Compilation cannot pass . Another experience is when you don’t know SPI The wiring of can be obtained by printing SPI The port of .
I tried again these days ESP32 Use W5500 The situation of ,ESP32 It can be done client, and server To communicate , But I don’t know why I still can’t do server.
Postscript
Recently, some netizens discussed ESP8266 and W5500 About the board communication , It’s an experiment . It can be used ESP8266 Connect W5500 Realize Ethernet wired communication , Just add… In the initialization program Ethernet.init(5); This command selects GPIO5 As a chip selection signal . Also pay attention to :
- You cannot use the default GPIO15 As a selection CS The signal , If you use GPIO15 There will be a crash . Maybe with our board GPIO15 A connected 10KΩ Related to the grounding resistance of .
- Chip selection signal selects other signals to communicate and realize TCP Transmission of, etc .
- Add… To initialization Ethernet.Inti(5); Can , This CS You can choose any
ESP32+W5500
About ESP32+W5500 Of server Can’t run, solved , have access to ESP32 and W5500 Realize wired Ethernet communication . The key is that there is a problem with the library function , You need to use… At compile time Server.h library . The address of my library is at the following location on the machine :
Change the header file into the following form to compile and use W5500 Communication .
class Server: public Print
{
public:
//virtual void begin(uint16_t port=0) =0; modified by CAI at 2021-12-13
virtual void begin() = 0;
};
版权声明
本文为[caixf_ 001]所创,转载请带上原文链接,感谢
https://chowdera.com/2022/03/202203140548448906.html
COMMENTS