Skip to content

W5500-based Webserver data display with N32G457 series

Make a web server for displaying sensor data using W5500 and Mongoose. the hardware part is composed of the N32G457 main control board.

WIZnet

Published December 27, 2022

Original author: yukelab · ChinaOriginal source (new tab)

W5500-based Webserver data display with N32G457 series

Components

Hardware components

WIZnet parts

Project description

The SDI-12-based sensor data recorder I was going to do was not suitable after I got the board; I happened to have a W5500 module at hand, so I made a webserver for displaying sensor data;

Based on the webserver developed by W5500 and Mongoose; the hardware part is composed of W5500 module, N32G457 main control board, etc.; the software part is mainly transplanted from Mongoose 7.4, adapted to the RT-Thread SPI driver, and filled in a little pit of the W5500 software package.

hardware wiring
W5500 Module Hardware
SPI1
CS_PIN -> PA3
RST_PIN -> PC4
IRQ_PIN -> PA0

ADC temperature
VRFE_N -> GND

VREF_P -> 3V3

Software Implementation
The software architecture of this project is mainly completed with 2 threads, among which:
MG thread: the main thread of Mongoose http server;
INFO thread: responsible for obtaining the chip temperature. Since there are no other types of sensors at hand, some information for display is generated in this thread. random number;

Since there is no storage device, the code of the js part is stored in ROMFS, and the js part uses d3.js to draw and update dynamic charts, and uses axios to make http requests;

The complete picture of the work:
 

W5500-based Webserver data display with N32G457 series

 

Demonstration effect :

W5500-based Webserver data display with N32G457 series

 

Code address
https://gitee.com/yukelab7/n32g457_mongoose

other
Basic development environment configuration
Use the initial env environment of RT-Thread to compile the code;

Compiler Environment
scons

Use pyocd to burn
pyocd burning environment configuration
The support for the target chip in the document (Target support) talks about the support of the target chip in three ways;

Built-in
CMSIS-Packs
Manual pack usage


Here I use CMSIS-Packs to provide the N32G45x Nationstech.N32G45x_DFP.1.0.4.packpackage , but pay attention to modify the path of the compressed file of this package, and note that the left side is the correct configuration;

W5500-based Webserver data display with N32G457 series

Use the default configuration file, the file name must be pyocd.yamlor pyocd.yml, then pyoncd flash ./rtthread.bindownload ;

pyocd.yaml file content

 

probes:
 0001A0000002: # Probe's unique ID.
   target_override:  n32g457vel7
   test_binary:      ./rtthread.bin
pack:
 - ./pyocd_flash/Nationstech.N32G45x_DFP.1.0.4.pack

 

W5500-based Webserver data display with N32G457 series

Three Pitfalls in the Software Development Process
spi part
Problem Description
I imitated the hardware library by myself, and built a spi driver. spi_transmitreceiveWhen I , I found that SPI_I2S_RNE_FLAG was set before filling the data, resulting in misplaced and missing data in the readback data;

solution
In the process of reading and writing data, ensure that SPI_I2S_RNE_FLAG is in a non-set state, and pass a dummy read operation;

W5500 part
Problem Description
The wiznet package does not handle the SO_REUSEADDR and SO_KEEPALIVE options in the wiz_setsockopt function of the wiznet package, which causes mongoose to fail to start;

solution
Add these two option parameters;

mongoose part
Problem Description
mongoose runs normally on qemu; because there is no storage device on the n32g457 board, the server-related files are stored in flash in the form of ROMFS, and then the default file interface of mongoose is used, and the read and write index.htmlfails ;

solution
It is found that the essence of mg_file is realized by the standard library. Maybe the standard library in RTT does not support the reading of ROMFS. Based on the poxis interface of DFS, a file interface is made;
 

 

Documents

Comments

Similar projects you might like

Comments