This video tutorial shows how to use the NRF24L01 radio transceiver, by sharing a library that I've written for the NRF24. Here is a link for the library files and source code: github.com/MYaqoobEmbedded/ST...
I struggled with these problems for a long time, and this video is my day. My research work was stuck at a dead end because of a lack of knowledge about STM and nRF24. Great work!!
Wonderful tutorial, also helped me, building a bidirectional RF transmission with the NRF24L01+. There's one thing which could be interesting for some of you here, where I was struggeling for a longer time: I tried to use the automatic acknowledge functionality and always after the first transmission it stopped working. Well, the reason was not too abvious for me in the beginning but does make sense now: In order to save battery, I'm always taking away the battery completely from the transmitter after sending my data. This again always resets the internal counter, which is managed by the NRF24L01+ chip internally. When sending a second time, means, by pressing my transmission button again, this counter was then on the same value as before - and the receiver thinks that this was just a repetition of the first signal, and ignors it. So in other words: If you plan to remove the power of the transmitting chip, then you should: a) Use the non-acknowledged single way transmission mode or b) Build your own acknowledge system in Software and use a counter to distinguish between a "retransmission" packet or a new packet. Hope this helps someone? ;-) Greetz and thanks again for the great and well explained tutorial!
Thanks for the library. Just read the previous comments and changed the "Micro Second" code and it worked. For stm32fo use internal timer to generate almost 1us delay. I've used timer3 void NRF24_DelayMicroSeconds(uint32_t uSec) { __HAL_TIM_SET_COUNTER(&htim3,0); __HAL_TIM_ENABLE(&htim3); while(__HAL_TIM_GET_COUNTER(&htim3)
At first i want to thank you for this great library you have provided, which actually does my job easily. But initially this library did not work on my STM32F446 and STM32F767 and i ended up learning about the NRF24 (which is good :) ). Last night i was trying to do some project and i needed a function for delay us. I remembered that you library consist of a delay us function and i tried to implement it and Boom!! I found that your delay us function don't work. And i implemented your libraries again with HAL_Delay(1) for everywhere you used delay us function and everything works just as expected. So if anyone is having problem with this library after all the circuitry part is OK then try to change the delay us function. Regards
@@mutexembedded2206 you should make a tutorial on microdelay and why it is different for different boards and how things work inside the mcu... It will help many people... Including me. Regards
Thank you so much for this comment ! I spent few hours checking every function, and everything that was written in every register just to realize everything was correct. I would have never found where the error came from if it wasn't for your comment. It seems kind of weird that I have this bug since I am using exactly the same board as the Transmitter one (STM32f401RE), but it still did not work because of the Delay. Thanks again ! Also, thank you Mohammed for your work and all your tutorials (even if on this one it did not work). I am learning a lot from all your videos.
Hi, could you please, or somebody else, share code ? I did try to replace every "delay us" function with HAL_Delay(1) , but no luck. I also properly implemented delay_us function, in which i used timer, but i still cant communicate with another board. I have no problem to read registers of NRF24, or write to them, so ISP configuration must be OK. When i use two arduinos (2x mini pro, one as Rx, one as Tx) they works fine. But when i try to replace one arduino with STM32F103, i am not able to receive or send data to arduino.
Thank you sooooooooooooo much dear MYaqoobEmbedded... its working proper for me on my stm32f103c8 board, there was a problem on receiver but with the help of @Devjeet Mandal comment about delay, i used HAL_Delay(1); at every where instead of uDelay its working well on my board, THANK YOU sooo much dear MYaqoobEmbedded bro, thanks lot. Thank you @Devjeet Mandal for your kind note, thank you
I appreciate your work Mohammad As a hobbyist, I started exploring embedded systems on and off. Lately I have been very impressed with ChibiOS I wonder if you considered it? and if so what you think? It has a a solid RTOS and HAL layers, and nicely coupled with STM32 boards. Frankly I feel you need an RTOS layer, else the resources of the MCUs won't be taken advantage of Thx Again Salah
Nice tutorial. I also watched your tutorial on the Virtual Serial Port. Is there a way to use the nrf24_DebugUART_Init(huart2); function but send printRadioSettings(); data to the VSP instead of uart2?
I want to try this after I build another F405 board. Can someone give me a link for some NRF24L01 modules that will definitely work with this library please
Great tutorial! Only one problem: in function" NRF24_DelayMicroSeconds(uint32_t uSec)" I had to add volatile qualifier for uSecVar, otherwise timing was too short and functions using this timing didn't work. Compiler optimization issue in "while(uSecVar--);" loop. I'm on STM32cubeIDE. Thanks once again!
I am using NRF24L01+ module with STM32F446RE Nucleo board. I changed delay us functions to HAL_Delay(1). After that, I am able to transmit in TX mode, but I am not able to receive the data at the receiver side. I am following all steps showed in this video. Can anyone please help me?
I have one more question. I will apply to my system but I wanted to ask you that can I use NRF24 module as transmitter and receiver at the same time by using your codes?
hello, i have a question about sending data from multiple devices and receiving in only one (multiple Tx, one Rx). Should i use different channels on every Tx or should i use different pipe addresses? As I understood from datasheet, I can use different pipe addresses for every Tx and all of those addresses should be in Rx device, then just scan through them? Thank you for this very easy to use library.
Hello! I am trying to find a library that works with a simple 433Mhz RF transmitter and this is the closest I can find. Do you think that the write function in this library works with a much simpler 433Mhz transmitter? If not, can you point me to where I can learn more about rf transmitters so I can make my own library? Thank you!
Am not getting my receiver to reply to the transmitted message. I literally just copied the same project for transmitter and made sure that am loading the right elf file to the receiver. Still its NRF_available() always returns false. anyone that's experienced the same problem and how did they solve it?
hi, i downloaded your library for stm32 cube ide. But I want to change the RF_PWR setting. I saw that it is possible to choose between 0 dB and 18 dB. How do I change main.c? Also, which dB setting should I choose for the maximum distance? Can you help me.
Hello, I have some issues with receiving message. I have a question, if it is possible to implement your library on stm32L053 microcontroler? If so, what would be the main changes for the library? Thanks :)
Hi! Great video and very useful library. I’m trying to develop a simple TX RX application between two STM32s. I see that the .c library file has a SPI typedef called nrf24_hspi. However CubeMx declares it as hspi1. The code compiles (I haven’t tested functionality) but I don’t see any linkage between hspi1 and nrf24_hspi. How are the two connected?
@@mutexembedded2206 Thank you! I am following the video and I've entered the code for no ack transmit. However, it does not seem to be transmitting. Here is the UART data: pastebin.com/xbdXvhaZ. Here is the code so far: pastebin.com/9EWEpQbD. What am I missing?
@@mutexembedded2206 Oh sorry! It's a STM32F103C8T6 Bluepill board running at 72MHz. Using SPI1 which is on APB2 which is also running at 72MHz. I set the SPI baud prescaler divider to 64 giving me a data rate of 1.125Mbps. I have changed the define in MY_NRF24.h to stm32f1xxx_hal.h. Using UART1. Using the TrueStudio IDE.
Hey Mohammad, can u please add and extension of the video where a single nrf24 changes btwn transmit and receive mode. I was trying this using ur library. But failed to do so. There are 2 nrf A-Nrf and B-Nrf. First A-Nrf is in transmit mode and B-Nrf is in receive mode. Now A-should tranamit something and change in receive mode... Simultaneously B receives the data and changes in transmit mode. I am doing this by using NRF24_stoplistning() and NRF24_startlistening() to switch btwn transmit and receive mode.. But after few transaction both the devices turns in transmit mode. Can you help pls?
Thank you for your good work, that was very helpful especially i'm passing from Arduino to STM32 and i found it difficult. I tried to send struct data but the write function doesn't accept it as argument, how can I send more than one data? thank you in advance
Hi, you can send struct data as long as it does not exceed max bytes of 32 bytes. If I have: struct assetTracker_TAG{ uint8_t id; uint16_t addrs; uint32_t latitude; uint32_t longitude; bool status; }assetTracker_t; assetTracker_t myAssetDef; nrf_write(uint8_t *bytes, uint8_t size); nrf_write((uint8_t *) &myAssetDef, sizeof(myAssetDef));
I tried to use what you said, I guess this don't work assetTracker_t myAssetDef; we shoud declare the variable using assetTracker_TAG myAssetDef. still I have this error when i use nrf_write((uint8_t *) &myAssetDef,sizeof(myAssetDef)) that says "operand of type 'struct assetTracker_TAG' where arithmetic or pointer type is required" I used nrf_write(&myAssetDef,sizeof(myAssetDef)) which doesn't give error. In the end, I don't receive the data on the receiver. sorry to bother you.
Hello sir, Do you have any video which explains what clock speed to use on different applications like you changes Spi prescalar and leave frq to 84 MhZ How to get that?
For specific peripheral clock speed, you look into Clock Diagram for your specific MCU to find out which clock it's using. For instance ADC might be using APB1. Thus, you can look APB1 peripheral clock frequency in CubeMX clock tree and accordingly set your ADC prescalar.
@@zuhaibchoudhary4635 For Clock, it is recommended that you learn STM32 programming without CubeMX first. To get a better insight about what's going on. I am in fact preparing for a getting started series for fundamentals of STM32 programming, that's without CubeMX. That's in fact where most of us who do work with companies start with.
That will be great Sir Like We want to learn 1 . Without using HAL libraries. 2. how to make our own .c and .h file. 3. Writing from scratch and using our own libraries.
First, thank you very much for your tutorials. During following your teaching, I can't see the "Hello world!" in serial terminal window. It seems communication works. Could you check my code (actually yours)?. I am using two Nucleo F446REs.
HI MYaqoob, I am using your library "NRF24L01+, STM32-Tutorials\Tutorial 24 - NRF24L01 Radio Transceiver" I created an issue on the git hub page with above title , did you get chance to look at it?
welldone ... i hav e a question about this ce and csn pins ,, how i can change these pins and choose different ports for these pins .. i have ce on port B and csn is on port A
@@mutexembedded2206 i forgot to mentioned i am using stm32L0 , i did overwrite pins but it didnot work and also i wrote separately void NRF24_begin( function for ce and csn pins but did not help . tx ds remains zero all the time.
can you please help me about code for Arduino as receiver. I compile your code for transmitting but I want to use an Arduino as receiver and I just configured address and channel parameters but it didn't worked. Do you thing that ı should change library or set else? please help
@@mutexembedded2206 Thank you for your reply. I configured my stm as same as like you but my receiver nrf24l01 connected to an arduino. Do you think an arduino and a stm board can communicate with this way if we configure both of them correctly?
@@heuehwbebjd2100 unfortunately i couldnt solve the problem, i tried almost every library on internet and configuration but they didnt communicate each other. if you will be successful please inform me too :)
@@fehimkus5658 I have exactly same problem as you two have. I also tried different configurations for STM32 (change rf channel, CRC length, ack enabled/disabled) no luck. I also fixed MicroDelay function with using timer, still no luck :/
Hi, I am not entirely sure,, but could be something related to using different boards, think of anything that may have changed, UART peripheral, pins and port and so on. I will be able to give you a bit more constructive feedback if you can send me a link to your project setup. Thanks
@@mutexembedded2206 I have changed the UART. I am using USART3. I have also changed the SPI Pins but kept it on same port SCK - PE12 MISO - PE13 MOSI - PE14 CS - PE15 CE - PE10 IRQ - NC I have not changed a bit of your library. Here is the link of my main file and SPI initialization. pastebin.com/CVFTdKca
Hello again, I resolved my problem. In my case problem was in NRF24_startWrite(). Before set BIT_PWR_UP and clear BIT_PRIM_RX set CE line as LOW and after set CE in HIGH.
Hi, congratulations for the video. I followed the transmission and reception procedures without ack. and it did not work. However I noticed that when the settings by the printradiosettings in the transmitter show the address 0x1122334455, but in the receiver when the tx result in the printradiosettings in tx shows 0xe7e7e7e7e7 does not assign the address, but the channel was assigned normally. If you can help then and for a course completion job. thank you
HI MYaqoob, I am using your library for NRF24L01+, STM32-Tutorials\Tutorial 24 - NRF24L01 Radio Transceiver I have the following issue, Would you please help me understanding what is wrong.PFA Previously it was receiving correct strings, but now I am just receiving as "TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT" My transmission strings look like this ---------- Configured as Transmitter ------------ Tx Count= 6566, Tx Failed= 0, Rx Count= 0, Rx Failed= 0 'T' is first letter which is transmitted, but it doesn't receives strings after that, I checked with SPI analyser. image Sometime it goes to Power down mode abruptly and all value of status/config register becomes zero. I added NRF24_powerUp(); while changing mode Tx to Rx, but nothing helps. image Radio_RF_Control.zip
I will check for any software related issues with the NRF24L01+. I suggest you check for power consumption, perhaps use external power supply for the NRF as STM cannot supply lots of current.
@@mutexembedded2206 Thanks for the response. I have tested with external power as well as with ext voltage regulator and added a 10 uF capacitor and reduced RF Power but still no improvement, I also raised this issue on your github page.
Hi..thank you very much for the video... I tried it with my customised board having part stm32f072rb.... The transmitter works fine...I found transmitted successful msg on terminal... But as per video I didn't get data on receiver side...that is hello world... I didn't get where is the problem... Can you help me to get solve the issue
Many pple seem to suffer from this issue.. I will try updating this tutorial sometimr soon to fix all reported issues and make it compatible with all targets
@@mutexembedded2206 Thank you for the reply I am using two stm32f103c8 for TX and RX but not able to get the data on the receiver side could you please correct it, I think the minor mistake I am doing over here, Below is the link drive.google.com/file/d/1sTJKCOvcNkzY1lzRyMtCjxnakKnmdpfN/view?usp=sharing and please mail me @ iamnotarobot9643@gmail.com Thank you
@@newtonkhan7883 hi no worries Can you explain to me briefly what's your setup is like, are you communicating with PC or a UART module? And what sort of tests have you carried out already.
@@mutexembedded2206 Thank you so much for the reply I am using two stm32f103c8 for transmitter and receiver, I am using terminal software 1.9b. Thank you