Budiy • Upvote 0 • Downvote 0

Repair unstable NRF24+PA+LNA communication module

NRF24 is a module that can be used by Wireless Sensor Node (WSN) devices to send data offline using radio communication. The frequency used by the NRF24 module is the same as the WiFi frequency which is 2.4 GHz. This module is very popular because the price is the lowest compared to modules with other brands. However, this module has a high level of communication instability. Currently, there are two NRF24 versions, the first without an antenna (NRF24) and the version with an additional antenna (NRF24+PA+LNA). Based on the datasheet, the version without antennas can only communicate within a few meters, whereas in versions with additional antennas it can reach 1 kilometer.


Next, I tried to test NRF24 communication connected to Arduino Nano. Based on the data sheet, the NRF24 module works at a voltage of 2.7 to 3.6 Volts. Therefore, I use a Voltage Regulator so that the voltage received by NRF24 is stable at 3.3 Volts. I use a 5 Volt 2 Ampere power adapter to power the Arduino. The voltage regulator is connected to the 5V Vout pin of Arduino so that the Voltage Regulator will reduce the voltage from 5 Volts to 3.3 Volts. After trying to do a simple communication test it turns out that communication on the NRF24+PA+LNA module is still not stable. Then finally I was interested in finding out the cause of the unstable NRF24 communication.


Here is the code for the communication test on NRF24:

Transmitter:

#include <SPI.h>
#include <RF24.h>
const byte alamat[5] = {'s','e','t','a','n'};
RF24 radio(9, 10);
char dataDikirim[1]="0";
int nomer=0;
String tampung="";
unsigned long waktuSaatini;
unsigned long waktuSebelumnya;
unsigned long rentang=1000;
void setup(){
Serial.begin(9600);
Serial.println("mulai Transmitter");
radio.begin();
radio.setDataRate(RF24_250KBPS);
radio.setRetries(15,15);
radio.setPALevel(RF24_PA_MIN);
radio.openWritingPipe(alamat);
}
void loop(){
waktuSaatini=millis();
if (waktuSaatini-waktuSebelumnya>=rentang){
kirim();
waktuSebelumnya=millis();
}
}
void kirim(){
bool rslt;
rslt=radio.write(&dataDikirim, sizeof(dataDikirim));
Serial.print("Mengirim data");
Serial.print(dataDikirim);
if(rslt){
Serial.println("menerima ACK");
nomer+=1;
if(nomer>9){
nomer=0;
}
tampung.concat(nomer);
dataDikirim[0]=tampung.charAt(0);
}else{
Serial.println("Pengiriman gagal");
}
}

Receiver:

#include <SPI.h>
#include <RF24.h>
const byte alamat[5]={'s','e','t','a','n'};
RF24 radio(9, 10);
char dataDiterima[1];
bool dataBaru=false;
void setup(){
Serial.begin(9600);
Serial.println("mulai Receiver");
radio.begin();
radio.setDataRate(RF24_250KBPS);
radio.setPALevel(RF24_PA_MIN);
radio.openReadingPipe(1, alamat);
radio.startListening();
}
void loop(){
if(radio.available()){
radio.read(&dataDiterima, sizeof(dataDiterima));
dataBaru=true;
}
if(dataBaru==true){
Serial.print("Menerima data ");
Serial.println(dataDiterima);
dataBaru=false;
}
}

When I first opened the Serial Monitor I saw that the PA level was at PA_MAX, after that I closed the serial monitor. One to three seconds later I try to reopen the serial monitor and the PA status level changes to PA_MIN. I am confused and think why the PA level has changed. I close the serial monitor again and 1-3 seconds later I open the serial monitor and the PA level changes to PA_HIGH. After opening and closing the Serial Monitor several times, the PA level status sometimes has a fixed value and sometimes it keeps changing. So it can be concluded that power is the main problem of communication instability in the NRF24 module.


This is the code to check the PA level status in NRF24 module:

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <printf.h>
#define CE_PIN 9
#define CSN_PIN 10
const uint64_t pipe=0xD4D4F0E0C1LL;
RF24 radio(CE_PIN, CSN_PIN);
void setup() {
Serial.begin(9600);
printf_begin();
Serial.print("\nCek Koneksi\n");
radio.begin();
radio.printDetails();
Serial.print("\n\n\n");
Serial.print("Konfig 250KBPS");
Serial.print("\n");
radio.openReadingPipe(1, pipe);
radio.setChannel(115);
radio.setPALevel(RF24_PA_MAX);
radio.setDataRate(RF24_250KBPS);
radio.printDetails();
}
void loop() {
}

Previously I also used the NRF24 module version without antenna and communication was also unstable. The solution to overcome the communication instability in the NRF24 module version without antenna can be fixed easily by adding 1 capacitor with a capacity of 10 uF 50 Volts. However, this solution still does not work well on the NRF24 module version with additional antennas (NRF24+PA+LNA). After several attempts, I was finally able to make the NRF24+PA+LNA module very stable. My solution is to add three capacitors to the NRF24 module. The three capacitor specifications used are as follows:


10 uF 50 Volts (electrolytic)
10 uF 25 Volts (electrolytic)
0.1 uF 50 Volts (electrolytic)

Three capacitors are installed in parallel. The code above uses the NRF24 library from TMRh20 and the Serial Peripheral Interface (SPI) pins used are pin 9 and pin 10. An example of the results of adding a capacitor to NRF24 can be seen below.


repair unstable nrf24
repair unstable nrf24

That is all. May be useful.

You must be logged in to reply to this thread
More Articles from Budiy
kode program komputer
How to update Kali Linux to the latest version using 1 line of command code

Before updating the Kali Linux operating system, make sure you are logged in as a root user. The default username and password for the root user in Kali Linux are as follows: username : root password : toor [file]image/226[/file] This is the...


Author: sadboy