本帖最后由 damiaa 于 2018-4-23 11:57 编辑 【LoRa 模块免费送】LoRa 通讯之二:STM32F4+模块和PC互通1,准备电脑一台 2,模块2枚 4,下载STM32Cube_FW_F4_V1.21.0解压 5,打开串口通讯的例子 D:\st\stm32f429\en.stm32cubef4\STM32Cube_FW_F4_V1.21.0\Projects\STM32F429I-Discovery\Examples\UART\UART_TwoBoards_ComITModi 6,修改一下main.c如下: uint8_t aTxBuffer[] = " ****Loar Test*** "; uint8_t aRxBuffer[RXBUFFERSIZE]; /* Private function prototypes -----------------------------------------------*/ static void SystemClock_Config(void); static void Error_Handler(void); static uint16_t Buffercmp(uint8_t* pBuffer1, uint8_t* pBuffer2, uint16_t BufferLength); /* Private functions ---------------------------------------------------------*/ /** * @brief Main program * @param None * @retval None */ int main(void) { HAL_Init(); /* Configure LED3 and LED4 */ BSP_LED_Init(LED3); BSP_LED_Init(LED4); /* Configure the system clock to 180 MHz */ SystemClock_Config(); /*##-1- Configure the UART peripheral ######################################*/ /* Put the USART peripheral in the Asynchronous mode (UART Mode) */ /* UART1 configured as follow: - Word Length = 8 Bits - Stop Bit = One Stop bit - Parity = None - BaudRate = 9600 baud - Hardware flow control disabled (RTS and CTS signals) */ UartHandle.Instance = USARTx; UartHandle.Init.BaudRate = 9600; UartHandle.Init.WordLength = UART_WORDLENGTH_8B; UartHandle.Init.StopBits = UART_STOPBITS_1; UartHandle.Init.Parity = UART_PARITY_NONE; UartHandle.Init.HwFlowCtl = UART_HWCONTROL_NONE; UartHandle.Init.Mode = UART_MODE_TX_RX; UartHandle.Init.OverSampling = UART_OVERSAMPLING_16; if(HAL_UART_Init(&UartHandle) != HAL_OK) { Error_Handler(); } /* Configure USER Button */ BSP_PB_Init(BUTTON_KEY, BUTTON_MODE_GPIO); while(1) { if(BSP_PB_GetState(BUTTON_KEY) != RESET) { if(HAL_UART_Transmit_IT(&UartHandle, (uint8_t*)aTxBuffer, TXBUFFERSIZE)!= HAL_OK) { Error_Handler(); } while (UartReady != SET) { } UartReady = RESET; /* Turn LED3 Off */ BSP_LED_On(LED3); HAL_Delay(400); BSP_LED_Off(LED3); } if(HAL_UART_Receive_IT(&UartHandle, (uint8_t *)aRxBuffer, RXBUFFERSIZE) == HAL_OK) { BSP_LED_On(LED4); HAL_Delay(200); BSP_LED_Off(LED4); } } } 7,打开串口调试助手和编译运行429板子开始测试 8,按下429用户键,串口4收到429板子通过模块空中发来的消息。 9,串口4发送消息,429板子能收到数据10,429板子用 电池供电 ,串口4每一秒发送一次数据,429的LED4每秒闪动一次,这样就可以测试距离了。10,已经测试,初步估算1.5公里。细节有时间汇报。 1.5公里。电梯里面无信号。 |
厉害了 |
【LoRa模块免费送】评测2 写通讯参数
【LoRa模块_E32-TTL-100】+模块设置和通讯
【LoRa 模块免费送】LoRa 通讯之二:驱动设计
【LoRa 模块免费送】LoRa 通讯之一:两模块互通
【LoRa模块免费送】评测3 双机通讯
【LoRa模块免费送】评测4 通讯距离测试
【LoRa 模块免费送】LoRa 通讯之一:系统分析
【NUCLEO-L496ZG评测5】USART和LPUART通讯
ARM®mbed OS入门开发 mbed UART通讯最简单例子
ARM®mbed OS入门开发 mbed UART通讯