Close Menu
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
Facebook X (Twitter) Instagram
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us
Facebook X (Twitter) Instagram Pinterest YouTube LinkedIn
How To Electronics
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
How To Electronics
Home » Interfacing NRF24L01 Transceiver Module with STM32 Tx/Rx
STM32 Projects

Interfacing NRF24L01 Transceiver Module with STM32 Tx/Rx

Mamtaz AlamBy Mamtaz AlamUpdated:August 21, 20222 Comments5 Mins Read
Share Facebook Twitter LinkedIn Telegram Reddit WhatsApp
NRF24L01 STM32
Share
Facebook Twitter LinkedIn Pinterest Email Reddit Telegram WhatsApp

Overview

In this article, we will learn Interfacing of NRF24L01 Wireless Transceiver Module with STM32 Microcontroller. We will make a Sender and Receiver Circuit using a pair of NRF24L01 + STM32F103C Bluepill Board. The NRF24L01 is employed on a good sort of applications that need wireless control. They are transceivers which suggest that every module can transmit and receive data. These modules are very cheap and you can use them with any microcontroller like Arduino or STM32F103C.

We will connect the NRF24L01 Module with STM32 & using some example code we will build a wireless network. In the first example, we will send a simple “Hello World” text from Transmitter to Receiver. In the second example, we will interface the BME280 Barometric Pressure Sensor with STM32 & NRF24L01. We will then send the Humidity, Temperature, Pressure & Altitude data from Transmitter/Sender to Receiver.


Bill of Materials

We need following components for this tutorial. All the components can be easily purchased from Amazon. The components purchase link is given below.

S.N.Components NameQuantityPurchase Links
1STM32F103C Microcontroller2Amazon | AliExpress
2 NRF24L01 PA+LNA Module2Amazon | AliExpress
3BME2801Amazon | AliExpress
45V Power Supply 2Amazon | AliExpress
5Connecting Wires20Amazon | AliExpress
6Breadboard1Amazon | AliExpress



NRF24L01 Module

NRF24L01

The nRF24L01 is a wireless transceiver module, i.e. each module can both send & receive data. It works within the frequency of 2.4GHz. This frequency falls under the ISM band and is legal to use in most countries for engineering projects. The modules when operated efficiently can cover a distance of 100 meters.

NRF24L01 PA LNA

The second version of this module, i.e. nRF24L01 PA+LNA comes with an SMA connector, duck-antenna & special RFX2401C chip which integrates the PA + LNA. This range extender chip along with a duck-antenna helps the module achieve a significantly larger transmission range about 1000m. The PA stands for Power Amplifier which boosts the power of the signal being transmitted from the nRF24L01+ chip. The LNA stands for the Low-Noise Amplifier which takes the extremely weak and uncertain signal from the antenna and amplifies it to a more useful level.

The module operates at 3.3V but its SPI pins are 5V tolerable. Each module has an address range of 125 and every module can communicate with 6 other modules hence mesh networking can be established with this module. The NRF24L01 module works with the help of SPI communications hence you can use NRF24L01 with any microcontroller with SPI Pins like STM32 or Arduino Boards.

If you want to learn more about this module, then you can follow our previous projects based on nRF24L01 Modules:
1. Wireless Sensor Data Monitoring with nRF24L01 & Arduino: Check Here
2. Wifi Gateway & Sensor Node with nRF24L01 Arduino & ESP8266: Check Here




Interfacing NRF24L01 Transceiver Module with STM32

Now let us interface NRF24L01 Transceiver Module with STM32 microcontroller and build our own transmitter and receiver. The schematic for transmitter and receiver circuit is given below. You can assemble a pair of circuit on breadboard.

NRF24L01 STM32F103C Connection

The connection between NRF24L01 & STM32F103C Bluepill Boards is given below.

NRF24L01 VCC ………………………………………… 3.3V of STM32F103C
NRF24L01 CSN ………………………………………… PA4 of STM32F103C
NRF24L01 MOSI ………………………………………… PA7 of STM32F103C
NRF24L01 GND ………………………………………… GND of STM32F103C
NRF24L01 CE ………………………………………… PB0 of STM32F103C
NRF24L01 SCK ………………………………………… PA5 of STM32F103C
NRF24L01 MISO ………………………………………… PA6 of STM32F103C

