After a solid couple of days working with this, I'm still not receiving any information. I see the Tx light blinking once a second on the transmitter, but nothing happens at the Rx end. I've added a bit of code just so it says, "nope" when it doesn't have any new data, and the result is a solid string of "nope"s.
I know that these modules can't take more than 3.3v, but mine came without numbered pins and I plugged them in backward, misreading which side of the board the diagram was representing. Could the 5v signal have blown the radio board? How could I confirm that?
I'm using a Nano for both Tx and Rx. Could I maybe have them plugged into the wrong pins? I've corrected my pin order so many times that I have no faith in the order they're in now. Nonetheless, I've listed the order I'm currently using in the comment at the top of the code, just so I have a reference to work from as I go.
Tx code
/*
Transmitter for nRF24L01
nRF24L01 pin Nano pin Color (arbitrary)
CE 03 9(any) orange
CS/N 04 10(any) yellow
SCK 05 13 green
MOSI 06 11 blue
MISO 07 12 purple
IRQ 08 (none) grey
Nano pins, in order color
9 orange
10 yellow
11 blue
12 purple
13 green
*/
// SimpleTx - the master or the transmitter
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#define CE_PIN 9
#define CSN_PIN 10
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);
digitalWrite(10, HIGH); //sets it to master mode?
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;
}
Rx Code
/*
Receiver for nRF24L01
nRF24L01 pin Nano pin Color (arbitrary)
CE 03 9 orange
CS/N 04 10 yellow
SCK 05 13 green
MOSI 06 11 blue
MISO 07 12 purple
IRQ 08 (none) grey
Nano pins, in order Color
9 orange
10 yellow
11 blue
12 purple
13 green
*/
// SimpleRx - the slave or the receiver
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#define CE_PIN 9
#define CSN_PIN 10
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() {
digitalWrite(10, HIGH); //Sets to Master mode? I don't understand how it can only work in Master mode.
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;
}else{
Serial.println("nope");
}
}
void showData() {
if (newData == true) {
Serial.print("Data received ");
Serial.println(dataReceived);
newData = false;
}
}
This is like a steering wheel stuck on a pirate's crotch.