arduino + nrf24l01 not working with external power supply

Tapas08:
since both can transmit and receive but the only problem is that the transmitter don't receive acknowledgement?

Please post the programs that prove that.

...R

Robin2:
Please post the programs that prove that.

I have used code from your tutorial and just added acknowledgment checks.

Transmitter

// 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");

    radio.begin();
    radio.setDataRate( RF24_250KBPS );
    radio.setRetries(3,5); // delay, count
    radio.setAutoAck(true);
    radio.enableAckPayload();
    radio.enableDynamicPayloads();
    radio.setChannel(70);
    radio.openWritingPipe(slaveAddress);
}

//====================

void loop() {
    currentMillis = millis();
    if (currentMillis - prevMillis >= txIntervalMillis) {
        send();
        prevMillis = millis();
    }
}

//====================

void send() {
    char gotChars[5];
    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

    if (radio.isAckPayloadAvailable()){
      Serial.println("Payload available");
    }else{
      Serial.println("No Acknowledgement received");
    }

    Serial.print("Data Sent ");
    Serial.print(dataToSend);
    radio.read(gotChars, 5);
    if (rslt) {
        Serial.println("  Acknowledge received");
        updateMessage();
    }
    else {
        Serial.println("  Tx failed");
    }
    Serial.println("Ack Payload = "+ gotChars[0]);
}

//================

void updateMessage() {
        // so you can see that new data is being sent
    txNum += 1;
    if (txNum > '9') {
        txNum = '0';
    }
    dataToSend[8] = txNum;
}

Receiver

// 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() {

    Serial.begin(9600);

    Serial.println("SimpleRx Starting");
    radio.begin();
    radio.setDataRate( RF24_250KBPS );
    radio.setAutoAck(true);
    radio.enableAckPayload();
    radio.enableDynamicPayloads();
    radio.setChannel(70);
    radio.openReadingPipe(1, thisSlaveAddress);
    radio.startListening();
}

//=============

void loop() {
    getData();
    showData();
}

//==============

void getData() {
    if ( radio.available() ) {
        char msg[5] = "Done";
        radio.writeAckPayload(1, msg, sizeof(msg));
        radio.read( &dataReceived, sizeof(dataReceived) );
        newData = true;
    }
}

void showData() {
    if (newData == true) {
        Serial.print("Data received ");
        Serial.println(dataReceived);
        newData = false;
    }
}

Tapas08:
I have used code from your tutorial and just added acknowledgment checks.

I have bookmarked this so I can find it as I may no get time to study your code until tomorrow sometime.

...R

I have had a quick look at your program. You seem to have made a mashup of stuff. If you want to try the ackPayload system then use my second example which is specially for that.

It is much easier to help when you use the examples without ANY changes.

...R

Sorry I had to go out of town so could not reply and test the other code.
I just tried it and the transmitter still won't receive acknowledgement.
Also my new nrf24 will be available tomorrow so I will try it out tomorrow and will let you know.
Thanks for you time.

Tapas08:
I just tried it

For the future when you say you tried something please describe it in great detail including the actual code that was used in the trial. It is impossible to do any useful diagnosis without all the detail. It would be very different if I was standing beside you watching what you are doing.

...R

Robin2:
For the future when you say you tried something please describe it in great detail including the actual code that was used in the trial. It is impossible to do any useful diagnosis without all the detail. It would be very different if I was standing beside you watching what you are doing.

Okay I am sorry about that. I will try to be more precise.

So I tried your code for sending acknowledgement packet even on the new module but it is still not working. The other module (new NRF24) is still not receiving a data. I tried using capacitor too but it still wont receive data.
Here is your code that I tried

For TX:

// SimpleTxAckPayload - 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';
int ackData[2] = {-1, -1}; // to hold the two values coming from the slave
bool newData = false;

unsigned long currentMillis;
unsigned long prevMillis;
unsigned long txIntervalMillis = 1000; // send once per second

//===============

void setup() {

    Serial.begin(9600);
    Serial.println(F("Source File /mnt/sdb1/SGT-Prog/Arduino/ForumDemos/nRF24Tutorial/SimpleTxAckPayload.ino"));
    Serial.println("SimpleTxAckPayload Starting");

    radio.begin();
    radio.setDataRate( RF24_250KBPS );

    radio.enableAckPayload();

    radio.setRetries(3,5); // delay, count
    radio.openWritingPipe(slaveAddress);
}

