@senbayama_no_tanuki
The markdown I added to the code is incorrect, so some content is missing, so I'm reposting the whole code.
#include <M5Unified.h>
#include <M5GFX.h>
#include <SPI.h>
#include <M5Module_LAN.h>
//==============================================
// 1st M5MODULE-LAN-13.2(M5STACK-BASIC)
uint8_t int_pin = 34; // interrupt (input)
uint8_t rst_pin = 13; // Reset (output)
uint8_t cs_pin = 15; // CableSelect (output)
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x89};
IPAddress ip(192, 168, 1, 177);
IPAddress gateway(192, 168, 1, 1); // Subnet mask(It won't work without this gateway description)
IPAddress subnet(255, 255, 255, 0); // Subnet mask(It won't work without this subnet description)
//==============================================
// 2nd M5MODULE-LAN-13.2(M5STACK-BASIC)
uint8_t int_pin2 = 35; // interrupt (input)
uint8_t rst_pin2 = 0; // Reset (output)
uint8_t cs_pin2 = 5; // CableSelect (output)
byte mac2[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xA0};
IPAddress ip2(192, 168, 1, 178);
IPAddress gateway2(192, 168, 1, 1); // Subnet mask(It won't work without this gateway description)
IPAddress subnet2(255, 255, 255, 0); // Subnet mask(It won't work without this subnet description)
M5Module_LAN LAN;
M5Module_LAN LAN2;
EthernetServer server(8080);
EthernetServer server2(8088);
void setup() {
M5.begin();
M5.Display.begin();
M5.Display.setTextColor(WHITE);
M5.Lcd.setTextSize(2); // 1=7,2=14,3=21,4=28,5=35,6=42,7=49PX
SPI.begin(SCK, MISO, MOSI, -1);
// Initializing the first module
LAN.setResetPin(rst_pin);
LAN.reset();
LAN.init(cs_pin);
pinMode(cs_pin, OUTPUT);
pinMode(cs_pin2, OUTPUT);
pinMode(rst_pin, OUTPUT);
pinMode(rst_pin2, OUTPUT);
digitalWrite(cs_pin, LOW); // LOW=enable
digitalWrite(cs_pin2, HIGH); // HIGH=disable
digitalWrite(rst_pin, HIGH);
digitalWrite(rst_pin2, HIGH);
Ethernet.begin(mac, ip, gateway, subnet);
M5.Lcd.print("1st unit: ");
M5.Lcd.println(Ethernet.localIP().toString().c_str());
server.begin();
delay(2);
// Initializing the second module
LAN2.setResetPin(rst_pin2);
delay(10);
LAN2.reset();
LAN2.init(cs_pin2);
digitalWrite(cs_pin2, LOW); // LOW=enable
digitalWrite(cs_pin, HIGH); // HIGH=disable
Ethernet.begin(mac2, ip2, gateway2, subnet2);
M5.Lcd.print("2nd unit: ");
M5.Lcd.println(Ethernet.localIP().toString().c_str());
server2.begin();
}
void loop() {
// Server 2 Client Process
digitalWrite(cs_pin2, LOW); // LOW=enable
EthernetClient client2 = server2.available();
if (client2) {
while (client2.connected() && client2.available() > 0) {
char thisChar = client2.read();
M5.Lcd.print(thisChar);
}
}
digitalWrite(cs_pin2, HIGH); // HIGH=disable
// Server 1 Client Process
digitalWrite(cs_pin, LOW); LOW=enable
EthernetClient client1 = server.available();
if (client1) {
while (client1.connected() && client1.available() > 0) {
char thisChar = client1.read();
M5.Lcd.print(thisChar);
}
}
digitalWrite(cs_pin, HIGH); // HIGH=disable
}