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:
#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:
#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…