NRF24L01 on STM32F103

12,316

8

24

Introduction: NRF24L01 on STM32F103

About: Works with Arduino, RaspberryPi, Banana Pi, Orange Pi, STM32F103C, ESP8266,

This instructable is for those that want to get started using the "Blue Pill" with the NRF24L01.

OK, I'm cheap! I used the tutorials for the NRF24L01 to link two arduinos together, but then... Along came the "Blue Pill." The "Blue Pill," or STM32F103C, is a super cheap ARM cortex board, only slightly larger than a NANO, will a multitude of IOs, that can be bought at a fraction of the cost of an Arduino Uno. If you look online, sometimes they can be under $2.00.

I'm an advocate of cheap and easy. I wanted to use the "Blue Pill" to radio transmit with the NRF24L01, but I couldn't find any simple instructions. If you are looking to use the NRF24L01 with the "Blue Pill," this is the quick and dirty "How To."

Step 1: What You Will Need.

For this instructable, you will need a few things:

1. 2x NRF24L01 -- The wireless communication board.

2: "Blue Pill" -- stm32F103C

3. FTDI -- The USB to Serial communication device for the programming.

4. Arduino UNO-- or another "Blue Pill."

5. 2x 10uF Electrolytic Capacitors.

6. 1x LED

7. 1x 220 Ohm resistor

8. At least 14 male to female Dupont cables, a large handful of male to male Dupont Cables and two bread boards.

My "Title Shot" shows a breadboard without the FTDI, but with a voltage regulator on the end of the board. Most FTDIs can power the Blue Pill for this project. Also, I created a number of LEDs with a cardboard backing and 220 Ohm resistors pre-soldered for quick prototyping. This is why you don't see the resistor on the board.

Step 2: Setting Up the Transmitter

Here, you have an option between using a "Blue Pill" or and Arduino as the transmitter.

This is the first step in setting up the Arduino transmitter. We will set up the transmitter as the picture shows above. Note that the 10k Ohm resistor to ground is on the same side of the switch as Pin2. After the button is released, the low level leak through the resistor will help the Pin2 go back to 0v. This setup works with the "transmitter_NRFL01.ino" file below.

This is also the first step to set up the Blue Pill transmitter. This setup works with the "STM32_transmitter_NRFL01.ino" file below.

The USB port on the Blue Pill can not be used to upload the Code. There are some hacks that will allow the USB port to be used by flashing an Arduino bootloader onto the chip, but you still need to flash with an FTDI first.
For the sake of not trying to re-invent the wheel, I strongly recommend using this video to learn how to program the Blue Pill. Kudos to Joop Brokking for this Youtube video. It is the most simple explaination I've found. In the illustration above, note the 5v and 3.3v tolerant pins. This is important when starting to use this device. The 3.3v voltage regulator from 5v on the board is subject to overheat and fail if pushed too hard. The more you keep this board at 3.3v, the better. Note that the Pins have different coresponding names in the code than the silkscreened pin on the physical board.

Set up the blue pill as shown above after programming the code. The same applies with the Blue Pill diagram as the Arduino-- the resistor kinda leaks the voltage out to return to normal.

The Capacitor isn't really necessary, but with the small surges of power to transmit, the signal can be compromised and flaky.

In the Arduiino IDE, download and install the RF24 Library.

The Code:

Step 3: The Receiver Setup

Setup your board as the Gimp illustration is shown above. Yes, I know I need to learn fritzing. This is quick and easy Gimp (Graphic Image Manipulation Program).

The Code:

