W55MH32L-EVB MicroPython reference script

In this page, we will show all network and peripheral MicroPython script with simple setup.

Basic Setups

  1. Use a USB type C cable to connect the DAP-LINK Port with your PC to provide power and serial communication with Thonny.

  2. Go to Thonny and select the correct COM port and interpreter (MicroPython generic).

W55MH32L-EVB connection

How to install micropython firmware for W55MH32L-EVB?

  1. Connect DAPLINK USB port with your PC

  2. Windows will pop-up a new disc called WIZLINK

  3. Drag and drop the hex file to the WIZLINK window

WIZnet5K Networking

See network.WIZNET5K and socket

Setup:

  1. Connect the board and PC with an Ethernet cable.

  2. Set the IP address of the board and PC in the same IP segment.

Static IP

Script: GitHub

Results:

It shows the IP address details set inside the script.

_images/static.png

DHCP

Script: GitHub

Setup:

Please connect the board to a router with an Ethernet cable.

Results:

It shows the IP address details provided by DHCP server or router.

_images/DHCP.png

TCP Server (one time loopback)

Script: GitHub

Setup:
  1. Open a TCP socket tester and send data to the board using TCP client.

  2. Suggestion: WIZnet Socket Tester

Results:
  1. Receive loopback message from the board.

  2. The TCP socket will be close after the connection has been disconnected.

  3. Please run the script again after disconnected the TCP connection.

_images/TCP_Server.gif

TCP Client (one time loopback)

Script: GitHub

Setup:
  1. Set your PC’s IP address to ‘192.168.1.100’.

  2. Open a TCP socket tester and send data to the board using TCP Server in port ‘5001’.

  3. Suggestion: Hercules

Results:
  1. The script will automatically connect ‘192.1681.1.100’ with port ‘5001’.

  2. Receive loopback message from the board.

  3. The TCP socket will be close after the connection has been disconnected.

  4. Please run the script again after disconnected the TCP connection.

_images/TCP_Client.gif

GPIO (General Purpose Input Output)

See machine.Pin.

Script: GitHub

Setups:

Press the onboard button (PG6) to turn on and off the onboard LED (PD14).

Results:

The onboard LED will turn on and off based on the button state.

_images/GPIO.gif

ADC (Analog to Digital Conversion)

See machine.Pin and machine.ADC.

Script: GitHub

Setups:

Connect PA4 with a potentiometer for ADC testing

Results:

It shows the different results during changing the resistance value of the potentiometer.

_images/ADC.gif

DAC (Digital to Analog Conversion)

See machine.Pin and machine.DAC.

Script: GitHub

Setups:

Connect PA4 with a multimeter for DAC testing

Results:

The multimeter should show ~1.65V result

_images/DAC.gif

Bitstream

See machine and machine.Pin.

Script: GitHub

Setups:
  1. Provide power and connect WS2812 to a GPIO pin (PD5 for example)

Results:

It will turn on 12 WS2812 LEDs into green color.

_images/bitstream.gif

RTC (Real time clock)

See machine.RTC.

Script: GitHub

Setups:

Input the datetime into the script.

Results:

It shows the updated time every 3 seconds.

_images/RTC.gif

Timer

See machine.Timer.

Script: GitHub

Setups:

The script has set TIM4 into 1HZ

Results:

It shows the print result to show the timer is ticking

_images/timer.gif

UART (Serial Bus)

See machine.UART.

Script: GitHub

Setups:
  1. Connect a USB-TTL module with W55MH32L-EVB’s PA2(TX) and PA3 (RX) for USART2 to communicate with the PC.

  2. Open a serial terminal to receive and send data using UART

Results:
  1. The USB-TTL module serial terminal shows 10 sets of “abc” data.

  2. The MicroPython serial terminal shows 1 set of “123” data.

_images/uart.gif

I2C

See machine.I2C.

Script: GitHub

ahtx0 library: GitHub

Setups:
  1. Using I2C(1) to communicate with the board’s AHT sensor.

  2. Pin PB6 (SCL) and PB7 (SDA) has connected internally with the sensor.

  3. ahtx0.py library needs to be save in W55MH32’s Flash

Results:

It shows the Temperature and Humidity result.

_images/I2C_temp.gif

SPI

See machine.SPI.

SPI bus (WIZ850io)

Script: GitHub

Setups:
  1. Connect the SPI(1) with WIZ850io module.

  2. Please based on the follow table to connect the WIZ850io with W55MH32.

WIZ850io

W55MH32

GND

GND

VCC

3V3

SCLK

PA5 (SPI1_SCK)

MOSI

PA7 (SPI1_MOSI)

MISO

PA6 (SPI1_MISO)

SCSn

PA4

RSTn

PA3

Results:

It shows the correct chip version from W5500 chip’s register.

_images/spi_wiznet.png

SPI bus (ST7789)

Script: GitHub

st7789py library: GitHub

Setups:
  1. Connect the SPI(1) with a 1.54 inch TFT ST7789 (240 x 240) display.

  2. Please include the st7789py and the VGA text file.

  3. Please based on the follow table to connect the display with W55MH32.

ST7789

W55MH32

GND

GND

VCC

3V3

SCL

PA5 (SPI1_SCK)

SDA

PA7 (SPI1_MOSI)

RST

PD6

DC

PD5

CS

PA4

BL

3V3 (100% brightness)

Results:

It will display the following result.

_images/st7789.gif

SD Card

See machine.SDCard.

Script: GitHub

Setups:

Insert a microSD card into the SD card slot on the W55MH32 board.

Results:
  1. A file named “testing.txt” is written to the “/sd/” directory on the SD card.

  2. The content “Hi from W55MH32!” is written to the file.

  3. The script reads the content back from “testing.txt”.

  4. The content is printed on the MicroPython shell.

_images/sd_card.gif

USB

Setups: Connect the USB cable to the USB device port on W55MH32.

USB VCP Mode (Virtual COM Port Only)

See machine.USB_VCP.

Script: GitHub

Setups:
  1. Turn on PuTTY (or any serial terminal).

  2. Type and send a message from PuTTY to the board.

Results:

The board will echo back whatever message was received.

_images/usb_vcp.gif

USB MSC Mode (Mass Storage Only)

Script: GitHub

Setups:
  1. Run the script to enable USB MSC mode.

  2. The board will appear as a USB flash drive on your computer.

Results:
  1. A file named “test.txt” is written to the USB flash drive.

  2. The script reads the content back from “test.txt”.

  3. The content is printed on the MicroPython shell.

_images/usb_msc.gif