How to operate as a dual server with M5Module-LAN-13.2?
-
How to operate as a dual server with M5Module-LAN-13.2?
Detailed explanation of the situation
Two M5Module-LAN-13.2 units are connected to one M5Stack gray.
The jumper switches on the M5Module-LAN-13.2 units are set to INT, RST, CS in that order.
First unit: G35, G0, G5
Second unit: G34, G13, G15The first connection destination is 192.168.1.177:8080
The second connection destination is 192.168.1.178:8088
The two client PC programs are sending strings and trying to display the received strings on the LCD.The 192.168.1.178:8088 side receives the signal and displays it on the LCD.
The 192.168.1.177:8080 side has the green access light on the unit
but nothing displays on the LCD.If the side that doesn't display it disconnects the client program
it can't reconnect until you reset the M5Stack.Either SPI setting will work fine if only one module is connected.
Is there a problem with the class modules related to M5Module_LAN.h that prevents them from running in dual mode?
Could this be a problem with the library and board combination?I would appreciate any advice from anyone who knows how to run it as a dual server.
Arduino Library Version and setthings
The IDE I'm using is
Arduino IDE 2.3.3The board manager includes:
esp32 version 2.0.7
M5Stack version 2.1.2The board selected is
M5CoreThe library manager includes:
M5Unified version 0.1.17
M5Stack version 0.4.6
M5Module-LAN-13.2 version 1.0.0
M5GFX version 0.1.17
M5Family version 0.1.13Code that reproduces the problem
```#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 LAN2;
```EthernetServer server2(8088);
``` 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);
``` LAN.setResetPin(rst_pin); ``` LAN.reset(); ``` LAN.init(cs_pin);
``` pinMode(cs_pin2, OUTPUT); ``` pinMode(rst_pin, OUTPUT); ``` pinMode(rst_pin2, OUTPUT);
``` digitalWrite(cs_pin2, HIGH); // HIGH=disable ``` digitalWrite(rst_pin, HIGH); ``` digitalWrite(rst_pin2, HIGH);
``` 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(); ```}
``` // 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 ```}
-
I recently purchased M5Stack BASIC2.7 and tried it out.
With the M5Stack Gray, the IP addresses of both the 1st and 2nd units are displayed on the LCD,
but with the M5Stack BASIC2.7, I found that the IP addresses of both the 1st and 2nd units are 0.0.0.0.There seems to be some difference in the hardware, too.
Is it really possible to operate this unit in dual mode?
-
Hi @senbayama_no_tanuki
Yes, operate as a dual server with M5Module-LAN-13.2 is possible. And this problem might related to SPI speed.
Try adding these codes below:for (auto gpio : (const uint8_t[]){18, 19, 23}) { *(volatile uint32_t*)(GPIO_PIN_MUX_REG[gpio]) |= FUN_DRV_M; gpio_pulldown_dis((gpio_num_t)gpio); gpio_pullup_en((gpio_num_t)gpio); }
-
Hello, @kuriko
Thank you for reply.
I tried the suggested code but it didn't change anything.
The place to write the suggested code is before SPI.begin(SCK, MISO, MOSI, -1);, right?
Is it some kind of environmental issue?I have learned something.
When M5Bottom is attached, the LCD display is not displayed.
If you remove it, the IP address will become 0.0.0.0.If it works properly, then it may be environment dependent.
It would be helpful if you could tell me the type of M5Stack that works well, the combination of library versions, and sample code. -
Hi @senbayama_no_tanuki
We will release a Dual Server example as soon as possible. -
Hello, @kuriko
I hope it will be released soon.
I gave up for now.
Until then, I will use two M5Stacks and connect them via Port-A. -
@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 }