SparkFun Forums 

Where electronics enthusiasts find answers.

For the discussion of Arduino related topics.
By aslam_1991
#115814
hello there,

well i have been working on a project which needs communication between two arduino boards through two nRF24L01+ rf transceiver modules. well i have got the code and all. the sending side is working fine, but there isnt any reaction on the receiving side. the thing is, i m not particular about the data that needs to be transmitted. my project is about a home security alarm system. so i programmed the it where, when the door opens, there will be a signal sent from the door ( the transmitting end ) to the main board ( the receiving end ). so i jus need some sort of signal to be sent over.

well this is my code,

transmitting end:
Code: Select all
#include <Spi.h>
#include <mirf.h>
#include <nRF24L01.h>

// constants won't change. They're used here to 
// set pin numbers:
const int switchPin = 2;     // the number of the pushbutton pin
const int ledPin =  7;      // the number of the LED pin

// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status

void setup(){
  Serial.begin(9600);
  Mirf.init();
  Mirf.setRADDR((byte *)"clie1");
  Mirf.config();
  Mirf.payload = sizeof(int);

  // initialize the LED pin as an INPUT:
  pinMode(ledPin, INPUT);      
  // initialize the switch pin as an output:
  pinMode(switchPin, OUTPUT);
}

void loop(){

   digitalWrite(switchPin, HIGH);

  // read the state of the pushbutton value:
  buttonState = digitalRead(ledPin);

  if (buttonState == LOW) {     
    
    
  //byte data[Mirf.payload];
  Mirf.setTADDR((byte *)"serv1");
  
  Mirf.send((byte *)"hello");
  
  while(Mirf.isSending()){
  }
  Serial.println("Finished sending");
  delay(10);
  
  } 
 // else {
    // turn LED off:
    //digitalWrite(ledPin, LOW); 
 // }

  
}  
and this is the receiving end:
Code: Select all
#include <Spi.h>
#include <mirf.h>
#include <nRF24L01.h>

const int ledPin =  13;      // the number of the LED pin

void setup(){
  Serial.begin(9600);
  Mirf.init();
  Mirf.setRADDR((byte *)"serv1");
  Mirf.config();
  Mirf.payload = sizeof(int);
  pinMode(ledPin, OUTPUT);      

}

void loop(){
  byte data[Mirf.payload];

  if(Mirf.dataReady()){
    
    do{
      
    
      Mirf.getData(data);
      
      Serial.println(data[0]);
      
      Serial.println("Got packet");

      digitalWrite(ledPin, HIGH);

      
    }while(!Mirf.rxFifoEmpty());
  }
} 


i programmed the receiving such that an led will light up when the packet is received. so ya... the sending side is working fine... its jus the receiving side...

please do help... thank you very much...

cheers,

aslam...
User avatar
By leon_heller
#115816
How do you know that the transmitter is working properly?
By aslam_1991
#115817
yeah about that... i dont know that either... i looked at the serial monitor and " finished sending " appears... whenever the door is open... so i thought everything was fine... i m trying to look for ways to fine out if anything is actually being sent...

so do u have any ideas?

thanks for the reply...
User avatar
By leon_heller
#115819
I've got some PIC code that works, if that helps.
By aslam_1991
#115820
well yeah sure... but i m not sure how to change pic code to arduino code... do u have anything on that? thanx for ur help... please email me ur codes... to aslam_1991@hotmail.com

cheers,
aslam...
By aslam_1991
#115824
does any one know how to conver pic codes to arduino codes? sorrrry i m a noob at this actually... thanks...