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");
}
J-M-L
December 12, 2021, 5:15pm
2
Might miss a openWritingPipe()
Use
radio.write(text, sizeof text); // or strlen(text) but won’t send the trailing null char
J-M-L
December 12, 2021, 5:30pm
4
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.
system
Closed
June 11, 2022, 3:11pm
6
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.