Hello everyone, hope you are having a good day/night.
Whenever I use this type of nrf24l01 (the one with the antennas) it works:
But when I use this type it doesn't work, meaning it does not function, if it is a receiver it just prints out " " (even when the transmitter is off) or if it is a transmitter it does not transmit.
I tried them as receiver and transmitter but they never worked (they don't transmit or receive, because when I switch the nrf24l01 module to the nrf24l01+ PA + LNA it starts working again immediately.
This is my code (transmitter):
//Include Libraries
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
//create an RF24 object
RF24 radio(9, 8); // CE, CSN
//address through which two modules communicate.
const byte address[6] = "00001";
void setup() {
radio.begin();
//set the address
radio.openWritingPipe(address);
//Set module as transmitter
radio.stopListening();
}
void loop() {
unsigned int randNumber = random(1, 9999);
Serial.println(randNumber);
radio.write(&randNumber, sizeof(randNumber));
delay(20);
}
This is just the code that receives it. It has nothing to do with what I'm asking I'm just providing it to understand the transmitter code more (the code below is working fine.
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
// Create an RF24 object
RF24 radio(9, 8); // CE, CSN
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire);
// Address through which two modules communicate
const byte address[6] = "00001";
void setup() {
Serial.begin(9600);
// Initialize RF24 module
radio.begin();
// Set the address
radio.openReadingPipe(0, address);
// Set module as receiver
radio.startListening();
// Initialize OLED display
if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println("OLED initialization failed!");
while (true)
; // Stop execution if OLED fails
}
display.clearDisplay();
display.display();
}
void updateDisplay(unsigned int data) {
display.clearDisplay();
display.setTextSize(2);
display.setCursor(0, 16);
display.setTextColor(WHITE, BLACK); // Avoid full screen clearing to reduce flicker
display.print("data: ");
display.println(data);
display.display();
}
void loop() {
// Check if RF24 has received data
if (radio.available()) {
unsigned int data = 0;
radio.read(&data, sizeof(data)); // Read as unsigned int
updateDisplay(data);
}
}
I even tried using the nrf24l01 adapter that looks something like this:
No matter what distance I tried it never worked, and by didn't work I mean it does not transmit or receive anything. I am using room temperature to power the device which is about 28°C or 82°F, I'm using an Arduino nano to control the nrf24l01 modules.



