Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[arduino code examples for A6v3]-10 nRF24L01 wireless receiver and transmitter
#1
nRF24L01 Transmitter:
Code:
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#define CE_PIN 40
#define CSN_PIN 38

const uint64_t abc = 0xE8E8F0F0E1LL;

RF24 radio(CE_PIN, CSN_PIN);
char data[] = "Hello World, KinCony";

void setup()
{
   Serial.begin(9600);
   radio.begin();
   radio.openWritingPipe(abc);
}

void loop()
{
   radio.write( data, sizeof(data) );
}

nRF24L01 Receiver:
Code:
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#define CE_PIN 40
#define CSN_PIN 38

const uint64_t id = 0xE8E8F0F0E1LL;

RF24 radio(CE_PIN, CSN_PIN);

#define SIZE 32            // this is the maximum for this example. (minimum is 1)
char buffer[SIZE + 1];     // for the RX node
uint8_t counter = 0;       // for counting the number of received payloads

void setup()
{
   Serial.begin(9600);
   delay(1000);
   Serial.println("Nrf24L01 Receiver Starting");
   radio.begin();
   radio.openReadingPipe(1,id);
   radio.startListening();;
}

void loop()
{
    if (radio.available()) {         // is there a payload?
      radio.read(&buffer, SIZE);     // fetch payload from FIFO
      Serial.print("Received:");
      Serial.print(buffer);          // print the payload's value
      Serial.print(" - ");
      Serial.println(counter++);     // print the received counter
    }
}
Reply


Forum Jump:


Users browsing this thread:
1 Guest(s)