//=============

void loop() {

    currentMillis = millis();
    if (currentMillis - prevMillis >= txIntervalMillis) {
        send();
    }
    showData();
}

//================

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) {
        if ( radio.isAckPayloadAvailable() ) {
            radio.read(&ackData, sizeof(ackData));
            newData = true;
        }
        else {
            Serial.println("  Acknowledge but no data ");
        }
        updateMessage();
    }
    else {
        Serial.println("  Tx failed");
    }

    prevMillis = millis();
 }


//=================

void showData() {
    if (newData == true) {
        Serial.print("  Acknowledge data ");
        Serial.print(ackData[0]);
        Serial.print(", ");
        Serial.println(ackData[1]);
        Serial.println();
        newData = false;
    }
}

//================

void updateMessage() {
        // so you can see that new data is being sent
    txNum += 1;
    if (txNum > '9') {
        txNum = '0';
    }
    dataToSend[8] = txNum;
}

For RX:

// 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
int ackData[2] = {109, -4000}; // the two values to be sent to the master
bool newData = false;

//==============

void setup() {

    Serial.begin(9600);

    Serial.println("SimpleRxAckPayload Starting");
    radio.begin();
    radio.setDataRate( RF24_250KBPS );
    radio.openReadingPipe(1, thisSlaveAddress);

    radio.enableAckPayload();
    radio.writeAckPayload(1, &ackData, sizeof(ackData)); // pre-load data

    radio.startListening();
}

//==========

void loop() {
    getData();
    showData();
}

//============

void getData() {
    if ( radio.available() ) {
        radio.read( &dataReceived, sizeof(dataReceived) );
        updateReplyData();
        newData = true;
    }
}

//================

void showData() {
    if (newData == true) {
        Serial.print("Data received ");
        Serial.println(dataReceived);
        Serial.print(" ackPayload sent ");
        Serial.print(ackData[0]);
        Serial.print(", ");
        Serial.println(ackData[1]);
        newData = false;
    }
}

//================

void updateReplyData() {
    ackData[0] -= 1;
    ackData[1] -= 1;
    if (ackData[0] < 100) {
        ackData[0] = 109;
    }
    if (ackData[1] < -4009) {
        ackData[1] = -4000;
    }
    radio.writeAckPayload(1, &ackData, sizeof(ackData)); // load the payload for the next time
}

And here is the output on the serial monitor

That output suggests that the PTX is sending data because the PRX is updating the ackPayload. But I have no idea (other than a faulty nRF24) why the PTX is not getting the acknowledgement. The fault could be on either device - the PTX may not be able to listen or the PRX may not be able to talk.

Have you tried powering down the PTX and then powering it on again?
Have you put 10µF capacitors on both nRF24s

What happens on the PRX side when the PTX is powered down - I would expect it to stop producing output.

What happens if you swap the nRF24s so that the one that is now the PRX becomes the PTX etc? - i.e. upload the programs on the opposite Arduino.

If you now have 3 nRF24s (be careful to mark the new one so they can't get mixed up) then you need to check BOTH of the original ones with the new one.

Please do NOT change the program at all until you get this communication working.

...R

Yes I tried powering it down and also used 10uF capacitor on both the NRF24s.

What happens on the PRX side when the PTX is powered down - I would expect it to stop producing output.

Yes it does stop producing output

What happens if you swap the nRF24s so that the one that is now the PRX becomes the PTX etc?

I tried doing it too and one who is not receiving acknowledgement packets when switched to Receiver (by swapping codes) don't receive any data. I guess the third one is faulty too. sigh

If you now have 3 nRF24s (be careful to mark the new one so they can't get mixed up) then you need to check BOTH of the original ones with the new one.

Yes I checked all three of them and only one of them can transmit as well as receive, while the other two can only transmit.

Tapas08:
I tried doing it too and one who is not receiving acknowledgement packets when switched to Receiver (by swapping codes) don't receive any data. I guess the third one is faulty too. sigh

That is unfortunate. I must have had over 12 of them now with only 1 dud. And it has a complete short-circuit between Vcc and GND.

I know it costs money but I suggest you buy 3 more so you will (hopefully) have two working pairs and you can set aside one good pair for testing if you every run into another problem.

...R

Yes I guess I don't have any other option than to buy more NRF24s.
Thanks for all the help. _/_