Please fix micropython support for "LAN base module W5500 V12"
-
I've put a some effort into making the ethernet communication work for "LAN base module W5500 V12", but with no luck...
One big issue with the current libraries is that the "libs/ethernet/wiznet5k" needs "libs/ethernet/wiznet5k_dhcp". Since you put all the libraries in the "ethernet" folder, you'll get a reference error for the "import wiznet5k_dhcp" and "import wiznet5k_dns".
You can get ideas from here: https://github.com/adafruit/Adafruit_CircuitPython_Wiznet5k/tree/450c52e3b5a1f830581d8668cf57e779309d0aa7/adafruit_wiznet5k
And this guy claims to have got it right with w5500, micropython and esp32: https://github.com/Ayyoubzadeh/ESP32-Wiznet-W500-Micropython
I'm a beginner with the M5Stack, and I've reached the point where I'm trying to read and write to specific addresses, but something goes wrong (probably the SPI initiation), so I always end up with the error "AssertionError: Chip not reset properly!" (File "wiznet5k.py", line 384, in detect_w5500).
There are so many undocumented features for the M5Stack that it's challenging to gain an understanding and it's almost impossible to search for errors.
This is some of the libraries that I would like to get functional and of course documented:
- libs/ethernet/init
- libs/ethernet/wiznet5k
- libs/ethernet/wiznet5k_dhcp
- libs/ethernet/wiznet5k_dns
- libs/ethernet/wiznet5k_mqtt
- libs/ethernet/wiznet5k_ntp
- libs/ethernet/wiznet5k_socket
- libs/ethernet/wiznet5k_wsgiserver
Documentation????:
- modules/_lan_base
- module
-
If you're stuck with that "AssertionError," double-check your SPI initiation settings, and try to troubleshoot step by step.
-
Thanks, but I tried to change the SPI settings and I'm using this setting:
https://docs.m5stack.com/en/base/lan_base
from machine import Pin,SPI
from LAN.wiznet5k import WIZNET5K
#in my own folder "LAN" I got the library "wiznet5k"
spi=SPI(2, 8000000, mosi=Pin(23), miso=Pin(19), sck=Pin(18))
nic = WIZNET5K(spi, Pin(26), Pin(13)) #spi,cs,reset pin -
I'm doing some progress...
I get initiation problem sometimes (I fix this by cutting the power)????
Now I get as far as "socket.accept()" but still I don't know if my LAN module works as supposed and I can't communcate with my client programThe library "wiznet5k_requests" is located here:
https://github.com/Ayyoubzadeh/ESP32-Wiznet-W500-Micropython
from machine import Pin,SPI
from libs.ethernet.wiznet5k import WIZNET5K
import libs.ethernet.wiznet5k_socket as socket
import time
import module
import LAN.wiznet5k_requests as requests#Server
ServerIP = '192.168.0.100'
ServerSub = '255.255.255.0'
ServerRouter = '192.168.0.254'
ServerDNS = '192.168.0.254'def cnvIP(inIP):
stripIP = inIP.strip()
splitIP = stripIP.split('.')
outIP = tuple(int(x) for x in splitIP)
return(outIP)nic = WIZNET5K(is_dhcp=False)
time.sleep(1)
nic.ifconfig = (cnvIP(ServerIP),cnvIP(ServerSub),cnvIP(ServerRouter),cnvIP(ServerDNS))
requests.set_socket(socket, nic)
time.sleep(1)
MAC = ''.join(['{:02x}'.format(b) for b in nic.mac_address])
print("macaddress: " + MAC)The rest is socket communication --->
-
@h-gruber said in Please fix micropython support for "LAN base module W5500 V12":
from machine import Pin,SPI
from libs.ethernet.wiznet5k import WIZNET5K
import libs.ethernet.wiznet5k_socket as socket
import time
import module
import LAN.wiznet5k_requests as requests
#Server
ServerIP = '192.168.0.100'
ServerSub = '255.255.255.0'
ServerRouter = '192.168.0.254'
ServerDNS = '192.168.0.254'
def cnvIP(inIP):
stripIP = inIP.strip()
splitIP = stripIP.split('.')
outIP = tuple(int(x) for x in splitIP)
return(outIP)
nic = WIZNET5K(is_dhcp=False)
time.sleep(1)
nic.ifconfig = (cnvIP(ServerIP),cnvIP(ServerSub),cnvIP(ServerRouter),cnvIP(ServerDNS))
requests.set_socket(socket, nic)
time.sleep(1)
MAC = ''.join(['{:02x}'.format(b) for b in nic.mac_address])
print("macaddress: " + MAC)I've made som improvment to get rid of the "requests" module but I stuck with the socket communication. I can ping the address (192.168.0.100)
#----> code snippet from socket communication--> I get stuck on the "recv" function. I've tried to reduce to 128 byte (prev. 2048) and I know my client is OK. But I get no error message...
u = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
u.bind((ServerIP, Port))
tcp1_conn, tcp1_addr = u.accept()
data = tcp1_conn.recv(128)
from libs.ethernet.wiznet5k import WIZNET5K
import libs.ethernet.wiznet5k_socket as socket
import time#Server
ServerIP = '192.168.0.100'
ServerSub = '255.255.255.0'
ServerRouter = '192.168.0.254'
ServerDNS = '192.168.0.254'
Port = 5465def cnvIP(inIP):
stripIP = inIP.strip()
splitIP = stripIP.split('.')
outIP = tuple(int(x) for x in splitIP)
return(outIP)nic = WIZNET5K(is_dhcp=False)
time.sleep(1)
nic.ifconfig = (cnvIP(ServerIP),cnvIP(ServerSub),cnvIP(ServerRouter),cnvIP(ServerDNS))
socket._the_interface = nic
time.sleep(1)
MAC = ''.join(['{:02x}'.format(b) for b in nic.mac_address])
print("macaddress: " + MAC)The rest is socket communication --->
-
@h-gruber
Checking in to see if I received any responses. Where are the developers from M5Stack?
I've placed the gadgets on my shelf. It's a total waste of time trying to make things work with closed source when there's no documentation. The provided example with Google Blockly (is it Flow?) results in a DNS error.I was considering purchasing the "ATOM PoE Kit with W5500", but I suspect I might encounter the same issues.
The idea of stacking modules on top of each other is brilliant. I'll check back in the future to see if they've transitioned to open source or if the issues have been resolved...
-
-
@felmue
I tried and I''l get a DNS-error in this line:
"lan = module.get(module.LANBASE)"I haven't tried with "CircuitPython" this is (normally) maintained by Adafruit.
One problem with CircuitPython compared to micopython is it has no support for threads.
Later I want to add a watchdog (when I can communicate) and it will not function without multithreading... -
Hello @H-Gruber
below code works for me using M5Stack Basic or Fire (running UIFlow firmware 1.12.3):
from m5stack import * from m5ui import * from uiflow import * import module setScreenColor(0x222222) lan = module.get(module.LANBASE) label0 = M5TextBox(21, 24, "label0", lcd.FONT_Default, 0xFFFFFF, rotate=0) label1 = M5TextBox(22, 58, "label1", lcd.FONT_Default, 0xFFFFFF, rotate=0) label0.setText('Hello 1') lan.tcp_udp_config('192.168.144.1', 4711, 1, 2) label0.setText('Hello 2') label1.setText(str(lan.get_if_config())) lan.tcp_send_packet('1234') label0.setText('Hello 3') lan.socket_close() label0.setText('Hello 4')
Thanks
Felix