nrf24l01 - Debugging / test code.

Hi all

I have the two radio modules kinda working, the RX does pick up the odd transmission here and there so it kinda works, i suppose that's down to the lack of available current. Swapped the TX and RX over, same symptoms.

Anyway.. thats not my main issue.

To work out whats going on / test signal etc, i want to send some dynamic strings:
Here 1
Here 2
Here 3
Here 4

etc.

This is the code I currently have:

int Count = 0;

void loop(void){
  //digitalWrite(LED, HIGH);
  const char text[] = "Here " +String(Count);
  
  radio.write(&text, sizeof(text));
  Serial.print("Data Sent: ");
  Serial.println(text);
  Count++;
  delay(1000);
  //digitalWrite(LED, LOW);
}

Seems logical to me!

But this is the error I get:
exit status 1
initializer fails to determine size of 'text'

Tried:
const char text = "Here " +char(Count);

Same thing.

Tried:
Msg = "Here " +String(Count);
const char text = Msg;

Same error!

Also tried:
const char text = Msg;
const char text = char(Msg)
char text = Msg;;
String text = Msg;

I JUST want to add a number to the end of the string. It's a doddle in any other language.

How do I make this work?

char text[10];
sprintf(text,"Here %d",Count);

Thanks.

Is that the only way though? - Seems a bit daft that you can't write dynamic strings...

You can, if you use String objects. But since they do dynamic memory allocation, they're risky business on most Arduinos because they have so little RAM.

Have a look at this Simple nRF24L01+ Tutorial.

Wireless problems can be very difficult to debug so get the wireless part working on its own before you start adding any other features.

The examples are as simple as I could make them and they have worked for other Forum members. If you get stuck it will be easier to help with code that I am familiar with. Start by getting the first example to work

...R

Hi Robin

Thanks for that, another member has already pointed me to your most excellent guide.

Do I need the 10uF cap on the RX as well as the TX?

I’ve read many saying the nano can’t provide enough juice for these RF modules yet i’ve found many tutorials online that don’t say anything about this - some will mention a cap, others won’t!

Thanks,

Twixy

Twixy:
Do I need the 10uF cap on the RX as well as the TX?

It is on neither. It should go across the Vcc and GND pins of the nRF24.

I've read many saying the nano can't provide enough juice for these RF modules yet i've found many tutorials online that don't say anything about this - some will mention a cap, others won't!

I don't have a nano so I have no personal experience but I believe that it cannot supply enough 3.3v current. At least for testing try powering the nRF24 with a pair of AA alkaline cells (3v) with the battery GND connected to the Arduino GND,

...R

Robin2:
It is on neither. It should go across the Vcc and GND pins of the nRF24.

Sorry my mistake in the way i was describing..

I didn't mean the TX / RX pins, I mean the TX and RX modules. Does the RX transceiver need the 10uF cap if it is only used as a receiver?

Sorry for the confusion and thanks for your help so far :slight_smile:

Twixy:
Does the RX transceiver need the 10uF cap if it is only used as a receiver?

Both. In normal use both devices need to transmit - the receiver transmits an acknowledgement.

...R