Today i got a strange issue while programming an Arduino with RF24 Radio.
I was using Serial.print in the main loop to debug code. Found that whenever the radio.read() command was used and after that a new Serial.print command was given the arduino completely resets.
Have tried everything, other arduino, new radio module, delay before Serial.print, etc.
I know for sure that the radio is receiving information correctly. I have sent several values from an other radio module and one of them should make pin 5 high. That happend correctly. When pasting the code that make pin 5 high behind the Serial.print line nothing happend. (i deleted that part of pin 5 in my example code)
What i want is that the arduino can Serial.print the received intensity values so i can read them. It’s that simple…
Hope you can help me out,
Thanks in advance!
//----------------------------------------------------- LIBRARY CODE -----------------------------------------------------\\
#include <SPI.h>
#include "RF24.h"
//----------------------------------------------------- LIBRARY CODE -----------------------------------------------------\\
RF24 radio(7,8);
byte addresses[][6] = {"1Node","2Node"};
int intensity = 0;
void setup() {
Serial.begin(115200);
Serial.println("Setup reset");
radio.begin();
radio.setPALevel(RF24_PA_LOW); // Set the PA Level MAX (>250m)
radio.openWritingPipe(addresses[1]); // Open communication Pipe 1
radio.openReadingPipe(1,addresses[1]); // Listen on communication Pipe 1
radio.openReadingPipe(2,addresses[0]); // Listen on communication Pipe 2
radio.startListening();
}
void loop() {
if(radio.available()){
while(radio.available()) {
radio.read( &intensity, sizeof(unsigned long) );
}
radio.stopListening();
Serial.print("Hello World");
radio.startListening();
}
}