hi all
i am using arduino mega as transmitter and uno as reciever
here is the code i use
Transmitter
#include<SPI.h>
#include<RF24.h>
char msg[20] = "Hello World!";
char rec[27];
const uint64_t pipe[1] = {0xF0F0F0F0E1LL};
RF24 radio(7,52);
void setup()
{
Serial.begin(115200);
radio.begin();
radio.enableAckPayload();
radio.enableDynamicPayloads();
radio.setRetries(5, 15);
radio.openWritingPipe(pipe[0]);
}
void loop()
{
Serial.println("TX MILLS: " + String(millis()));
if(radio.write(msg,sizeof(msg)))
{
Serial.print("TX: ");
Serial.println(msg);
if(radio.isAckPayloadAvailable())
{
radio.read(&rec, 27);
Serial.println("RX: ");
Serial.println(rec);
}
else
{
Serial.println("No ACK recieved...");
}
}
else
{
Serial.println("Cannot Transmit..");
}
delay(1000);
}
Reciever
#include<SPI.h>
#include<RF24.h>
char msg[20] = "Hello awesome";
char rec[27];
const uint64_t pipe[1] = {0xF0F0F0F0E1LL};
RF24 radio(7,52);
void setup()
{
Serial.begin(115200);
radio.begin();
radio.enableAckPayload();
radio.enableDynamicPayloads();
radio.setRetries(15, 15);
radio.openReadingPipe(1, pipe[0]);
radio.startListening();
}
void loop()
{
Serial.println("RX MILLS: " + String(millis()));
if(radio.available())
{
radio.read(&rec, sizeof(rec));
Serial.print("RX: ");
Serial.println(rec);
radio.writeAckPayload(1, msg, sizeof(msg));
Serial.print("TX :");
Serial.println(msg);
}
delay(500);
}
i don't why i am not able to transmit data
it only transmits blank
so i also doesn't know wether the reciever side would work.
if any can help me it would be great it is for a mini project.
rec.ino (685 Bytes)
transmit.ino (800 Bytes)