1

I have been trying to get the NRF24L01 to transmit the "hello World", Though the devices are talking to each other they are reading scrambled data. I have looked everywhere for support but unfortunately tried solutions as much as I can. I have attached the code below and the output.

The steps for fixing from my side:

  • Checked the wiring
  • rechecked the code and the address
  • Used a capacitor
  • Changed the baud rate to the transceiver specification and random baud rates

I need a new perspective please help!!

Transmitter:

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

RF24 myradio(7, 8); // CE, CSN

const byte address[6] = "00001";

void setup() {
  myradio.begin();
  myradio.openWritingPipe(address);
  myradio.setPALevel(RF24_PA_MIN);
  myradio.stopListening();
}

void loop() {
  const char text[] = "Hello World";
  myradio.write(&text, sizeof(text));
}

Receiver:

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

RF24 myradio(7, 8); // CE, CSN

const byte address[6] = "00001";

void setup() {
  Serial.begin(9600);
  myradio.begin();
  myradio.openReadingPipe(0,address);
  myradio.setPALevel(RF24_PA_MIN);
  myradio.startListening();
}

void loop() {
  if (myradio.available()) {
    char text[32] = " ";
    myradio.read(&text, sizeof(text));
    Serial.println(text);
  }
}

I would like to add I have some basic knowledge of Arduino.

Output: ?????????????????????????????????/

????????????????????

??????????????????????????????????

???????????????????????

1
  • something weird happened, I made it work now it appears when I used a 3.3 V regulator and connected the VCC to the 5V supply of the Arduino it worked. I tried it again after 3 hrs it stopped working again but the connections were the same. I tried different wiring it didn't work. What could be the cause of the issue now?
    – user85289
    Jun 1 at 6:32

1 Answer 1

0

Your problem is in the usage of &text. text is a pointer to a block of memory with text in it. Thus &text is a pointer to the variable that stores the pointer to the block of memory that stores the text.

That is, for example:

  • "Hello world" is stored starting at address 10.
  • text is a variable stored at addresses 20 and 21 (it's two bytes to store the address of Hello world)
  • Using text gives you 10 but using &text gives you 20.

Since text is already a pointer you just need to cast it to the right type of pointer for the target function (uint8_t * possibly).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.