Be the First to Share

    Recommendations

    • Battery Powered Contest

      Battery Powered Contest
    • Plywood Challenge

      Plywood Challenge
    • Plastic Contest

      Plastic Contest

    24 Discussions

    0
    PavanS3
    PavanS3

    Question 1 year ago

    hello this is pavan,
    i just tried what exactly in your page.
    STM32 working fine, ARDUINO aswell, individually both are working. once i come to your connection and theme noting works.
    actually my intension is STM32 send MPU6050 data to UNO.

    0
    jimgarbe
    jimgarbe

    Answer 1 year ago

    I've been playing with two or more MPUs on the Blue Pill via the SPI interface. It seems to work much faster than an UNO. The bus speed of the UNO is sooo much slower than the STM32-- It would be , kinda, working backwards. With the given information (links to my sources), you should be able to make that connection fairly easily. Remember, the nrf24L01 isn't able to go very far if you don't, either get a better antenna, use a capacitor, or both. Sounds kinda like you're making a drone?

    0
    PavanS3
    PavanS3

    Reply 1 year ago

    thank you

    0
    PavanS3
    PavanS3

    Reply 1 year ago

    i want to make a make autonomous car. almost done. struck at data transmission. in my design hand glove with MPU6050 and STM32 send data to autonomous car. if possible please help me.

    0
    drakder9
    drakder9

    Reply 8 months ago

    hola, yo estoy tratando de hacer un drone con el stm32 crees que pueda ver tu codigo que hiciste?

    0
    jimgarbe
    jimgarbe

    Reply 1 year ago

    The same info you get from a serial bus is the same kind of data you can transmit via the NRF24L01.
    Definately parse the data on the MPU side as much as possible. The Blue Pill has much heavier parsing power to make the data to be transmitted more tight and concise. I really like the "Teapot" quaternion data. It is super clean and filtered. I would imagine you are using an L293 H-bridge kinda thing on the car side. It shouldn't be too hard to control it with the data, whichever parsed type you choose.
    There are a number of libraries that parse the data on the MPU end:
    FreeIMU
    MultiWii
    BolderFlight
    0
    jimgarbe
    jimgarbe

    Reply 1 year ago

    This is a little out of the scope of this simple instructable but I hope it helps.

    0
    Roystan Castelino
    Roystan Castelino

    Question 1 year ago

    Can you please make an instructable with both MCUs as STM32? here you have used arduino uno and it works. but when i use stm32 as a transmitter, it simply doesn't work. please make an instructable.

    0
    jimgarbe
    jimgarbe

    Answer 1 year ago

    Yeah, you have a point. You aren't the only one who has asked. I will just edit this post and use the picture that I sent to you with the transmitter schematic. ;-)

    0
    aspagteq
    aspagteq

    1 year ago

    how to send data in structure formate from arduino and receive in stm32 in same formate that is structure

    0
    jimgarbe
    jimgarbe

    Reply 1 year ago

    I'm not understanding what you are asking. I send the text on the transmitter and it is recieving the tex ton the other end and printing it on the serial bus verbatum. Are you trying to send multiple data structures-- arrays?

    0
    aspagteq
    aspagteq

    1 year ago

    how receive data in structure formate in stm32....its not supporting RF24NETWORK library

    1
    jimgarbe
    jimgarbe

    1 year ago

    Use the trasnmitter code shown for the arduino and change/comment line 21 to

    "//RF24 radio(9, 10); // CE, CSN
    RF24 radio(PB0, PA4); // CE, CSN on Blue Pill"
    --just like the reciever code.

    Change line 23 to
    "int button_pin = PB6;"

    voila!
    I hope this helps.

    STMtransmitter.png
    0
    Roystan Castelino
    Roystan Castelino

    Reply 1 year ago

    What is the function of int button_pin? I had not done that, rest I have done. Let me check that once.

    0
    jimgarbe
    jimgarbe

    Reply 1 year ago

    Oh yeah. "button_pin" just renames the pin as a variable, named "button_pin". The code uses "button_pin" throughout the rest of the code. This makes it easier to change input pins if you decide a different pin fits better.

    0
    jimgarbe
    jimgarbe

    Reply 1 year ago

    The "button_pin" declares which pin the chip will listen for input.

    0
    Roystan Castelino
    Roystan Castelino

    Question 1 year ago

    stm32 is unable to transmit, can you make stm32 as the transmiter? I tried several times with many libraries, no luck!

    0
    GürkanT2
    GürkanT2

    1 year ago

    Hello I am trying to make your application.However I get the following error

    Ekran Alıntısı.PNG