I have two nrf modules that are connected to uno's.
I have the connections per Robins tutorial 11 -mosi, 12 -miso, 13 - sclk and 9,10 for the CE, CSN respectively.
I am using a socket adapter shown here
The voltage to the nrf24 board is an acceptable 2.4 volts.
I am running Robins Simple one way transmission code, one uno being the transmitter and the other as the receiver.
I did not get the two to communicate. The transmitter is returning a 0 from radio.begin() function which means it not reading the correct data from the RF_SETUP register. I switched nRF24 modules with the same result. I switched uno's with the same result.
The receiver is also returning a 0 from the call to radio.begin()
I wish I had a couple of other nRF2401 boards from another source but I don't.
I thought by using the adapter boards I would not have to use caps on the nRF24 board VCC, gnd pins.
but maybe not.
Anyone have anything else I can try to get this working?
Thanks for responding. Here is the code and results.
Transmitter Code
// 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);
Serial.println("SimpleTx Starting");
if ((radio.begin()) == 0)
Serial.println("begin returned zero");
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;
}
Output from transmitter
Opening port
Port open
SimpleTx Starting
begin returned zero
#include <SPI.h>
#include <RF24_config.h>
// SimpleRx - the slave or the receiver
#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;
byte count=0;
//===========
void setup() {
Serial.begin(9600);
Serial.println("SimpleRx Starting");
if (radio.begin()==false)
Serial.println("error with radio.begin()");
radio.setDataRate( RF24_250KBPS );
radio.openReadingPipe(1, thisSlaveAddress);
radio.startListening();
}
//=============
void loop() {
getData();
showData();
count++;
if (count > 20)
while(1);
}
//==============
void getData() {
radio.flush_rx();
if ( radio.available() ) {
radio.read( &dataReceived, sizeof(dataReceived) );
newData = true;
}
}
void showData() {
if (newData == true) {
Serial.print("Data received ");
Serial.println(dataReceived);
newData = false;
}
}
Output from receiver
SimpleRx Starting
error with radio.begin()
Data received
Data received
Data received
Data received
Data received
Data received
Data received
Data received
Data received
Data received
Data received
Data received
Data received
Data received
Data received
Data received
Data received
Data received
Data received
Data received
Data received
...
You have made changes to my Tx program. I have not checked the Rx program.
Get the programs working without any changes first. It is much easier to help that way. When you have communication working then it will be time to experiment with changes.
I suspect the output from your Rx program is repeating very fast. It should only repeat once per second. If it is repeating very fast it probably means there is a hardware problem - perhaps a loose connection or an incorrect connection which allows the Arduino to think there is data when there is none.