Go Down

Topic: Using nRF24 Receiver, radio.available() function is not returning "True" (Read 188 times) previous topic - next topic

iPankaj

I am sending alphabets 'A', 'B', 'C' and 'D'  using four push buttons at the transmitter side using nRF24L01 module and Arduino uno as Hardware on both the sides (Tx and Rx).

At transmitter side  I am getting the acknowledgement that the alphabet is sent to the given pipe01 But
at  Receiver side, radio.available() function is not returning "True".
I am facing this problem since 3 days. I have tried many possibilities and the codes which are available online.

(PS: i am using TMRH20 RF24 library)
here i am attaching transmitter code, receiver code with screenshots of outputs i am getting on serial monitor.

Please post the suggestions as soon as possible.
thanks....

Robin2

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


This is a crazy way to send data
Code: [Select]
    if (buttonA != lastButtonStateA)           // to write the alphabet only when the state of the button changes
    {
      if (buttonA == HIGH)
      {
        x[0] = ('A');                        //delay(50);
      }
      lastButtonStateA = buttonA;
      radio.write(&buttonA,sizeof(buttonA) );  //sizeof(buttonA)
    }

    else if(buttonB != lastButtonStateB)
    {
      if(buttonB == HIGH)
        {x[0]= 'B';}
        lastButtonStateB = buttonB;
        radio.write(&buttonB, sizeof(buttonB));
    }

    // etc
 


Use your buttons to update a single variable and then send that. There is no need to send the data from a different variable for each button.

It would probably also be a good idea to send the values for every button in each message - even if the data does not change. That would make it easier for the receiver to identify which value is for which button.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

iPankaj

Thanks for the reply,
i had been through that link already...here i could not understand how can i operate and send data from  four different buttons by using one variable only, please guide me through this...
and why in my case, receiver is not acknowledging any data even when the data is sent?
Thanks !

Robin2

Suppose you have an array
Code: [Select]
byte buttonStates[4] = {0,0,0,0};

Then your code could be

Code: [Select]
buttonStates[0] = digitalRead(button0pin);
buttonStates[1] = digitalRead(button1pin);
// etc


and your sending code would be

Code: [Select]
result = radio.write(&buttonStates, sizeof(buttonStates));

I have not allowed for de-bouncing, but the above should give you the idea

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

iPankaj

Thanks again for helping me out sir...

sir,  i want the receiver to receive data from multiple transmitters. as I know nRF24 receiver can receive the data from 6 pipes or from 6 transmitters, Is there any way by which we can receive the data from more than 6 transmitters using one receiver as nRF24l01 module?

1 transmitter=> will have 4 push buttons and they will return 'A', 'B', 'C', 'D' from those buttons (when the button is pressed)

Robin2

In my tutorial there is an example with a master and 2 slaves. It could be extended to a large number of slaves.

You will note that my example only uses 1 or 2 pipes (can't remember which). One reason for using multiple pipes is so that the receiver can identify who sent the message. IMHO it is easier to do that by including an ID code in each message. And that frees you from any limitation on the number of slaves.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

Go Up