Exploring the World of Wireless Communication: My Journey with the NRF24 Module
Have you ever wondered about the inner workings of these wireless connections or how you could create your own wireless communication system? That’s where the NRF24 module comes into play. The NRF24 module is a small, affordable, and versatile piece of hardware that allows you to establish wireless communication between various electronic devices. Whether you’re an electronics hobbyist, a DIY enthusiast, or just curious about the world of wireless technology, this blog will introduce you to the fascinating world of NRF24 modules.
These modules are transceiver modules. That means same module can act as both transmitter and receiver.
Let’s see some features of nrf24 modules
- Low Power Consumption
Typically operates at 3.3V, but can support a voltage range of 1.9V to 3.6V. And best of all, it consumes 26 μA in standby mode and 900 nA at power down mode. So, they’re the best wireless devices for low-power applications. ( Refer datasheet more details : https://www.nordicsemi.com/products/nrf24-series )
2. Adjustable Parameters
Data Rate: You can configure data rates as 250 kbps, 1 Mbps, and 2 Mbps.
Transmit power: Adjustable transmit power levels ranging from -18 dBm to 0 dBm (in 6 dBm steps). Maximum output power is typically 0 dBm (1 mW).
RF Channels: 126 available RF channels to choose from for communication.
3. Supports SPI protocol.
The NRF24L01 module and microcontrollers like Arduino communicate with each other using the Serial Peripheral Interface (SPI) protocol. This protocol commonly used to transfer data between microcontrollers, sensors, memory devices, and other peripheral devices.
4. It operates in the 2.4 GHz ISM band
ISM stands for “Industrial, Scientific, and Medical.” It’s a frequency band that has been reserved by regulatory bodies in many countries for non-licensed use. That’s means you can freely use these frequencies for communication. The NRF24 module operates at a specific frequency within the ISM band, which is 2.4 gigahertz (GHz). This frequency range is also commonly used by other wireless technologies, such as Wi-Fi, Bluetooth, and some microwave ovens.
Now let’s see how to establish a connection between two nrf24 modules. For that what you just need is two nrf4 modules and two microcontrollers (Eg: Arduino uno).
First you have to connect pins of the nrf24 module to the microcontroller accordingly. ( Refer this : https://projecthub.arduino.cc/tmekinyan/how-to-use-the-nrf24l01-module-with-arduino-813957).
Then you can upload the code for both transmitter and receiver.
Transmitter code.
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(9, 10); // CE, CSN
void setup() {
radio.begin();
radio.openWritingPipe(0xF0F0F0E1LL); // Set the address for the receiver
radio.setPALevel(RF24_PA_LOW); // Set the power level low to conserve energy
radio.stopListening(); // Put the radio in transmit mode
}
void loop() {
char text[] = "Hello, World!";
radio.write(&text, sizeof(text)); // Send the message
delay(1000); // Send every 1 second
}
Receiver code :
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(9, 10); // CE, CSN
void setup() {
Serial.begin(9600);
radio.begin();
radio.openReadingPipe(1, 0xF0F0F0E1LL); // Set the same address as the transmitter
radio.setPALevel(RF24_PA_LOW); // Set the power level low to conserve energy
radio.startListening(); // Put the radio in receive mode
}
void loop() {
if (radio.available()) {
char text[32] = "";
radio.read(&text, sizeof(text)); // Read the incoming message
Serial.println(text);
}
}
Here what we have done is sending a text message called “hello word” continuously within a one second delay. In the receiver’s end we are waiting for message and when we receive it, we print it on the serial monitor.
Not only just text messages but also you can do audio transmission as well. For that you can use an audio handling library such as RF24Audio.We have developed a Miner Safety Helmet for our first-year hardware project. There we have enabled two-way voice communication between two stations using nrf24 modules. If you are interested in how we have handled audio transmission feel free to refer this. ( https://github.com/isuruij/Miner-Safety-Helmet )