Please provide sample program for NRF24L01 communication.

Please provide sample program for NRF24L01 communication.

There are two transmitters and one receiver. I have to send int values from transmitter boards to receiver board. I am using Nano + Nano IO Shield. The shield has port for XBee and nRF24L01. 3 board will be used. I need to send distance value obtained from Ultrasonic Sensors to receiver board.

Is google broken in your country ?

There are two libraries commonly used to interface to nRF24L01+ transceivers. Both come with example sketches and documentation. I will leave it to your initiative to find the libraries, but if it takes you longer than thirty seconds you're doing something wrong.

Yes. I have the MIRF and RadioHead libraries and want to use RadioHead nRF24 library. It has nRF reliable datagram client and reliable datagram server. All I understand is I have to use relaible datgram server code for receiver board and client code for transmitter boards. I need example code to send int values like 0, 1, 2, 3,....

The receiver has to receive this from the transmitters and have to control some device for this the receiver has to know which data is from which transmitter and at the receiver side if data was not sent successfully then a retransmission has to occur until the data reach the receiver. The data has to be sent once every 30 seconds or 1 minute. I will use Timer interrupt for this purpose. The int value is number of pulses from flow sensor. I get around 320 pulses per liter. I sent liter value as int.

I found this but this is not for relaibale datagram example

http://hack.lenotta.com/arduino-raspberry-pi-switching-light-with-nrf24l01/

Don't use the Timer interrupt for that - it's completely unnecessary and using interrupts introduces all sorts of issues that are best avoided. Just use the techniques demonstrated in the blink without delay example to do your transmission at regular intervals.

Ok, but give me an example code for 2 tx and 1 rx for sending a receiving unsigned int data using RadioHead nRF24 reliable datagram method.

jayanthd:
Ok, but give me an example code

You're asking people to write code for you and you don't even say please? Sheesh...

Doesn't that library come with examples and documentation?

The example that comes show how to send and receive strings. I need to send only one or two byte(s) which is an int value which is the distance from distance sensor. Range of sensor is 2 cm to 700 cm. So data can be 1 byte or 2 bytes. Should I use buf[2] and data[2] ? Should I change casting the buf to string to casting it to unsigned int in Serial print command ?

You haven't shown which code you're referring to, but I guess it uses the bool send(const uint8_t* data, uint8_t len) method in the RH_NRF24 class. The send method has arguments which provide the start address and length of the data to be sent. The data can be in any data structure that you like - you just need to pass the start address and size in bytes to send().

int myMessage[2];
myMessage[0] = 12;
myMessage[1] = 34;

rf24.send(myMessage, sizeof(myMessage));

I am using nRF reliable datagram method in RadioHead > nRF24 library. Reliable datagram method send out data and if it doesn't get ack then it keeps resending data unless it gets an ack.

Which method of which class in the RH library are you calling to send the message?

In RH nRF24 example there is 2 examples which are reliable datagram example which checks if data was sent by using ack. That is what I ma using.

Previous post that might have information.

https://www.google.com/search?as_q=NRF24L01&as_epq=&as_oq=&as_eq=&as_nlo=&as_nhi=&lr=&cr=&as_qdr=all&as_sitesearch=http%3A%2F%2Fforum.arduino.cc%2Findex&as_occt=any&safe=images&tbs=&as_filetype=&as_rights=&gws_rd=ssl