nRF24L01 project guidance.

Hello guys,

I am working on the project of designing a transceiver network. I am using 4 Arduino Uno boards and 4 nRF24l01 transceivers. In my network, thyere will be one transceiver at the base station and other 3 transceivers will be connected to the base station in star network. Now my project has these scenarios. It is described below.

(1) The text message will be broadcast from transceiver at the base station. So basically I should type the message in the serial monitor of Arduino and when I press send it will broadcast the message. Each transceiver should have unique id.
(2) Now any transceiver at the receiver end should reply back. So it will be case like real time chatting with base station.

Based on the these scenarios I want help with coding. I am new to the programming. I have found some examples of basic transmitting and receiving code. But in those examples, the message is written in the code. I want want to do real time chatting between two boards. Also How can I broadcast the message.

Please if anyone can help me with the code, it would be grate. Its quite urgent.

Thank you.

Have you gotten 2 radios to talk to each other?

HI,
Have you googled?

network nRF24l01

See what comes back?

Tom ...... :slight_smile:

I was trying a simple chat example using 2 nRF24L01 and two Arduino Uno boards. My code is as below. I am getting some errors. When I run code I am getting errors as below.

//
nRF24_Serial_Chat.ino: In function 'void nRF_receive()':

nRF24_Serial_Chat:110: error: void value not ignored as it ought to be
//

I have shared the code.
Please guys help me to get rid of the error. Its urgent.

/*
nRF Serial Chat

this simple interactive serial chat over nRF that can be used for both sender
and receiver as I swapped the TX & RX addr during read/write operation.

It read input from Serial Monitor and display the output to the other side
Serial Monitor or 16x2 LCD (if available)... like a simple chat program.

Max payload is 32 bytes for radio but the serialEvent will chopped the entire buffer
for next payload to be sent out sequentially.

*/

#include <LiquidCrystal.h>
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
#include "printf.h"

LiquidCrystal lcd(10, 7, 3, 4, 5, 6);

RF24 radio(8,9);

const uint64_t pipes[2] = { 0xDEDEDEDEE7LL, 0xDEDEDEDEE9LL };

boolean stringComplete = false; // whether the string is complete
static int dataBufferIndex = 0;
boolean stringOverflow = false;
char charOverflow = 0;

char SendPayload[31] = "";
char RecvPayload[31] = "";
char serialBuffer[31] = "";

void setup(void) {

Serial.begin(57600);
lcd.begin(16,2);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("RF Chat V0.90");

printf_begin();
radio.begin();

radio.setDataRate(RF24_250KBPS);
radio.setPALevel(RF24_PA_MAX);
radio.setChannel(70);

radio.enableDynamicPayloads();
radio.setRetries(15,15);
radio.setCRCLength(RF24_CRC_16);

radio.openWritingPipe(pipes[0]);
radio.openReadingPipe(1,pipes[1]);

radio.startListening();
radio.printDetails();

Serial.println();
Serial.println("RF Chat V0.90");
delay(500);
lcd.clear();
}

void loop(void) {

nRF_receive();
serial_receive();

} // end loop()

void serialEvent() {
while (Serial.available() > 0 ) {
char incomingByte = Serial.read();

if (stringOverflow) {
serialBuffer[dataBufferIndex++] = charOverflow; // Place saved overflow byte into buffer
serialBuffer[dataBufferIndex++] = incomingByte; // saved next byte into next buffer
stringOverflow = false; // turn overflow flag off
} else if (dataBufferIndex > 31) {
stringComplete = true; // Send this buffer out to radio
stringOverflow = true; // trigger the overflow flag
charOverflow = incomingByte; // Saved the overflow byte for next loop
dataBufferIndex = 0; // reset the bufferindex
break;
}
else if(incomingByte=='\n'){
serialBuffer[dataBufferIndex] = 0;
stringComplete = true;
} else {
serialBuffer[dataBufferIndex++] = incomingByte;
serialBuffer[dataBufferIndex] = 0;
}
} // end while()
} // end serialEvent()

void nRF_receive(void) {
int len = 0;
if ( radio.available() ) {
bool done = false;
while ( !done ) {
len = radio.getDynamicPayloadSize();
done = radio.read(&RecvPayload,len);
delay(5);
}

RecvPayload[len] = 0; // null terminate string

lcd.setCursor(0,0);
lcd.print("R:");
Serial.print("R:");
lcd.setCursor(2,0);
lcd.print(RecvPayload);
Serial.print(RecvPayload);
Serial.println();
RecvPayload[0] = 0; // Clear the buffers
}

} // end nRF_receive()

void serial_receive(void){

if (stringComplete) {
strcat(SendPayload,serialBuffer);
// swap TX & Rx addr for writing
radio.openWritingPipe(pipes[1]);
radio.openReadingPipe(0,pipes[0]);
radio.stopListening();
bool ok = radio.write(&SendPayload,strlen(SendPayload));

lcd.setCursor(0,1);
lcd.print("S:");
Serial.print("S:");
lcd.setCursor(2,1);
lcd.print(SendPayload);
Serial.print(SendPayload);
Serial.println();
stringComplete = false;

// restore TX & Rx addr for reading
radio.openWritingPipe(pipes[0]);
radio.openReadingPipe(1,pipes[1]);
radio.startListening();
SendPayload[0] = 0;
dataBufferIndex = 0;
} // endif
} // end serial_receive()

If you had read the how to use the forum sticky you would know to post code in code tags. Copying and pasting your code into my IDE is a huge pain the way it is now posted, code tags make it easy. Then, in our IDE, we can compile the code to see the errors and help fix them.

Sorry for the inconvenience.
But I didn't find code bulletin board in this quick reply.
You can check the same post on this link. Where you will find the tagged code.
Chek the link below.

http://forum.arduino.cc/index.php?topic=322313.0