Notifications
Clear all
Topic starter
2026-05-15 1:22 am
The main function of the wireless receiver is to receive node data via the wireless channel, convert it into a serial port signal, and send it to the back-end PC for analysis, processing and data display.
Power consumption is not a concern for the receiver. Therefore, STM32F103C8T6 is selected as the main control MCU, and nRF24L01p is adopted as the RF chip as well.
Power consumption is not a concern for the wireless receiver, but communication distance needs to be considered. Therefore, its receiving sensitivity is configured to the maximum level. As mentioned above, the receiving sensitivity can reach -94dBm at a baud rate of 250kbps. The configuration code is as follows:
SPI_RW_Reg(WRITE_REG + EN_RXADDR, 0x08);// 使能接收通道3
SPI_RW_Reg(WRITE_REG + RF_CH, 0x00); // 选择射频通道0x40
SPI_RW_Reg(WRITE_REG + SETUP_AW, 0x03);
SPI_RW_Reg(WRITE_REG + DYNPD, 0x08);
SPI_RW_Reg(WRITE_REG + FEATURE, 0x04);
SPI_RW_Reg(WRITE_REG + RF_SETUP, 0x26); // 数据传输率250Kbps,低噪声放大器增益-94dBm
SPI_RW_Reg(WRITE_REG + CONFIG, 0x3f); // CRC使能,16位CRC校验,上电,接收模式
4. PC Software
After the receiver receives a large amount of node data, it forwards the data to the PC via the serial port. A simple PC-side software has been developed to display the data and log it into the HEX.txt file. The interface layout is as follows:
The program flowchart is shown below. Its main functions are to receive data via the serial port, parse the data, display the data in the form of graphs, and log the data to a text file.
In the plotting code segment, after receiving the data packet, the temperature and humidity data are extracted, converted to decimal, and then plotted in the drawing area on the right. Since the test target is temperature and humidity in a conventional environment, the temperature display range is set to 0~50℃, and the humidity display range is set to 0~100%RH. As shown in the code, the temperature curve is red and the humidity curve is blue.
If temperature_x >= 9990 Or humidity_x >= 9990 Then
temperature_x = 0
humidity_x = 0
Picture1.Cls '清除图片,重新画图
End If
temperature_x = temperature_x + 10
humidity_x = humidity_x + 10
Picture1.Circle (temperature_x, t_temp * 180), 10, vbRed '温度描点
Picture1.Circle (humidity_x, h_temp * 90), 10, vbBlue '湿度描点
Display the received data packet in the text box Text22.
Text22.SelStart = Len(Text22.Text)
Text22.Text = Text22.Text + vbCrLf
Text22.Text = Text22.Text & "Receive:"
Text22.SelStart = Len(Text22.Text)
For i = 6 To 16
If Len(Hex(recdata_buffer(i))) = 1 Then
rec_temp = "0" & Hex(recdata_buffer(i))
ElseIf Len(Hex(recdata_buffer(i))) = 2 Then
rec_temp = Hex(recdata_buffer(i))
End If
Text22.Text = Text22.Text & rec_temp + Space(1)
Text22.SelStart = Len(Text22.Text)
Next
Text22.Text = Text22.Text + vbCrLf
Text22.Text = Text22.Text & "Address:" & H_add & Space(1) & L_add & Space(2) & "Temperature:" & t_temp & "℃" & Space(2) & "Humidity:" & h_temp & "%RH" & Space(2) & "Votage:" & v_temp & "V" & Space(2) & "Time:" & Now
Text22.SelLength = 1
Text22.SelStart = Len(Text22.Text)
Length_1 = Len(Text22.Text)
End If
End If
Write the data to a text file named HEX.txt, which is stored in the same location as the program. The content is appended to the end of the file. Each data packet occupies one line and is added line by line.
If Length_1 > Length_0 Then
Text22.SelStart = Length_0 'A.Length_0为写入新数据前文本长度
Text22.SelLength = Length_1 - Length_0 'B.两者的差为新数据长度
Dim FileNumber
FileNumber = FreeFile
Open App.Path & "/HEX.txt" For Append As #1 '文件保存位置与程序一致
Print #1, Text22.SelText '将上边A,B两式计算得到的新数据写入文本
Close #1
Length_0 = 0
Length_1 = 0
End If
.................. To be continue
Yassin | Building Compact, High-Current Connections for Drones & Robots




