przemobe / micropy-ENC28J60

ENC28J60 Ethernet chip driver for MicroPython (RP2)
GNU General Public License v3.0
20 stars 6 forks source link

How to set IPv4 address to ENC28J60 and access/use it as a TCP/UDP socket? #6

Open Venkatesh416 opened 7 months ago

Venkatesh416 commented 7 months ago

I'm using ENC28J60 module with Raspberry Pi Pico microcontroller. How can we set the IP address to the ethernet module using micropython?

After assigning, how can we access the network socket using micropython? can we do socket programming using micropython?

przemobe commented 7 months ago

Hello,

As far as I know (correct me if I'm wrong), no official Micropython port with build-in network socket library have possibility for user defined NIC driver. (No API for user defined NIC driver ;-( )

Because of that the solution can be using additional library that implements ETH/IP/... stack.

I'm personally using ENC28J60 driver together with network stack shown in examples directory: Ntw.py . Here you can set IP address manually via ntw.setIPv4() function or automatically with Dhcp4Client.py.

If your application allows using custom network driver or custom socket (non-blocking) then you may try to integrate it with this driver and ETH/IP/UDP stack implemented in Ntw.py.

The microCoAPy library is a good example of integration using custom UdpSocket. You can find working sample in examples/MicrocoapyClient.py.