cancel
Showing results for 
Search instead for 
Did you mean: 

Not being able to receive data from LORA with stm32

AlexanderKibarov
Associate III

Hello, I am trying to send and receive data with LoRa using STM32. I will leave the codes below. The LoRa connections are made correctly. I was able to communicate using a similar code with another board, but it didn't work with the STM32. The reason for turning on the LEDs in the code is to check if the data is being sent via UART. Additionally, as stated in the LoRa documentation, I first send the address value, then the channel value, and finally the data. Can you help me?

 

Transmit:

uint8_t adressandchannel[] = {0x00, 0x00, 0x32}; // --> 1. Adress High, 2. Adress Low, 3. Channel

uint8_t data[] = {'H','E','L','L','O',' ','W','O','R','L','D','\n'};

HAL_StatusTypeDef st;

HAL_StatusTypeDef st1;

 

int main(void)

{

HAL_Init();

 

SystemClock_Config();

 

MX_GPIO_Init();

MX_USART3_UART_Init();

MX_USB_OTG_FS_PCD_Init();

MX_USART2_UART_Init();

 

while (1)

{

st = HAL_UART_Transmit(&huart2, adressandchannel, 3, 250);

st1 = HAL_UART_Transmit(&huart2, data, 12, 250);

if(st == HAL_OK && st1 == HAL_OK) HAL_GPIO_WritePin(GPIOB, GPIO_PIN_7, GPIO_PIN_SET);

HAL_Delay(500);

HAL_GPIO_WritePin(GPIOB, GPIO_PIN_7, GPIO_PIN_RESET);

HAL_Delay(500);

}

 

Receive:

uint8_t data2[12];

HAL_StatusTypeDef st;

 

int main(void)

{

HAL_Init();

 

SystemClock_Config();

 

MX_GPIO_Init();

MX_USART3_UART_Init();

MX_USB_OTG_FS_PCD_Init();

MX_USART2_UART_Init();

while (1)

{

 st = HAL_UART_Receive(&huart2, data2, 12, 1000);

 if(st == HAL_OK) HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_7);

 else HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_14);

}

 

0 REPLIES 0