Code crashes on line, tried to fix added image of serial monitor

I have the rf24 library by TMRh20
i put print statements in for debugging

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

RF24 radio(7,8);

const byte address[6] = "00001";

void setup() {
  Serial.begin(9600);  //Baud rate
  
  radio.begin();
  radio.openWritingPipe(address);
  radio.setPALevel(RF24_PA_MAX);
  radio.setDataRate(RF24_250KBPS);
  radio.stopListening();
  
  Serial.println("void setup done");
  Serial.println("e");
}

void loop() {
  Serial.println("void loop run");
  const char text[] = "nrftest";
  Serial.println("1 test");
  radio.write(&text, sizeof("nrftest"));   //crashes here
  Serial.println("2 test");
  delay(2000);
  Serial.println("sent");
}

Might miss a openWritingPipe()
Use
radio.write(text, sizeof text); // or strlen(text) but won’t send the trailing null char


sorry.
its not working.

I can’t see the openWritingPipe which is possibly hidden behind an image of text…

Time to do yourself a favour and read How to get the best out of this forum an post accordingly (including code tags and necessary documentation).

There are also countless tutorials on getting the basics to work, try that to ensure your setup is ok.

Note that Serial.print() is buffered. You may be getting the wrong idea of where the crash occurs. Add "Serial.flush();" after each debug message to make sure the message gets sent before the crash.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.