wifi communication using nrf24l01

i am trying to send and receive data using arduino uno and nrf24l01 with an antenna attached to it so i tried out 4 to 5 online codes for it but none of worked then i downloaded rf24_g library and used its sample code for transmitter and receiver so i was transmitting it but at the receiving end i could not get the data which transmitted both codes are given below please can you help me figure out how move forward with the idea
this is the transmitting code

/* This sketch sends a packet with random data to another radio and waits for

  • the packet to be sent back. It prints out the random data and the received data, which should be the same.

#include <rf24g.h>
// We must instantiate the RF24_G object outside of the setup function so it is available in the loop function
RF24_G test;
void setup() {
// create the RF24G object with an address of 4, using pins 7 and 8
test = RF24_G(1, 7, 8);


void loop() {
// create a random number
uint8_t randNumber = 100;
// create a variable to store the received number
int actual;
// declare the sender packet variable
packet sender;
// declare the receiver packet variable
packet receiver;
// set the destination of the packet to address 1
// write the payload to the packet
sender.addPayload(&randNumber, sizeof(int));
// print out the original payload
Serial.print("original number:");
// send the packet, if it is successful try to read back the packet
if (test.write(&sender) == true) {
// wait until a packet is received
while (test.available() != true);
// copy the packet into the receiver object
// copy the payload into the actual value
receiver.readPayload(&actual, sizeof(int));
// print out the actual value received
Serial.print("received number:");



this is the receiving code

/* This is a small sketch that listens

  • for packets and forwards them back to the sender.

#include <rf24g.h>
// we must instantiate the RF24_G object outside of the setup function so it is available in the loop function
RF24_G test;
int i = 0;
void setup() {
// create the RF24G object with an address of 1, using pins 7 and 8
test = RF24_G(11, 7, 8);
// print out the details of the radio's configuration (useful for debug)

void loop() {
// declare packet variable
packet receiver;
// declare string to place the packet payload in
char payload[30];
// check if the radio has any packets in the receive queue
if (test.available() == true) {
Serial.println("packet received!");
// read the data into the packet
// print the packet number of the received packet
// if these are not consecutive packets are being lost due to timeouts.
Serial.print("count: ");
// print the source address of the received packet
Serial.print("address: ");
// load the payload into the payload string
receiver.readPayload(payload, 30);
// print the payload
Serial.print("payload: ");
// since the address in the packet object is already
// set to the address of the receiver, it doesn't need to be changed
// hence, we can write the packet back to the receiver
// we may check to see if the transmission failed, if so we just drop the packet
if (test.write(&receiver) == false) {
Serial.println("transmit back failed!");
Serial.println("dropping packet...");

For a start, nRF24 modules are NOT WiFi.

Second, When posting code please use the code button </>

so your code 
looks like this

and is easy to copy to a text editor See How to use the forum

Third, 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

There is also a connection test program to check that the Arduino can talk to the nRF24 it is connected to.

A common problem with nRF24 modules is insufficient 3.3v current from the Arduino 3.3v pin. The high-power nRF24s (with the external antenna) will definitely need an external power supply. At least for testing try powering the nRF24 with a pair of AA alkaline cells (3v) with the battery GND connected to the Arduino GND.

And Fourthly, I am suggesting to the Moderator to move your question to the Networking section of the Forum.


Topic moved as requested.