I've been trying to get the Nrf24L01 to work for several days now without much success.
I want to send data of a joystick from one Arduino to another one. I also tried adding a 100uF capacitor on each arduino. The only thing I'm receiving are a bunch of zeros or wrong numbers.
On the Arduino Duemilanove and other ATmega168 / 328-based boards, the SPI bus uses pins 10 (SS), 11 (MOSI), 12 (MISO), and 13 (SCK). On the Arduino Mega, this is 50 (MISO), 51 (MOSI), 52 (SCK), and 53 (SS). Note that even if you're not using the SS pin, it must remain set as an output; otherwise, the SPI interface can be put into slave mode, rendering the library inoperative.
Have you tried my examples? They worked for me on my Mega. Debugging wireless can be very difficult and it is easier to help when you are using code I am familiar with.
I tried your code. I also added an external 3.3V regualtor. Unfortanetly your code doesn't seem to work for me. The transmitter tries to transmit but always fails and the Receiver doesn't show anything except for simple rx starting. The changes I made in your code is that is set ce to 9 and csn to 53. I also tried to set csn pin as output.
DE67:
I tried your code. I also added an external 3.3V regualtor. Unfortanetly your code doesn't seem to work for me. The transmitter tries to transmit but always fails and the Receiver doesn't show anything except for simple rx starting.
If you post the exact code (both programs) that YOU uploaded to your Megas (are you using 2 Megas?) and examples of the output from the two programs I will try to help.
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#define CE_PIN 9
#define CSN_PIN 53
const byte slaveAddress[5] = {'R','x','A','A','A'};
RF24 radio(CE_PIN, CSN_PIN); // Create a Radio
char dataToSend[10] = "Message 0";
char txNum = '0';
unsigned long currentMillis;
unsigned long prevMillis;
unsigned long txIntervalMillis = 1000; // send once per second
void setup() {
Serial.begin(9600);
pinMode(53,OUTPUT);
Serial.println("SimpleTx Starting");
radio.begin();
radio.setDataRate( RF24_250KBPS );
radio.setRetries(3,5); // delay, count
radio.openWritingPipe(slaveAddress);
}
//====================
void loop() {
currentMillis = millis();
if (currentMillis - prevMillis >= txIntervalMillis) {
send();
prevMillis = millis();
}
}
//====================
void send() {
bool rslt;
rslt = radio.write( &dataToSend, sizeof(dataToSend) );
// Always use sizeof() as it gives the size as the number of bytes.
// For example if dataToSend was an int sizeof() would correctly return 2
Serial.print("Data Sent ");
Serial.print(dataToSend);
if (rslt) {
Serial.println(" Acknowledge received");
updateMessage();
}
else {
Serial.println(" Tx failed");
}
}
//================
void updateMessage() {
// so you can see that new data is being sent
txNum += 1;
if (txNum > '9') {
txNum = '0';
}
dataToSend[8] = txNum;
}