In my project I'm going to connect 5 sub units to a main unit via RF transceivers. I'm using NRF24l01 transceivers with Arduino mega for main unit and Uno for sub units.I have tried many ways with various libraries**(RF24,NRF24L01,etc...)** but couldn't come up with a working one for bi direction .there are many transmitter and receiver codes. Most of codes that i tried work but the case is they all are only one way connections.but i couldn't combine them to work as a bi directional link. some ppl said that use of IRQ pin as a interrupt. any how i need all the sub units to receive all the data sent from the main unit and transmit data when needed,and same time main unit to transmit all the data need to be sent and receive data sent by sub units.I saw some codes using two pipes to receive and transmit but still i can't figure it out to work.
If any one have a idea please help me with this.please.
Sounds like a great project. I love working with the nRF24L01. You do have to use two pipes to communicate bi-directional.
Key elements:
#include "nRF24L01.h"
#include "RF24.h"
RF24 radio(PIN9_RF_CE, PIN10_CS); // make sure this corresponds to the pins you are using
// NOTE: the "LL" at the end of the constant is "LongLong" type
// const uint64_t pipes[2] = { 0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL };
const uint64_t pipes[4] = { 0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL, 0xE8E8F0F0E1LL, 0xE8E8F0F0D2LL };
void setup() {
// Setup and configure rf radio
radio.begin();
// Start listening
radio.startListening();
}
void loop() {
if ( radio.available() )
{
radio.read( _rxDataObject, sizeof(rxDataObject) );
// do something with the data?
}
// use a timer here or some other trigger...
radio.stopListening();
for (; sensor != NULL; sensor = sensor->next )
{
// we need data to sent...
setDataObject( &txDataObject, sensor );
// radio stuff
radio.write( &txDataObject, sizeof(txDataObject) );
// serial print received data
printDataObject( &txDataObject );
// end of serial printing
delay(50);
}
// end of radio stuff
radio.startListening();
}
but what are the 2 pipes you have used. are rxDataObject,txDataObject??
As i see u didn't create those. how ever thank you very much for ur idea.
i have another problem, do you have any idea how to use the IRQ(8 pin of tansceiver)..
data sheet shows that it can be used to get 3 types of interrupts.
i need to take the interrupt when data received to the main unit. it always transmit the data and when it received data it trigger the IRQ pin with interrupt then read data,again it goes to transmit mode. i know that it is possible but i don't know how to do it. how we can setup it. any idea????