---
title: "IoT application based on RT-Thread+RA6M4+W5500 (based on Alibaba Cloud platform)"
url: "https://maker.wiznet.io/gavinchang/projects/iot-application-based-on-rt-thread-ra6m4-w5500-based-on-alibaba-cloud-platform/"
markdown_url: "https://maker.wiznet.io/gavinchang/projects/iot-application-based-on-rt-thread-ra6m4-w5500-based-on-alibaba-cloud-platform/md"
type: "UCC: User Created Content"
author: "plcpro"
author_url: "https://club.rt-thread.org/ask/article/d20bdb32d5314829.html"
editor: "WIZnet"
editor_url: "https://maker.wiznet.io/"
original_author: "plcpro"
original_url: "https://club.rt-thread.org/ask/article/d20bdb32d5314829.html"
published: "2023-01-02"
language: "en"
hardware: ["WIZnet W5500"]
likes: 6
views: 746
comments: 0
source: "WIZnet Makers (https://maker.wiznet.io/)"
---

# IoT application based on RT-Thread+RA6M4+W5500 (based on Alibaba Cloud platform)

> IoT application based on RT-Thread+RA6M4+W5500 (based on Alibaba Cloud platform)

Original author: plcpro (source: https://club.rt-thread.org/ask/article/d20bdb32d5314829.html)

## Components

- **WIZnet W5500** x 1 ([docs](https://docs.wiznet.io/Product/Chip/Ethernet/W5500))

WIZnet parts: W5500 ([Datasheet](https://docs.wiznet.io/Product/Chip/Ethernet/W5500/datasheet?utm_source=maker&utm_medium=project&utm_campaign=w5500), [product hub](https://maker.wiznet.io/products/w5500/))

## Documents and links

- [rt-thread-ra6m4](https://gitee.com/plcprosunway/rt-thread-ra6m4) (code)

## Article

**application background**
With the advancement of technology, the Internet of Things has gradually entered the home. It has become a trend to monitor and understand the status of electrical equipment in the home through the Internet of Things platform. This application brings you an application platform for the Internet of Things.
**function realization**
Through the development board of Renesas, we put the IO (LED light, button), light sensor and analog information on the development board. Upload to Alibaba Cloud platform through MQTT. In this way, when we log in to the Alibaba Cloud platform, we can know the status of the above devices.
**overall framework**

![Overall frame.PNG](https://oss-club.rt-thread.org/uploads/20220722/bdaf38305258de69ae97534192fbed09.png.webp)
hardware
The CPK-RA6M4 MCU evaluation board is based on the ARM Cortex M33 core chip launched by Renesas Electronics. The RW007 and W5500 modules connected to the network are added here. Make it convenient to connect to the Internet.

![CPK-RA6M4 hardware block diagram.PNG](https://oss-club.rt-thread.org/uploads/20220713/44c55dfe2e41cbf2faee672a3880d593.png.webp)
software framework
Based on RT-THREAD STUDIO project.
The software framework and the use of rt-thread resources are as follows:

![Software Framework.PNG](https://oss-club.rt-thread.org/uploads/20220729/1cd7bd527d930434e27befe11ce0fdb8.png.webp)

![Software Framework Package.PNG](https://oss-club.rt-thread.org/uploads/20220729/12da470ecaed8f467b4d23c99eea38c6.png)

![Software Framework Components and Service Layer.PNG](https://oss-club.rt-thread.org/uploads/20220729/7208859a2ebe2bc64968840063158f2d.png.webp)

![Software Framework Bottom Driver.PNG](https://oss-club.rt-thread.org/uploads/20220729/f8f60f2a948d59b25495dc09817f1b41.png.webp)

The occupied resources on the RA6M4 board are as follows:

![Software Framework Hardware Configuration.PNG](https://oss-club.rt-thread.org/uploads/20220729/a94eb92df0a935ae282d28f13f9d5afb.png.webp)
problem solving
Problems and solutions encountered when configuring W5500 and connecting to Alibaba Cloud.
The project is to connect Alibaba Cloud IOT through W5500. Realize the function of MQTT. Because the RW007wifi module is used at the same time, it is connected through SPI1. So prepare to achieve wired and wireless dual Internet access. So I am going to use SPI0 to communicate with W5500.
There are several places to pay special attention to when configuring SPI0.

1 The SPI MODE option should be changed to SPI OPERATIONthe defaultClock Synchronous Operation

2 Cancel the SSLA0 configuration of spi0 and set it in Pins instead. Set P205 toOutput mode（Initial High）

3 Callback The callback function is changed tospi0_callback

4 The interrupt pin of W5500 selects P06 on PMODA. It should be noted that when configuring IRQ11, the Triggerdefault is Risingto be changed to Falling
W5500 after the above configuration is completed. But an spi0 write failederror occurs.
There is no problem with carefully comparing the settings of SPI1.
Later, after analysis, it was found that DTC was not selected in the SPI option in the RT-THREAD setting, but the default in SPI0 was Enable Support for using TDC--- Enabled.
Change this option to Disableddrive success.
Also setting it as Enabled in SPI1 is no problem. We must pay attention to this point! ! !

So far W5500 has been able to network normally. However, when connecting to Alibaba Cloud's IOT, there will be an hard fault on thread: tshellerror bus fault:alarm.
After searching and locating the function in wizchip_c , after monitoring and analyzing, it is found that the value of the variable is too small.dns.int16_t dns_makequery(uint16_t op, char * name, uint8_t * buf, uint16_t len)
char sname[MAXCNAME];

The Aliyun iot URL needs 5-60 characters. Cause cp error error:Cannot access memory at address xxxxxxx
Changing wizchip_dns.h to #define MAX_DOMAIN_NAME 25616 will cause memory address error for URLs that are too long.

ADC continuous reading
The ADC sampling mode Mode in the Renesas configuration software defaults to Single Scansuch that the result of continuous sampling is normal for the first time, and the subsequent value is 0. It is necessary to modify the Mode to Continuous Scancyclic continuous reading.

overall picture

![Overall picture.jpg](https://oss-club.rt-thread.org/uploads/20220729/f4a2fc1a392c4260b9ef2194ca7ef234.jpg.webp)

Alibaba Cloud Data Change Comparison

![light31.PNG](https://oss-club.rt-thread.org/uploads/20220729/327da2abf4ab816e341f935cc92b6620.png)

![Alibaba cloud light31.PNG](https://oss-club.rt-thread.org/uploads/20220729/c97abc0f46445e6bcadac615f345a298.png)

![Alibaba cloud light999.PNG](https://oss-club.rt-thread.org/uploads/20220729/34812cf4232dc1b449ad9fa5adf036ae.png)

**Source code project file**
https://gitee.com/plcprosunway/rt-thread-ra6m4

Video material
https://www.bilibili.com/video/BV1t3411G7rn/?vd_source=d7cf337e889a6fabab42a74bc87c5601
https://www.bilibili.com/video/BV1xt4y1H7AM/?vd_source=d7cf337e889a6fabab42a74bc87c5601
https://www.bilibili.com/video/BV16S4y1t7jG/ ?vd_source=d7cf337e889a6fabab42a74bc87c5601
https://www.bilibili.com/video/BV1DT411j7Px/?vd_source=d7cf337e889a6fabab42a74bc87c5601
https://www.bilibili.com/video/BV1Pa411S7V3/?vd_source=d7cf337e889a6fabab42a74bc87c5601
————————————————
版权声明：本文为RT-Thread论坛用户「plcpro」的原创文章，遵循CC 4.0 BY-SA版权协议，转载请附上原文出处链接及本声明。
原文链接：https://club.rt-thread.org/ask/article/d20bdb32d5314829.html

---

Source: https://maker.wiznet.io/gavinchang/projects/iot-application-based-on-rt-thread-ra6m4-w5500-based-on-alibaba-cloud-platform/
