So I followed this tutorial to get two UNOs transmitting data to eachother. This works perfectly fine with both UNOs.
However I want to set up a MEGA 2560 to work as a receiver instead of one of the UNOs. I know my UNO transmitter is working correctly because when using another UNO as a receiver it works fine.
For my PIN layout on my MEGA, I have:
nRF24L01+ MEGA
MISO ICSP1
MOSI ICSP4
SCK ICSP3
VCC 3.3V
GND GND
CSN 53
CE 49
My code which for the MEGA is here, and is only slightly modified from the working UNO receiver code with CE pin changed and CSN pin changed:
// SimpleRx - the slave or the receiver
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#define CE_PIN 49
#define CSN_PIN 53
const byte thisSlaveAddress[5] = {'R','x','A','A','A'};
RF24 radio(CE_PIN, CSN_PIN);
char dataReceived[10]; // this must match dataToSend in the TX
bool newData = false;
//===========
void setup() {
Serial.begin(9600);
Serial.println("SimpleRx Starting");
radio.begin();
radio.setDataRate( RF24_250KBPS );
radio.openReadingPipe(1, thisSlaveAddress);
radio.startListening();
}
//=============
void loop() {
getData();
showData();
}
//==============
void getData() {
if ( radio.available() ) {
radio.read( &dataReceived, sizeof(dataReceived) );
newData = true;
Serial.println("AVAILABLE");
}
else
Serial.println("radio unavailable");
}
void showData() {
if (newData == true) {
Serial.print("Data received ");
Serial.println(dataReceived);
newData = false;
}
}
Finally, when running the checkConnection code on the thread mentioned above (post #29) for the UNO working as a receiver I have the following data (shown in the attachment work.PNG).
When running the same code with the pins changed to correspond to where they go on the MEGA I have this, shown in the attachment nowork.png
If I make PIN 9 to CE and PIN 10 to CSN it also doesn't work.
Not working means that the radio.available() function in the code always returns false, and I cannot get any data reading.