Transmitter Receiver


NRF24L01 STM32 Library

The STM32 Board doesn’t support nRF24L01 RadioHead Library (#include <RH_NRF24.h>). Hence we need to use RF24 Library. This library is designed to be maximally compliant with the intended operation of the chip & built against the standard SPI library.

The library supports two header files:

1
2
#include <nRF24L01.h>
#include <RF24.h>

You can download the library from the following Github link. Add the library to the Arduino IDE.

NRF24L01 STM32 Library


Simple Sender & Receiver Code

Now let us test the simple communication between STM2 NRF24L01 Transmitter and Receiver. The transmitter circuit will send “Hello World” along with the packet number. You can display transmitted and received message on Serial Monitor.

Sender Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
 
RF24 radio(PB0, PA4); // CE, CSN on Blue Pill
const uint64_t address = 0xF0F0F0F0E1LL;
int counter = 0;
 
void setup()
{
Serial.begin(9600);
radio.begin();                  //Starting the Wireless communication
radio.openWritingPipe(address); //Setting the address where we will send the data
radio.setPALevel(RF24_PA_MIN);  //You can set it as minimum or maximum depending on the distance between the transmitter and receiver.
radio.stopListening();          //This sets the module as transmitter
}
 
void loop()
{
char text[] = " Hello World";
char str[50];
sprintf(str,"%s %d",text,counter);
radio.write(&str, sizeof(str));  
 
Serial.println(str);
counter++;
delay(2000);
}

Receiver Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
 
RF24 radio(PB0, PA4); // CE, CSN on Blue Pill
const uint64_t address = 0xF0F0F0F0E1LL;
boolean button_state = 0;
 
void setup()
{
Serial.begin(9600);
radio.begin();
Serial.print("ADDRESS :");
radio.openReadingPipe(0, address);   //Setting the address at which we will receive the data
radio.setPALevel(RF24_PA_MIN);       //You can set this as minimum or maximum depending on the distance between the transmitter and receiver.
radio.startListening();              //This sets the module as receiver
}
void loop()
{
if (radio.available())              //Looking for the data.
{
Serial.println("Radio is sniffing");
  
char text[32] = "";                 //Saving the incoming data
radio.read(&text, sizeof(text));    //Reading the data
Serial.println(text);
}
}

After uploading code on both the microcontroller, you can open both Serial Monitor. It will display the Sender and Receiver data with the Packet number.




Sending Sensor Data Wirelessly to Receiver using NRF24L01 & STM32

Let us go through the second example now. In this example, we will be Interfacing NRF24L01 with STM32 and BME280 sensor to the Sender Circuit. You can connect a BME280 Barometric Pressure Sensor to the Sender Circuit. The Sensor uses I2C Protocol for communication and measures the environmental temperature, humidity, Atmospheric Pressure, and Altitude. Below is the circuit of the transmitter.

The Sensor works on I2C Protocol so its I2C Pins, i.e SDA & SCL is connected to PB7 & PB6 respectively. We will send the BME280 Sensor reading wirelessly from STM32 NRF24L01 Sender to STM32 NRF24L01 Receiver.

Sender Code

The Sender Circuit requires a BME280 Library. You can get the library from this link: BME280 Library. Add the library to the Arduino Library folder.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#include <nRF24L01.h>
#include <RF24.h>
 
RF24 radio(PB0, PA4); // CE, CSN on Blue Pill
const uint64_t address = 0xF0F0F0F0E1LL;
int counter = 0;
 
 
float temperature;
float humidity;
float altitude;
float pressure;
 
#define SEALEVELPRESSURE_HPA (1013.25)
 
Adafruit_BME280 bme;
 
struct MyData
{
  int counter;
  float temperature;
  float humidity;
  float altitude;
  float pressure;
};
MyData data;
 
void setup()
{
Serial.begin(9600);
radio.begin();                  //Starting the Wireless communication
radio.openWritingPipe(address); //Setting the address where we will send the data
radio.setPALevel(RF24_PA_MIN);  //You can set it as minimum or maximum depending on the distance between the transmitter and receiver.
radio.stopListening();          //This sets the module as transmitter
 
if (!bme.begin(0x76))
{
    Serial.println("Could not find a valid BME280 sensor, check wiring!");
    while (1);
  }
 
}
 
void loop()
{
  data.counter = counter;
  data.temperature = bme.readTemperature();
  data.pressure = bme.readPressure() / 100.0F;
  data.altitude = bme.readAltitude(SEALEVELPRESSURE_HPA);
  data.humidity = bme.readHumidity();
  
  Serial.print("Packet No. = ");
  Serial.println(data.counter);
  
  Serial.print("Temperature = ");
  Serial.print(data.temperature);
  Serial.println("*C");
 
  Serial.print("Pressure = ");
  Serial.print(data.pressure);
  Serial.println("hPa");
 
  Serial.print("Approx. Altitude = ");
  Serial.print(data.altitude);
  Serial.println("m");
 
  Serial.print("Humidity = ");
  Serial.print(data.humidity);
  Serial.println("%");
 
  Serial.println();
  
  radio.write(&data, sizeof(MyData));
  
  Serial.println("Data Packet Sent");
  Serial.println("");
  
  counter++;
  delay(3000);
}


Receiver Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
 
RF24 radio(PB0, PA4); // CE, CSN on Blue Pill
const uint64_t address = 0xF0F0F0F0E1LL;
 
struct MyData
{
  int counter;
  float temperature;
  float humidity;
  float altitude;
  float pressure;
};
MyData data;
 
void setup()
{
Serial.begin(9600);
radio.begin();
Serial.print("ADDRESS :");
radio.openReadingPipe(0, address);   //Setting the address at which we will receive the data
radio.setPALevel(RF24_PA_MIN);       //You can set this as minimum or maximum depending on the distance between the transmitter and receiver.
radio.startListening();              //This sets the module as receiver
}
 
int recvData()
{
  if ( radio.available() )
  {
    radio.read(&data, sizeof(MyData));
    return 1;
    }
    return 0;
}
 
 
void loop()
{
  if(recvData())
  {
 
  Serial.println("Data Received:");
  Serial.print("Packet No. = ");
  Serial.println(data.counter);
  
  Serial.print("Temperature = ");
  Serial.print(data.temperature);
  Serial.println("*C");
 
  Serial.print("Pressure = ");
  Serial.print(data.pressure);
  Serial.println("hPa");
 
  Serial.print("Approx. Altitude = ");
  Serial.print(data.altitude);
  Serial.println("m");
 
  Serial.print("Humidity = ");
  Serial.print(data.humidity);
  Serial.println("%");
 
  Serial.println();
  }
}

After uploading code, you can open Serial Monitor. The Serial Monitor will display the transmitted and received data.

You can make the Wifi Gateway to post the data to the Server. Here is an example post for doing this: STM32 NRF24L01 Sensor Node with ESP32 NRF24L01 Gateway

Share. Facebook Twitter Pinterest LinkedIn Tumblr Email Reddit Telegram WhatsApp
Previous ArticleBlynk Controlled WS2812B Neopixel LED Strip with NodeMCU
Next Article STM32 NRF24L01 Sensor Node with ESP32 NRF24L01 Gateway

Related Posts

PIR Motion Detection using Bluetooth & STM32 Board

PIR Motion Detection using Bluetooth & STM32 Board

Updated:December 23, 20234K
STM32 SHT85 Humidity Temperature Sensor

Collecting SHT85 Sensor Data using STM32 & Bluetooth Low Energy

Updated:August 20, 20222K
SX1276 STM32

Interfacing LoRa SX1276 with STM32 Microcontroller | LR1276-915MHz

Updated:May 29, 2023112K
BLE enabled Smart Bulb with STM32 & Javascript

BLE enabled Smart Bulb with STM32 & Javascript

Updated:August 20, 20222K
Create BLE Project using STM32 Microcontroller & BlueIO

Create BLE Project using STM32 Microcontroller & BlueIO

Updated:August 20, 202212K
DS18B20 STM32

Interfacing DS18B20 Temperature Sensor with STM32

Updated:August 21, 2022110K
View 2 Comments

2 Comments

  1. geordi on December 5, 2021 9:02 PM

    what is the point of using stm 32 if we need arduino? I want to do it with cubeide

    Reply
  2. ali demir on December 31, 2022 6:55 AM

    could you find how to do

    Reply

CommentsCancel reply

Latest Posts
IoT Based PM & Air Quality Monitoring System using ESP32

IoT Based PM & Air Quality Monitoring System using ESP32

May 31, 2026
DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

May 10, 2026
IoT Activity Tracker with ESP32 & Accelerometer Gyroscope

IoT Activity Tracker with ESP32 & Accelerometer/Gyroscope

May 2, 2026
A Guide to Sourcing Obsolete ICs for Vintage Projects

Beyond AliExpress: A Guide to Sourcing Obsolete ICs for Vintage Projects

April 21, 2026

ESP32 IoT Vehicle Motion Analyzer with MPU6050 & LIS3MDL

April 27, 2026
Building a Smart Sensor Node with a BLE Microcontroller

Building a Smart Sensor Node with a BLE Microcontroller

February 26, 2026
High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

April 27, 2026
DIY Colorimeter using AS7265x Spectroscopy Sensor & ESP32

DIY Colorimeter using AS7265x Spectroscopy Sensor & ESP32

February 1, 2026
Top Posts & Pages
  • Buck Converter: Basics, Working, Design & Application
    Buck Converter: Basics, Working, Design & Application
  • How to use INA226 DC Current Sensor with Arduino
    How to use INA226 DC Current Sensor with Arduino
  • 12V DC to 220V AC Inverter Circuit & PCB
    12V DC to 220V AC Inverter Circuit & PCB
  • Designing of MPPT Solar Charge Controller using Arduino
    Designing of MPPT Solar Charge Controller using Arduino
  • How to use Modbus RTU with ESP32 to read Sensor Data
    How to use Modbus RTU with ESP32 to read Sensor Data
  • IoT Based ECG Monitoring with AD8232 ECG Sensor & ESP32
    IoT Based ECG Monitoring with AD8232 ECG Sensor & ESP32
  • Boost Converter: Basics, Working, Design & Application
    Boost Converter: Basics, Working, Design & Application
  • IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
    IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
Categories
  • Arduino Projects (197)
  • Articles (60)
    • Learn Electronics (19)
    • Product Review (15)
    • Tech Articles (28)
  • Electronics Circuits (46)
    • 555 Timer Projects (21)
    • Op-Amp Circuits (7)
    • Power Electronics (13)
  • IoT Projects (204)
    • ESP32 MicroPython (7)
    • ESP32 Projects (81)
    • ESP32-CAM Projects (15)
    • ESP8266 Projects (76)
    • LoRa/LoRaWAN Projects (22)
  • Microcontrollers (38)
    • AMB82-Mini IoT AI Camera (4)
    • BLE Projects (18)
    • STM32 Projects (19)
  • Raspberry Pi (93)
    • Raspberry Pi Pico Projects (57)
    • Raspberry Pi Pico W Projects (12)
    • Raspberry Pi Projects (24)
Follow Us
  • Facebook
  • Twitter
  • Pinterest
  • Instagram
  • YouTube
About Us

“‘How to Electronics’ is a vibrant community for electronics enthusiasts and professionals. We deliver latest insights in areas such as Embedded Systems, Power Electronics, AI, IoT, and Robotics. Our goal is to stimulate innovation and provide practical solutions for students, organizations, and industries. Join us to transform learning into a joyful journey of discovery and innovation.

Copyright © How To Electronics. All rights reserved.
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us

Type above and press Enter to search. Press Esc to cancel.

Ad Blocker Enabled!
Ad Blocker Enabled!
Looks like you're using an ad blocker. Please allow ads on our site. We rely on advertising to help fund our site.