Hi,
I'm trying to figure out how to communicate between the nRF24L01 and nRF24LU1+.
I've used this project for the PC+dongle side.
It seems the dongle isn't receiving any data yet from the arduino.
Can you please look if my configurations are correct? Is the addr correct?
Thanks!
This is the config code on the dongle (I prefer to leave as is first):
void rf_configure( )
{
__xdata uint8_t addr[4];
RFCON = 0x06; // Enable RF clock
RFCE = 0; // Disable chip
rf_write_byte_reg( 0x00, 0x39 ); // Enable RX IRQ, CRC Enabled, be a receiver
rf_write_byte_reg( 0x01, 0x00 ); // Disable auto-acknowledge
rf_write_byte_reg( 0x03, 0x03 ); // Set address width to 5bytes (default, not really needed)
rf_write_byte_reg( 0x06, 0x07 ); // Air data rate 1Mbit, 0dBm, Setup LNA
rf_write_byte_reg( 0x11, 0x04 ); // 4 byte receive payload
rf_write_byte_reg( 0x05, 0x02 ); // RF Channel 2 (default, not really needed)
addr[0] = 0xE7;
addr[1] = 0xE7;
addr[2] = 0xE7;
addr[3] = 0xE7;
rf_write_reg( 0x0A, addr, 4 );
rf_write_byte_reg( 0x00, 0x3B ); // RX interrupt, power up, be a receiver
RFCE = 1; // Enable chip
}
This is the code on the arduino (I'm trying to match it to the config in the dongle):
/**
* A Mirf example to test the latency between two Ardunio.
*
* Pins:
* Hardware SPI:
* MISO -> 12
* MOSI -> 11
* SCK -> 13
*
* Configurable:
* CE -> 8
* CSN -> 7
*
* Note: To see best case latency comment out all Serial.println
* statements not displaying the result and load
* 'ping_server_interupt' on the server.
*/
#include <SPI.h>
#include <Mirf.h>
#include <nRF24L01.h>
#include <MirfHardwareSpiDriver.h>
void setup(){
Serial.begin(9600);
/*
* Setup pins / SPI.
*/
/* To change CE / CSN Pins:
*
* Mirf.csnPin = 9;
* Mirf.cePin = 7;
*/
/*
Mirf.cePin = 7;
Mirf.csnPin = 8;
*/
Mirf.spi = &MirfHardwareSpi;
Mirf.init();
/*
* Configure reciving address.
*/
Mirf.setRADDR((byte *)"clie1");
/*
* Set the payload length to sizeof(unsigned long) the
* return type of millis().
*
* NB: payload on client and server must be the same.
*/
Mirf.payload = 4;//sizeof(unsigned long);
/*
* Write channel and payload config then power up reciver.
*/
/*
* To change channel:
*
* Mirf.channel = 10;
*
* NB: Make sure channel is legal in your area.
*/
Mirf.channel = 2;
Mirf.config();
Mirf.configRegister(RF_SETUP, 0x07); //Air data rate 1Mbit, 0dBm, Setup LNA
Mirf.configRegister(EN_AA, 0x00); //Disable auto-acknowledge
Serial.println("Beginning ... ");
}
void loop(){
unsigned long time = millis();
byte addr[4];
addr[0] = 0xE7;
addr[1] = 0xE7;
addr[2] = 0xE7;
addr[3] = 0xE7;
Mirf.setTADDR(addr);
Mirf.send((byte *)"1");
while(Mirf.isSending()){
}
Serial.println("Finished sending");
delay(10);
while(!Mirf.dataReady()){
//Serial.println("Waiting");
if ( ( millis() - time ) > 1000 ) {
Serial.println("Timeout on response from server!");
return;
}
}
Mirf.getData((byte *) &time);
Serial.print("Ping: ");
Serial.println((millis() - time));
delay(1000);
}