Simple data transfer network with ENC28J60/Arduino (Uno)

IT WORKED!!!
Thank you very much! Now I will try to understand remoteIP and remotePort. I can write Arduino-to-Arduino but I tried to edit the code to send it once to Arduino A and once to Arduino B (third one). It doesn't work but it's getting late. Tomorrow is another day.

give each node a static IP (ignore the ports now)
one can be the master e.g. 192.168.1.177 transmitting datagrams to

  1. slave 1 192.168.1.176
  2. slave 2 192.168.1.175
  3. etc etc

or alternativly the slaves send datagrams to the master - when a datagram is received the function Udp.remoteIP() tells you the IP it is from
or a combination of both

1 Like

here is an example of the chat program with two devices (a Mini ENC28J60 with nano and a ESP32 over WiFi) sending text text to a UNO with a ENC28J60
serial monitor output

Ethernet UDP chat program
MAC address 0xDE.0xAD.0xBE.0xEF.0xFE.0xB0
Ethernet cable is not connected.
Ethernet UDP started  IP 192.168.1.176 port 10000
Received packet of size 22
From  IP 192.168.1.177 port 10000
Contents: hello from 177 test 1
Received packet of size 14
From  IP 192.168.1.177 port 10000
Contents: 192.168.1.176
Received packet of size 24
From  IP 192.168.1.164 port 10000
Contents: hello from 164 test 1
Received packet of size 24
From  IP 192.168.1.164 port 10000
Contents: hello from 164 test 2 12
Received packet of size 8
From  IP 192.168.1.164 port 10000
Contents: 34567890
Received packet of size 24
From  IP 192.168.1.177 port 10000
Contents: hello from 177 test 2 ab
Received packet of size 5
From  IP 192.168.1.177 port 10000
Contents: cdef

nano serial monitor output

Ethernet UDP chat program
MAC address 0xDE.0xAD.0xBE.0xEF.0xFE.0xB1
Ethernet cable is not connected.
Ethernet UDP started  IP 192.168.1.177 port 10000
Transmitting to  IP 192.168.1.176 port 10000
hello from 177 test 1
Transmitting to  IP 192.168.1.176 port 10000
192.168.1.176
Transmitting to  IP 192.168.1.176 port 10000
hello from 177 test 2 ab
Transmitting to  IP 192.168.1.176 port 10000
cdef

ESP32 serial monitor output

ESP32 WiFi UDP chat - send UDP datagrams 
....................
Gateway IP address: 192.168.1.254
Ethernet UDP started  IP 192.168.1.164 port 10000
Opening udp port 10000
enter remote IP address (e.g. 192.168.1.176)? remote IP OK
Remote  IP 192.168.1.176 port 10000
Transmitting to  IP 192.168.1.176 port 10000
hello from 164 test 1
Transmitting to  IP 192.168.1.176 port 10000
hello from 164 test 2 12
Transmitting to  IP 192.168.1.176 port 10000
34567890
1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.