NRF24L01 on STM32F103

2,798

2

21

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."

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

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

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 Arduino

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.

The Capacitor isn't really necessary, but without it 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 STM32F103C 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 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.

The Code:

Be the First to Share

    Recommendations

    • CNC Contest

      CNC Contest
    • Make it Move

      Make it Move
    • Teacher Contest

      Teacher Contest

    21 Discussions

    0
    None
    aspagteq

    5 weeks ago

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

    1 reply
    0
    None
    jimgarbeaspagteq

    Reply 4 weeks 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
    None
    aspagteq

    5 weeks ago

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

    1
    None
    jimgarbe

    6 weeks 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
    3 replies
    0
    None
    Roystan Castelinojimgarbe

    Reply 6 weeks ago

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

    0
    None
    jimgarbeRoystan Castelino

    Reply 6 weeks 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
    None
    Roystan Castelino

    Question 2 months ago

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

    0
    None
    GürkanT2

    4 months ago

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

    Ekran Alıntısı.PNG
    2 replies
    0
    None
    jimgarbeGürkanT2

    Reply 4 months ago

    EEEEWWWWW! Yeah, this is one of those library issues I mentioned to merouaneouared21 earlier. Make sure that you have the library referenced properly in the program. Either this is a different library, or the author of the library has changed the method. I use a Linux machine to compile the code. I'll see if I can remember how to run Windoze enough to reproduce your error.

    0
    None
    jimgarbejimgarbe

    Reply 4 months ago

    OK, I downloaded the Arduino IDE, Installed the RF24 Library, and Installed the SAM Arm Cortex-M3 boards in boards manager, Downloaded the STM32 library from Roger Clark and unzip it into the ...\Documents\Arduino\hardware folder. (create the hardware folder if it doesn't exist.). I rebooted the Arduino IDE and compiled the code without a hitch. I did find that the line, "#include <nRF24L01.h>" is not necessary because It's not used in the sketch.

    0
    None
    PavanS3

    Question 4 months 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.

    5 answers
    0
    None
    jimgarbePavanS3

    Answer 4 months 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
    None
    PavanS3PavanS3

    Reply 4 months 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
    None
    jimgarbePavanS3

    Reply 4 months 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
    None
    jimgarbejimgarbe

    Reply 4 months ago

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

    0
    None
    merouaneouared21

    Question 5 months ago on Step 3

    hy guys....i want to know all the steps to make the stm32f103c8t6 working with nrf240l1,specially the part of libraries!!