Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
scarletwiz committed Feb 13, 2023
0 parents commit 9adee9a
Show file tree
Hide file tree
Showing 20,740 changed files with 15,922,524 additions and 0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
70 changes: 70 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# W5300 TOE Examples

- [**Overview**](#overview)
- [**Getting Started**](#getting_started)
- [**Appendix**](#appendix)
- [**Datasheet**](#datasheet)
- [**Other Examples**](#other_examples)



<a name="overview"></a>
## Overview

The W5300 TOE examples use **W5300 TOE Shield** - ethernet I/O shield compatible with STM32 Nucleo-144 boards built on WIZnet's [**W5300**][link-w5300] ethernet chip, and STM32 Nucleo-144 boards.

- [**W5300 TOE Shield**][link-w5300_toe_shield]

<p align="center"><img src="https://github.com/Wiznet/W5300-TOE-C/blob/main/Static/Images/w5300_toe_shield_main.png"></p>

STM32 Nucleo-144 boards support the list below.

- [**NUCLEO-F429ZI**][link-nucleo-f429zi]

And W5300 TOE Examples supports two Thonny IDE.
<p align="center"><img src="https://github.com/Wiznet/W5300-TOE-MicroPython/blob/main/static/images/MicroPython_Thonny.png"></p>


<a name="getting_started"></a>
## Getting Started

Please refer to [**Getting Started**][link-getting_started] for how to configure development environment or examples usage.



<a name="appendix"></a>
## Appendix



<a name="datasheet"></a>
### Datasheet

- [**W5300**][link-datasheet_w5300]
- [**W5300 TOE Shield**][link-datasheet_w5300_toe_shield]



<a name="other_examples"></a>
### Other Examples

- C
- [**W5300-TOE-C**][link-w5300-toe-c]
- Arduino
- [**W5300-TOE-Arduino**][link-w5300-toe-arduino]




<!--
Link
-->

[link-w5300]: https://docs.wiznet.io/Product/iEthernet/W5300
[link-w5300_toe_shield]: fill_in_the_blank
[link-nucleo-f429zi]: https://www.st.com/en/evaluation-tools/nucleo-f429zi.html
[link-getting_started]: https://github.com/Wiznet/W5300-TOE-MicroPython/blob/main/static/GettingStart.md
[link-datasheet_w5300]: https://docs.wiznet.io/img/products/w5300/W5300_DS_V134E.pdf
[link-datasheet_w5300_toe_shield]: fill_in_the_blank
[link-w5300-toe-arduino]: https://github.com/Wiznet/W5300-TOE-Arduino
[link-w5300-toe-c]: https://github.com/Wiznet/W5300-TOE-C
14 changes: 14 additions & 0 deletions example/DHCP/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
## Quick micropython Code

```python
from wiznet_conf import wiznet5k_w5300

def main():
w5300=wiznet5k_w5300()
w5300.w5300_set_dhcp()
...

```

you can see that you are DHCP IP
<p align="center"><img src="https://github.com/Wiznet/W5300-TOE-MicroPython/blob/main/static/images/DHCP/dhcp_init.png"></p>
9 changes: 9 additions & 0 deletions example/DHCP/dhcp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from wiznet_conf import wiznet5k_w5300

def main():
w5300=wiznet5k_w5300()
w5300.w5300_set_dhcp()
print("----------- done ------------")

if __name__ == "__main__":
main()
23 changes: 23 additions & 0 deletions example/HTTP/client/HTTP_Client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from usocket import socket
from wiznet_conf import wiznet5k_w5300
import urequests
import network
import time

def request():
r = urequests.get('http://httpbin.org')
#r.raise_for_status
print(r.status_code)
print(r.text)
r= urequests.post('http://httpbin.org/post', json={'WIZnet Test'})
if not r:
print('spreadsheet: no response received')
print(r.json())

def main():
w5300=wiznet5k_w5300()
w5300.w5300_set_ip('192.168.11.104','255.255.255.0','192.168.11.1','8.8.8.8')
request()

if __name__ == "__main__":
main()
98 changes: 98 additions & 0 deletions example/HTTP/client/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# How to WebClient Example

![][link-http]


## Step 1: Prepare Software

> The following serial terminal program is required for **Webclient** test, download and install from below links.
### &#10004;[**Thonny**][link-thonny]


## Step 2: Prepare hardware

1. Combine WIZnet W5300-TOE Ethernet Shield and NUCLEO-F429ZI STM Board
2. Connect ethernet cable to W5300-TOE ethernet port.
3. Connect NUCLEO-F429ZI to desktop or laptop using 5 pin micro USB cable.


## Step 3: Setup WebClinet Example

To test the **Webclient example**, minor settings shall be done in code.

1. Check COMport in [‘Configure interpreter …] and then open **Thonny** Python IDE.

![][link-thonny_setup]

2. Create a new file by pressing the **New File** button. Copy the ***urequest.py*** library code into it. You can access the *urequest* library code in the following link.
> https://github.com/micropython/micropython-lib/blob/master/python-ecosys/urequests/urequests.py
If **[urequests.py]**, which is officially open on MicroPython, does not work, **use the code in lib direcroty.**
> https://github.com/Wiznet/W5300-TOE-MicroPython/blob/main/example/lib/urequests.py
3. Initialize ethernet interface and configuration.
Open the example code to set **[Network Information]**

> nic.ifconfig(('IP Address', 'Netmask', 'Gateway', 'DNS'))
```python

from wiznet_conf import wiznet5k_w5300
...

def main():
w5300=wiznet5k_w5300()
w5300.w5300_set_ip('192.168.11.104','255.255.255.0','192.168.11.1','8.8.8.8')
...

```

4. HTML request, Access **HTML**.

```python
def request():
#get
r = urequest.get("http://httpbin.org/get")
print(r.status_code)
print(r.text)

#post
r = urequest.post("http://httpbin.org/post", json={'Hello': 'WIZnet'})
print(r.json())
```



## Step 4: Upload and Run

1. Use DNS to access the address of the server. After that, it accesses the server in each URL and prints the contents. The text of each URL is as follows.

![][link-webclient_1]

2. Text content in **HTML**.

![][link-webclient_2]

3. HTTP_Client **Get**, **Post** result

![][link-webclient_3]






<!--
Link
-->

[link-thonny]: https://thonny.org/

[link-http]: https://github.com/Wiznet/W5300-TOE-MicroPython/blob/main/static/images/HTTP/HTTP.png
[link-thonny_setup]: https://github.com/Wiznet/W5300-TOE-MicroPython/blob/main/static/images/thonny-setup_example.png

[link-webclient_1]: https://github.com/Wiznet/W5300-TOE-MicroPython/blob/main/static/images/HTTP/webclient_1.png
[link-webclient_2]: https://github.com/Wiznet/W5300-TOE-MicroPython/blob/main/static/images/HTTP/webclient_2.png
[link-webclient_3]: https://github.com/Wiznet/W5300-TOE-MicroPython/blob/main/static/images/HTTP/webclient_3.png

75 changes: 75 additions & 0 deletions example/HTTP/server/HTTP_Server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
from usocket import socket
from wiznet_conf import wiznet5k_w5300
import time
import pyb

def web_page():
global led_togle
led_togle = 0

if led_togle==1:
led_state="OFF"
led_togle=0
else:
led_state="ON"
led_togle=1


html = """
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Raspberry Pi Pico Web server - WIZnet W5100S</title>
</head>
<body>
<div align="center">
<H1>Raspberry Pi Pico Web server & WIZnet Ethernet HAT</H1>
<h2>Control LED</h2>
PICO LED state: <strong>""" + led_state + """</strong>
<p><a href="/?led=on"><button class="button">ON</button></a><br>
</p>
<p><a href="/?led=off"><button class="button button2">OFF</button></a><br>
</p>
</div>
</body>
</html>
"""
return html

def main():
led= pyb.LED(1)

w5300=wiznet5k_w5300()
w5300.w5300_set_ip('192.168.11.104','255.255.255.0','192.168.11.1','8.8.8.8')

s = socket()
s.bind(('192.168.1.20', 80))
s.listen(5)

while True:
conn, addr = s.accept()
print('Connect from %s' % str(addr))
request = conn.recv(1024)
request = str(request)
#print('Content = %s' % request)
led_on = request.find('/?led=on')
led_off = request.find('/?led=off')
if led_on == 6:
print("LED ON")
led.on()
if led_off == 6:
print("LED OFF")
led.off()
response = web_page()
conn.send('HTTP/1.1 200 OK\n')
conn.send('Connection: close\n')
conn.send('Content-Type: text/html\n')
conn.send('Content-Length: %s\n\n' % len(response))
conn.send(response)
conn.close()

if __name__ == "__main__":
main()
Loading

0 comments on commit 9adee9a

Please sign in to comment.