Skip to content

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)

gavinchang

Published January 02, 2023

Original author: plcpro · ChinaOriginal source (new tab)

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

Components

Hardware components

WIZnet parts

Project description

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
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
software framework
Based on RT-THREAD STUDIO project.
The software framework and the use of rt-thread resources are as follows:

Software Framework.PNG
Software Framework Package.PNG
Software Framework Components and Service Layer.PNG
Software Framework Bottom Driver.PNG

The occupied resources on the RA6M4 board are as follows:

Software Framework Hardware Configuration.PNG
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

Alibaba Cloud Data Change Comparison

light31.PNG
Alibaba cloud light31.PNG
Alibaba cloud light999.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

Documents

Comments

Similar projects you might like

Comments