NRF2401 Wireless Communication

From Tuxamito
Revision as of 09:59, 5 November 2016 by Daniel (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Nrf24l01 pinout1.jpg

Nrf24l01 pinout2.jpg

Nrf24l01 diagram.png


#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

RF24 radio(7, 8);

const byte rxAddr[6] = "00001";
char text[32] = {0};

void setup()
{
  while (!Serial);
  Serial.begin(115200);
  
  radio.begin();
  radio.openReadingPipe(0, rxAddr);
  
  radio.startListening();


  Serial.println("Listening!");
}

void loop()
{
  if (radio.available())
  {
    radio.read(text, sizeof(text));  
    Serial.println(text);
  }
}


#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <printf.h>

byte i = 0;
char text[24] = {0};

RF24 radio(7, 8);


const byte rxAddr[6] = "00001";

void setup()
{
  Serial.begin(115200);
  printf_begin();

  radio.begin();
  radio.setRetries(15, 15);
  radio.openWritingPipe(rxAddr);
  
  radio.stopListening();

  Serial.println("Ready!");
}

void loop()
{
  sprintf(text, "Hello World %d", i);
  Serial.println(text);
  radio.write(text, sizeof(text));
  i++;

  //radio.printDetails();
  delay(1000);
}