nRF24L01 and Arduino

Hi all,

I am trying to use the nRF24L01 and Arduino Uno on a project.
I have been trying to read from the radio on line 41 after the 'break' and compare the 'level' value with the character 'e'.
On starting, the program wait to receive the character '1' from the transmitting node then print the 'number'.
I want the program to check the radio for 'level' at each iteration and if the 'level' value received is 'e' print the message 'ok'.

At the moment, my code included here gives me this output with no change when I send 'e' or any other character from the transmitter.

Receiver
iB: 49
Number: 1
level:
.
.
.
.
etc

Thanks for the help.

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

RF24 radio(5, 6); //CSE and CE of the wifi module

int number=0;
int iB = 0;
char level = 0;
int i=0;
const byte rxAddr[6] = "00001"; //Communication channel for the nRF24L01
void setup()
{
   Serial.begin(9600);// 
  //-------nRF24L01-----
  radio.begin(); //Start the nRF24L01 module
  radio.openReadingPipe(0, rxAddr); //Open channel
  radio.startListening();//Await for data
  Serial.println("Receiver"); //This is the receiver
}

void loop()
{
  while (radio.available()>0) 
	{
		radio.read(&iB, sizeof(iB));
		Serial.print("iB: ");
		Serial.println(iB);
		
		{
  while(iB==49) //49, 50, 51 are equal 1, 2 and 3 respectively
				{
					for(int i=0; i<=30; i++)        
					   {
						  number=number+1;
						  Serial.print("Number: ");
						  Serial.println(number);
						  delay(50);
						   break;
					  
				            }
				    radio.read(&level, sizeof(level));
				    delay(50);
				    Serial.print("level: ");
				    Serial.println(level);
					
				    if(level=='e')
						{
						 Serial.println("ok");
						}  

				}
		}
	}
}

Are you saying that it always shows iB: 49?

If so it seems like the problem is in the transmitter - but you have not posted that code.

I got my NRF24s to work using this tutorial - have you tried it?

...R

No, because this node is set to start only if 1 (ASCII=49) is type into the remote serial. All works except the interrupt while in the for loop.
I will loop into the tutorial to see if it helps.
Thanks

suluku:
No, because this node is set to start only if 1 (ASCII=49) is type into the remote serial.

I cannot relate this to my Reply #1

except the interrupt while in the for loop

In programming an interrupt is a very specific thing and you don't have one in your program.

...R

Hi Robin2
Thanks for the clarification :slight_smile:

So there are two nodes:

Node 1: Only send whatever character is typed into its serial port to the second node through the nRF.
i.e When 1 is sent the main loop starts as in the code shown above.

Node 2: Runs the code posted here above.

I will be looking toward using flags to move within the program.

suluku:
Hi Robin2
Thanks for the clarification :slight_smile:

Sorry, but still as clear a mud.

There are 3 short sentences in my Reply #1

If you respond clearly to each one of them we may be able to move forward.

...R