Skip to content

Instantly share code, notes, and snippets.

@mithi
Last active March 20, 2020 12:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mithi/ffbfb37bd6324740933b867b8fc84347 to your computer and use it in GitHub Desktop.
Save mithi/ffbfb37bd6324740933b867b8fc84347 to your computer and use it in GitHub Desktop.
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <printf.h>
#define CE_PIN 9
#define CSN_PIN 10
RF24 radio(CE_PIN, CSN_PIN);
const byte ADDRESS[6] = "00001";
void setup() {
while (!Serial);
Serial.begin(9600);
printf_begin();
radio.begin();
//radio.setAutoAck(false);
radio.setDataRate(RF24_2MBPS);
//RF24_1MBPS, RF24_2MBPS
radio.setPALevel(RF24_PA_MIN);
//RF24_PA_LOW, RF24_LOWMBPS
radio.setRetries(3,5);
// delay, count
radio.openReadingPipe(0, ADDRESS);
radio.startListening();
radio.printDetails();
}
void loop() {
if (radio.available()) {
char text[32] = "";
radio.read(&text, sizeof(text));
Serial.println(text);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment