RT-Thread of RT-Thread + WIZnet + W5500 + MQTT + ali-iotkit-v3.0.1 Completed Ethernet Socket communication MQTT protocol topic subscription publication

RT-Thread of RT-Thread + WIZnet + W5500 + MQTT + ali-iotkit-v3.0.1 Completed Ethernet Socket communication MQTT protocol topic subscription publication
ORIGINAL POST
By None
components
Hardware Components
STM32L475
X 1
W5500
X 1
Software Apps and online services
RT-Thread
details

29cc6e4f79e8f0527be8ae2a09fb1791.png

table of Contents

1 Introduction

1.1 WIZnet

1.2 W5500

2. RT-Thread Studio configuration and related code

2.1 Add WIZnet software package

2.2 Configure WIZnet software package

2.3 Configure spi20

3. Verify the effect

4. With ali-iotkit-v3.0.1 Alibaba Cloud IOT software package MQTT topic subscription publishing

4.1 Add ali-iotkit-v3.0.1 package

4.2 Configure the triplet parameters of Ali-iotkit to connect to the Alibaba Cloud IOT platform, open the Samples sample code, and other parameters can be defaulted

4.3 MQTT example code mqtt-example.c

4.4 Sample code of object model linkkit_example_solo.c

4.5 Experimental verification OK

 


Development environment: useRT-Thread Real-time operating system.

Development software: useRT-Thread Studio (Currently the latest version 1.1.3).

Development hardware: use the STM32L475 Pandora development board of Punctual Atom.

 

1 Introduction

1.1 WIZnet

WIZnet software package is RT-Thread based on WIZnet official websiteioLibrary_DriverThe transplantation of the code base is implemented. Currently, only W5500 devices are supported. On the basis of the original code library function, this software package docks with the RT-Thread SAL socket abstraction layer, realizes the support for standard BSD Socket APIs, is perfectly compatible with a variety of software packages and the realization of network functions, and improves the compatibility of WIZnet devices.

1.2 W5500

W5500 is one of the high-performance Ethernet interface chip series launched by WIZnet, which integrates full hardware TCP/IP protocol stack + MAC + PHY. The full hardware protocol stack technology uses hardware logic gate circuits to implement complex TCP/IP protocol clusters, and its application has significant advantages such as simple and fast, high reliability, and good security; the internal integration of MAC and PHY technology allows the single-chip microcomputer to connect to the Ethernet solution The hardware design is simpler and more efficient.

The W5500 chip is an integrated hardwareTCP/IP protocolThe embedded Ethernet controller of the stack is also an industrial Ethernet control chip. It is South Korea’s WIZnet (Wei Zhi Na Te) released a full hardware TCP/IP protocol stack Ethernet interface chip.

W5500 supports high-speed standard 4-wireSPIThe interface communicates with the host. The SPI rate can theoretically reach 80MHz. It also integrates Ethernet data link layer (MAC) and 10BaseT/100BaseTX Ethernet physical layer (PHY), supports auto-negotiation (10/100-Based full duplex/half duplex), power-down mode and wake-up on LAN Features. Different from the traditional software protocol stack, the 8 independent hardware sockets embedded in the W5500 can carry out 8-channel independent communication. The communication efficiency of the 8-channel Socket does not affect each other. Each socket can be flexibly defined through the 32K byte receiving/sending buffer on the W5500 chip. the size of.

(Note: Reference materialsWIZnet W5500-Reference Design Collection

Features

    • Full hardware TCP/IP protocol stack: TCP, UDP, ICMP, IPv4, ARP, IGMP, PPPoE
    • 8 independent hardware sockets, each communication does not affect each other
    • 32K bytes transmit and receive buffer
    • Integrated 802.3 Ethernet MAC
    • Integrated 10Base-T / 100Base-T Ethernet PHY
    • Host interface: SPI high-speed serial peripheral interface (up to 80Mhz)
    • Support embedded operating system: Linux & RTOS
    • Support power-down mode & wake on UDP network
    • Working voltage 3.3V, I/O 5V withstand voltage
    • Support auto negotiation (full/half duplex, 10M/100M)
    • Working temperature is about 40℃
    • 48Pin LQFP lead-free package (7x7mm, 0.5mm pin pitch)

 

 

 

2. RT-Thread Studio configuration and related code

2.1 Add WIZnet software package

Search for W5500 package in RT-Thread package and add it to the project

The result after adding is shown in the figure below

2.2 Configure WIZnet software package

The pin description of spi20 device is as follows

PB12SPI2_CS
PB13SPI2_SCK
PB14SPI2_MISO
PB15SPI2_MOSI

Reset reset pin is 26 (corresponding to PB10), IRQ interrupt pin 27 (corresponding to PB11), please refer to the figure below for pin numbers

The hardware connection diagram is as follows:

 

2.3 Configure spi20

Add the HAL_SPI_MspInit function (SPI2 pin configuration) to the drv_spi.c source file

3. Verify the effect

The display effect of the serial debugging assistant is as follows

ifconfig: View the current network ip address, gw address (gateway address), net mask (subnet mask), dns server (dns server)

ping 172.30.1.103 Successfully pinged, indicating that the LAN can access each other

(Note: Because the router is not connected to the public network, there is no ping www.baidu.com)

 

4. With ali-iotkit-v3.0.1 Alibaba Cloud IOT package MQTT topic subscription publishing

4.1 Add ali-iotkit-v3.0.1 package

4.2 Configure the triple parameter of Ali-iotkit to connect to the Alibaba Cloud IOT platform, open the Sample code, and other parameters can be defaulted

4.3 MQTT example code mqtt-example.c

Enter ali_mqtt_sample in the serial debugging assistant (add the carriage return, line feed or ENTER key) to connect to the Alibaba Cloud IOT cloud platform for MQTT communication.

4.4 Sample code of object model linkkit_example_solo.c

Enter ali_linkkit_solo_sample in the serial debugging assistant (add the carriage return, line feed or ENTER key) to connect to the Alibaba Cloud IOT cloud platform for object model communication.

4.5 Experimental verification OK

29cc6e4f79e8f0527be8ae2a09fb1791.png

table of Contents

1 Introduction

1.1 WIZnet

1.2 W5500

2. RT-Thread Studio configuration and related code

2.1 Add WIZnet software package

2.2 Configure WIZnet software package

2.3 Configure spi20

3. Verify the effect

4. With ali-iotkit-v3.0.1 Alibaba Cloud IOT software package MQTT topic subscription publishing

4.1 Add ali-iotkit-v3.0.1 package

4.2 Configure the triplet parameters of Ali-iotkit to connect to the Alibaba Cloud IOT platform, open the Samples sample code, and other parameters can be defaulted

4.3 MQTT example code mqtt-example.c

4.4 Sample code of object model linkkit_example_solo.c

4.5 Experimental verification OK

 


Development environment: useRT-Thread Real-time operating system.

Development software: useRT-Thread Studio (Currently the latest version 1.1.3).

Development hardware: use the STM32L475 Pandora development board of Punctual Atom.

 

1 Introduction

1.1 WIZnet

WIZnet software package is RT-Thread based on WIZnet official websiteioLibrary_DriverThe transplantation of the code base is implemented. Currently, only W5500 devices are supported. On the basis of the original code library function, this software package docks with the RT-Thread SAL socket abstraction layer, realizes the support for standard BSD Socket APIs, is perfectly compatible with a variety of software packages and the realization of network functions, and improves the compatibility of WIZnet devices.

1.2 W5500

W5500 is one of the high-performance Ethernet interface chip series launched by WIZnet, which integrates full hardware TCP/IP protocol stack + MAC + PHY. The full hardware protocol stack technology uses hardware logic gate circuits to implement complex TCP/IP protocol clusters, and its application has significant advantages such as simple and fast, high reliability, and good security; the internal integration of MAC and PHY technology allows the single-chip microcomputer to connect to the Ethernet solution The hardware design is simpler and more efficient.

The W5500 chip is an integrated hardwareTCP/IP protocolThe embedded Ethernet controller of the stack is also an industrial Ethernet control chip. It is South Korea’s WIZnet (Wei Zhi Na Te) released a full hardware TCP/IP protocol stack Ethernet interface chip.

W5500 supports high-speed standard 4-wireSPIThe interface communicates with the host. The SPI rate can theoretically reach 80MHz. It also integrates Ethernet data link layer (MAC) and 10BaseT/100BaseTX Ethernet physical layer (PHY), supports auto-negotiation (10/100-Based full duplex/half duplex), power-down mode and wake-up on LAN Features. Different from the traditional software protocol stack, the 8 independent hardware sockets embedded in the W5500 can carry out 8-channel independent communication. The communication efficiency of the 8-channel Socket does not affect each other. Each socket can be flexibly defined through the 32K byte receiving/sending buffer on the W5500 chip. the size of.

(Note: Reference materialsWIZnet W5500-Reference Design Collection

Features

    • Full hardware TCP/IP protocol stack: TCP, UDP, ICMP, IPv4, ARP, IGMP, PPPoE
    • 8 independent hardware sockets, each communication does not affect each other
    • 32K bytes transmit and receive buffer
    • Integrated 802.3 Ethernet MAC
    • Integrated 10Base-T / 100Base-T Ethernet PHY
    • Host interface: SPI high-speed serial peripheral interface (up to 80Mhz)
    • Support embedded operating system: Linux & RTOS
    • Support power-down mode & wake on UDP network
    • Working voltage 3.3V, I/O 5V withstand voltage
    • Support auto negotiation (full/half duplex, 10M/100M)
    • Working temperature is about 40℃
    • 48Pin LQFP lead-free package (7x7mm, 0.5mm pin pitch)

 

 

 

2. RT-Thread Studio configuration and related code

2.1 Add WIZnet software package

Search for W5500 package in RT-Thread package and add it to the project

The result after adding is shown in the figure below

2.2 Configure WIZnet software package

The pin description of spi20 device is as follows

PB12SPI2_CS
PB13SPI2_SCK
PB14SPI2_MISO
PB15SPI2_MOSI

Reset reset pin is 26 (corresponding to PB10), IRQ interrupt pin 27 (corresponding to PB11), please refer to the figure below for pin numbers

The hardware connection diagram is as follows:

 

2.3 Configure spi20

Add the HAL_SPI_MspInit function (SPI2 pin configuration) to the drv_spi.c source file

3. Verify the effect

The display effect of the serial debugging assistant is as follows

ifconfig: View the current network ip address, gw address (gateway address), net mask (subnet mask), dns server (dns server)

ping 172.30.1.103 Successfully pinged, indicating that the LAN can access each other

(Note: Because the router is not connected to the public network, there is no ping www.baidu.com)

 

4. With ali-iotkit-v3.0.1 Alibaba Cloud IOT package MQTT topic subscription publishing

4.1 Add ali-iotkit-v3.0.1 package

4.2 Configure the triple parameter of Ali-iotkit to connect to the Alibaba Cloud IOT platform, open the Sample code, and other parameters can be defaulted

4.3 MQTT example code mqtt-example.c

Enter ali_mqtt_sample in the serial debugging assistant (add the carriage return, line feed or ENTER key) to connect to the Alibaba Cloud IOT cloud platform for MQTT communication.

4.4 Sample code of object model linkkit_example_solo.c

Enter ali_linkkit_solo_sample in the serial debugging assistant (add the carriage return, line feed or ENTER key) to connect to the Alibaba Cloud IOT cloud platform for object model communication.

4.5 Experimental verification OK

documents
Code
github code

COMMENTS

Please Login to comment
  Subscribe  
Notify of
POSTED BY
Reusable S/W