Skip to content

Instantly share code, notes, and snippets.

@wwwins
Last active January 14, 2016 03:19
Show Gist options
  • Select an option

  • Save wwwins/b55de292b3c0f235092f to your computer and use it in GitHub Desktop.

Select an option

Save wwwins/b55de292b3c0f235092f to your computer and use it in GitHub Desktop.
Receiver For Arduino.
#include <SPI.h>
#include "RF24.h"
/************* USER Configuration *****************************/
// Hardware configuration
RF24 radio(9, 10); // Set up nRF24L01 radio on SPI bus plus pins 7 & 8
/***************************************************************/
const uint64_t pipes[2] = { 0xABCDABCD71LL, 0x544d52687CLL }; // Radio pipe addresses for the 2 nodes to communicate.
char data[32]; //Data buffer for testing data transfer speeds
void sendCallback() {
Serial.println("Stop Listening.");
delay(100);
radio.stopListening();
radio.write(&data,32);
Serial.println("Send Response.");
radio.startListening();
}
void setup(void)
{
Serial.begin(57600);
radio.begin();
radio.setChannel(1);
radio.setPALevel(RF24_PA_MIN);
radio.setDataRate(RF24_250KBPS);
//radio.setAutoAck(1);
radio.setRetries(15, 15);
radio.setCRCLength(RF24_CRC_16); // Use 8-bit CRC for performance
radio.openWritingPipe(pipes[1]);
radio.openReadingPipe(1, pipes[0]);
radio.startListening(); // Start listening
radio.printDetails(); // Dump the configuration of the rf unit for debugging
radio.powerUp(); //Power up the radio
}
void loop(void)
{
if (radio.available()) {
while (radio.available()) {
radio.read(&data, 32);
Serial.print("Received:");
Serial.println(data);
sendCallback();
delay(10);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment