i am developing my project in a stm32f103c8 (bluepill) with Keil and CubeMX, i want to use a nrf24l01 transmitter and for this i looked for a tutorial which is exactly what i want to do. the problem is that when i do it i notice that the radio transceiver does not transmit or receive, i have seen on the internet that some people have problems with this card that i am using, just me this is failing me using this library. I leave a link to a video that shows the same steps that I made in addition to the library. precisely the function nrf24_write
is the one that is not working. I hope you can help me because I've been trying to understand why it does not work for several days.
link video:
https://www.youtube.com/watch?v=O2dg2Eo7vo8
link library:
main code:
/* Includes ------------------------------------------------------------------*/
#include "main.h"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "MY_NRF24.h"
#include "stdio.h"
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */
/* USER CODE END PTD */
/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */
/* USER CODE END PD */
/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */
/* USER CODE END PM */
/* Private variables ---------------------------------------------------------*/
SPI_HandleTypeDef hspi1;
UART_HandleTypeDef huart1;
/* USER CODE BEGIN PV */
/* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_SPI1_Init(void);
static void MX_USART1_UART_Init(void);
/* USER CODE BEGIN PFP */
/* USER CODE END PFP */
/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
uint64_t TxpipeAddrs = 0x324e6f6465;
char myTxData[32]; //= "Hello World!";
char AckPayload[32];
/* USER CODE END 0 */
/**
* @brief The application entry point.
* @retval int
*/
int main(void)
{
/* USER CODE BEGIN 1 */
myTxData[0]= 0;
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_SPI1_Init();
MX_USART1_UART_Init();
/* USER CODE BEGIN 2 */
NRF24_begin(GPIOB, GPIO_PIN_8, GPIO_PIN_9, hspi1);
nrf24_DebugUART_Init(huart1);
//**** TRANSMIT - ACK ****//
NRF24_setPALevel(RF_PWR_HIGH);
NRF24_openWritingPipe(TxpipeAddrs);
NRF24_setAutoAck(true);
NRF24_setChannel(52);
NRF24_setPayloadSize(32);
NRF24_setDataRate(RF24_2MBPS);
NRF24_enableDynamicPayloads();
NRF24_enableAckPayload();
NRF24_stopListening();
HAL_Delay(1000);
printRadioSettings();
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
if(NRF24_write(myTxData, 32))
{
NRF24_read(AckPayload, 32);
HAL_UART_Transmit(&huart1, (uint8_t *)"Transmitted Successfully\r\n", strlen("Transmitted Successfully\r\n"), 10);
char myDataack[80];
sprintf(myDataack, "AckPayload: %s \r\n", AckPayload);
HAL_UART_Transmit(&huart1, (uint8_t *)myDataack, strlen(myDataack), 10);
}else{
HAL_UART_Transmit(&huart1, (uint8_t *)"Transmitted Failed\r\n", strlen("Transmitted Failed\r\n"), 10);}
myTxData[0]= myTxData[0] + 1;
HAL_Delay(1000);
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}