How to include driver into micropython compilation
Re: How to include driver into micropython compilation
Hi, this is the files that you have to upload on the board. In the .zip archive there is also an example script that use ETH connection to require the current data from a NTP server. Best Regards.
- Attachments
-
- wiznet5k.zip
- Pure-python driver for WIZNET5K working on ESP32
- (18.77 KiB) Downloaded 9903 times
-
- Posts: 28
- Joined: Sun Aug 08, 2021 5:48 pm
Re: How to include driver into micropython compilation
I think it will works with every board with the WIZNET5500 module connected via a machine.SPI. You can try if it works...
-
- Posts: 28
- Joined: Sun Aug 08, 2021 5:48 pm
Re: How to include driver into micropython compilation
Hi, I tried with raspberry pi pico.It gives some error.When I run wiznet5k.py, it gives this:
When I run wiznet5k_dhcp.py , wiznet5k_dns.py gives same error on different lines.
wiznet5k_socket.py doesn't gives error.
When I use your example code , I changed cs pin for my pico (I used wiznett w5500 with circuitpython same pin). It gives this:
When I added line 9 to bottom it gives this error:
Code: Select all
Traceback (most recent call last):
File "<stdin>", line 32, in <module>
File "wiznet5k_dhcp.py", line 19, in <module>
File "wiznet5k_socket.py", line 19, in <module>
File "wiznet5k.py", line 33, in <module>
File "wiznet5k_dns.py", line 20, in <module>
ImportError: can't import name htons
wiznet5k_socket.py doesn't gives error.
When I use your example code , I changed cs pin for my pico (I used wiznett w5500 with circuitpython same pin). It gives this:
Code: Select all
Traceback (most recent call last):
File "<stdin>", line 9, in <module>
File "wiznet5k.py", line 159, in __init__
File "wiznet5k.py", line 339, in _w5100_init
File "wiznet5k.py", line 354, in detect_w5500
AssertionError: Expected 0x08.
Code: Select all
Traceback (most recent call last):
File "<stdin>", line 10, in <module>
File "wiznet5k_socket.py", line 64, in getaddrinfo
File "wiznet5k_socket.py", line 72, in gethostbyname
AttributeError: 'NoneType' object has no attribute 'get_host_by_name'
Re: How to include driver into micropython compilation
For the `AssertionError: Expected 0x08.`, it seems is that the problem is in writing register on the chip. Are you sure your connected pin configuration is right. I had the same error when I had choose too high frequency for SPI. `htonl` and `htons` are function defined in `wiznet5k_socket`, so, if the import works, you have to be able to manually call these function.
-
- Posts: 28
- Joined: Sun Aug 08, 2021 5:48 pm
Re: How to include driver into micropython compilation
I didn't set frequency, I tried with your example code (esp32_eth_wiznet5500_ntp).vinz-uts wrote: ↑Tue Nov 16, 2021 9:24 pmFor the `AssertionError: Expected 0x08.`, it seems is that the problem is in writing register on the chip. Are you sure your connected pin configuration is right. I had the same error when I had choose too high frequency for SPI. `htonl` and `htons` are function defined in `wiznet5k_socket`, so, if the import works, you have to be able to manually call these function.
I am using circuitpython like this,
Code: Select all
spi_bus = busio.SPI(board.GP10, MOSI=board.GP11, MISO=board.GP12)
cs = digitalio.DigitalInOut(board.GP13)
Code: Select all
spi = SPI(1)
cs = Pin(13,Pin.OUT)
nic = WIZNET5K(spi,cs)
wiznet5k_socket.py
Code: Select all
import gc
import time
import wiznet5k as wiznet5k
from micropython import const
wiznet5k.socket.py :
Code: Select all
import gc
import time
import wiznet5k as wiznet5k
import wiznet5k_dhcp as dhcp
import wiznet5k_dns as dns
from micropython import const
_the_interface = None # pylint: disable=invalid-name
Re: How to include driver into micropython compilation
Code: Select all
import network
from usocket import socket
from machine import Pin,SPI
import rp2
def main():
spi=SPI(0,2_000_000, mosi=Pin(19),miso=Pin(16),sck=Pin(18))
nic = network.WIZNET5K(spi,Pin(17),Pin(20))
nic.ifconfig(('192.168.100.20','255.255.255.0','192.168.100.1','8.8.8.8'))
while True:
if nic.isconnected() == True:
#print(nic.regs())
s=socket()
s.connect(('192.168.100.10',5000))
while True:
data = s.recv(1500)
print(data.decode('utf-8'))
if data != 'NULL' :
s.send(data)
main()
github : https://github.com/irinakim12/micropyt ... e/wiznet5k
Loopback example : https://www.hackster.io/irinakim1225/ho ... hon-a6c351
Re: How to include driver into micropython compilation
I've upload the directory to my esp32 - but it won't run because of this error:
ImportError: no module named 'wiznet5k.WIZNET5K'
I'm in the right directory.
How do I get it to work?
TIA
-
- Posts: 2
- Joined: Wed Apr 06, 2022 4:58 am
Re: How to include driver into micropython compilation
hello sir. can you share it ?vinz-uts wrote: ↑Fri Nov 12, 2021 9:25 pmHi, I've done some test with a ESP32-WROVER-IE and an external SPI Wiznet5500 ethernet chip. After a lot of research on this forum and github, I've decided to try to modify a pure-python adafruit driver (developed for circuitpython) for this chip. Now it seems works, but maybe it need more test. I can share this driver if someone will try to use it, or, if someone help me to understand the right steps, I will upload it in the right folder of micropython repo.
Re: How to include driver into micropython compilation
Hi, this is the folder which contains the drivers files and the script test. You have to copy only the content of the folder (files, not the folder) in your micro and run the `esp32_eth_wiznet5500_ntp.py` file to try it. I've just tested it now and seems all works, I've also changed the NTP server with the google one. Let's me know if it works.
Best regards,
Vinz.
Best regards,
Vinz.
- Attachments
-
- wiznet5k.zip
- (18.57 KiB) Downloaded 9893 times