/*
14CORE NRF24L01 MASTER CONTROLLER/TRANSMITTER
*/ #include <SPI.h> //Include SPI Code Library which can be downloaded below #include "nRF24L01.h" //Include NRF24L01 Code Library which can be downloaded below #include "RF24.h" //Inlcude NRF24 Code Library which can be downloaded below
int msg[0];
RF24 radio(9,10); // The NRF24L01 Pin CE and Pin CSN
const uint64_t pipe = 0xE8E8F0F0E1LL; //Communication Pip Address
int switchButton1 = 7; // Push button connected to Arduino pin 7
int switchButton2 = 8;
int switchButton3 = 3;
void setup(void){
Serial.begin(9600); //Start Serial Communication at baud rate 9600
radio.begin();
radio.openWritingPipe(pipe);} //Open Communication Pipe
void loop(void){
if (digitalRead(switchButton1) == LOW){ // When the push button has been press it will send radio signal to the RX to turn the LED into HIGH
msg[0] = 1;
radio.write(msg, 1);
}
if (digitalRead(switchButton2) == LOW){ // When the push button has been press it will send radio signal to the RX to turn the LED into HIGH
msg[0] = 2;
radio.write(msg, 1);
}
if (digitalRead(switchButton3) == LOW){ // When the push button has been press it will send radio signal to the RX to turn the LED into HIGH
msg[0] = 3;
radio.write(msg, 1);
#include <SPI.h> //Include SPI Code Library which can be downloaded below #include "nRF24L01.h" //Include NRF24L01 Code Library which can be downloaded below #include "RF24.h" //Inlcude NRF24 Code Library which can be downloaded below
int msg[1];
RF24 radio(9,10); // NRF24L01 Pin
const uint64_t pipe = 0xE8E8F0F0E1LL; //Start Pipe Communication Address
#define Indicator1 A0 #define Indicator2 A1 #define Indicator3 A2//This the LED which is connected to Arduino Pin 3
void setup(void){
Serial.begin(9600);
radio.begin();
radio.openReadingPipe(1,pipe);
radio.startListening();
pinMode(Indicator1, OUTPUT);
pinMode(Indicator2, OUTPUT);
pinMode(Indicator3, OUTPUT);}
void loop(void)
{
if (radio.available())
{ bool done = false;
while (!done)
{ done = radio.read(msg, 1);
Serial.println(msg[0]);
if (msg[0] == 1){digitalWrite(Indicator1, LOW);}
else {digitalWrite(Indicator1,HIGH);}
if (msg[0] == 2){digitalWrite(Indicator2, LOW);}
else {digitalWrite(Indicator2,HIGH);}
if (msg[0] == 3){digitalWrite(Indicator3, LOW);}
else {digitalWrite(Indicator3,HIGH);}
}}
else digitalWrite(Indicator1,HIGH); digitalWrite(Indicator2,HIGH); digitalWrite(Indicator3,HIGH);
Serial.println("No Radio Transmission");
}
I want to sent the data between two nrf24 with range 1km or above. the location is open field. I have antnna version nrf24, I don't know how to use the low frequency.
What is your programs purpose? Does it have a button? What are the schematics? Do you have a different code for the reciver/transmitter? A really good thing Ive learned with my time using arduino is that you should not rush things and make them good and understand them from bottom to top. Make a schematic, if it takes a day drawing do it so you understand it. Then you Start building the program to its purpose based on you schematic and plan.
If your using the NRF24 modules with the power amplifier and SMA antenna socket, be aware that in a lot of places in the World you may be limited to a maximum power output of 10mW.
Which means dont use the RF24_PA_MAX setting as that can send out circa 150mW. On some versions of RF24 this can be close to the power output you get even when RF24_PA_MIN is used.
There are plenty of other radio modules, especially for use in the 434Mhz, 868Mhz or 915Mhz bands which will cover the 1km without the need to use high levels of RF power.