I’m trying to get two Arduinos talking using the NRF24L01+ boards. One is a Fio, the other is a Mega 2560. The Connections are as follows:
SPI Mega Fio
CE 49 9
CSN 53 10
SCK 52 13
MOSI 51 11
MISO 50 12
Both of the radios are supplied 3.3V from the Arduino boards. I am using pin 49 for CE because I am going to be installing a Project Freematics Shield and an LCD on the Mega once I can get this radio problem working. Right now, I am trying to simply transmit from the Mega to the Fio. My transmission code is:
// transmitter code
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
const uint64_t pipe = 0xE8E8F0F0E1LL;
int dd[0];
RF24 radio(48,49);
void setup()
{
Serial.begin(9600);
radio.begin();
radio.openWritingPipe(pipe);
dd[0]=0;
}
void loop()
{
dd[0]=dd[0]+1;
Serial.print(dd[0]);
Serial.print(" ");
radio.write( dd, sizeof(dd) );
delay(1000);
}
My receiver code is:
// receiver code
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
int dd[0];
RF24 radio(8,9);
const uint64_t pipe = 0xE8E8F0F0E1LL;
void setup(void)
{
Serial.begin(9600);
radio.begin();
radio.openReadingPipe(1,pipe);
radio.startListening();
pinMode(led, OUTPUT);
digitalWrite(led, LOW);
}
void loop(void)
{
if ( radio.available() )
{
// Dump the payloads until we've gotten everything
bool done = false;
while (!done)
{
done = radio.read( dd, sizeof(dd) );
Serial.print(dd[0]);
Serial.print(" ");
}
}
}
When I look at the transmission side with the serial monitor, I get my one per second increment that I would expect. When I look at the serial monitor on the receiver, I simply get the number 2312 over and over again. I realize that I’m probable making a bonehead mistake, but I can’t see what it could be. Any help?
Thanks.