interfacing NRF24L01+ with attiny84 (not sending the data)

Hello,
I have followed the instruction as below link
http://forum.arduino.cc/index.php?topic=421081
and i have installed damellis Version of the attiny board.

the connections are as follows

attiny------NRF
pin-9 (SCK)-----SCK
pin-8 (MISO)----MISO
pin-7(MOSI)-----MOSI
pin-12--------CE
pin-11---------CSN

also i have rigged up another receiver with another NRF module and arduino nano

MISO connects to pin 12 of the NANO

MOSI connects to pin 11 of the NANO

SCK connects to pin 13 of the NANO

CE connects to pin 7 of the NANO

CSN connects to pin 8 of the NANO

The code of transmitter (using NANO as transmitter) is same as above tutorial

// SimpleTx - the master or the transmitter

//#include <nRF24L01.h>
#include <RF24.h>



#define CE_PIN   7
#define CSN_PIN 6

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.begin(9600);
     Serial.println("SimpleTx Starting");
    radio.begin();
     radio.setAutoAck(1);
    radio.setDataRate( RF24_250KBPS );
    radio.setRetries(3,5); // delay, count
    radio.openWritingPipe(slaveAddress);
}

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

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

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

void send() {

    bool rslt=false;
    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.println(dataToSend);
    Serial.println(rslt);
    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;
}

and the receiver code is as follows

// SimpleRx - the slave or the receiver

//#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 9); // RX, TX
#define CE_PIN   1
#define CSN_PIN 2

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

    mySerial.begin(9600);

    mySerial.println("SimpleRx Starting");
    radio.begin();
    radio.setDataRate( RF24_250KBPS );
    radio.openReadingPipe(1, thisSlaveAddress);
    radio.startListening();
}

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

void loop() {
 // radio.printDetails();
    getData();
    showData();
}

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

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

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

both the code is compiling and is uploaded (for attiny84 I have uploaded using USBasp programmer)

the output of nano in serial monitor is

Data Sent Message 1
0
  Tx failed

and of attiny is didnt as per the code

I have used RF library by TMRh20 ver1.3.0

the data is not getting sent
I have also tried getting started example code of RF. No luck there too. Also all the modules are new. Please help me...

tinytinytx.ino (1.7 KB)

sorry my bad nano as transmitter and attiny as reciever. And also

MISO connects to pin 12 of the NANO

MOSI connects to pin 11 of the NANO

SCK connects to pin 13 of the NANO

CE connects to pin 7 of the NANO

CSN connects to pin 6 of the NANO

not 8

Which ATtiny core do you use? There are several available for the Arduino IDE and they have differences.

I suggest you start by getting communication working between the Nano and another Arduino (Uno, Nano etc) that can easily send messages to the Serial Monitor. Then transfer one end of the process to the Attiny with as few changes as possible.

Your Attiny program seems to have the SPI library commented out. What are you using as an alternative?

I have a few nRF24s working with Attiny1634s. I wrote my own SPI functions and nRF24 functions but I cannot now recall if I did so out of necessity or just because I was pig-headed. I think the SPI functions are essential - using the Univeral Serial Interface. In any case the nRF24 functions are almost identical to the functions in the TMRh20 library.

I also have some functions to send serial data on one of the I/O pins for debugging - a very crude bit-bang code.

I use the SpenceKonde Attiny core

...R

The core I used was damellis as per the instruction from
https://create.arduino.cc/projecthub/arjun/programming-attiny85-with-arduino-uno-afb829?f=1

Thank you for suggesting an new core. I'll try that. I don't think spi library supports attiny as when I compiled it with it it gave some error.(sorry I forgot what error it was) and also according to some threads and also one of the example code for attiny spi headder is not required it seems. Rf24 will work it seems so I commented it out..

It will be helpful for me if u could share that code if possible..

rao10:
It will be helpful for me if u could share that code if possible..

I need to do a little tidying up and I don't have time this evening. I will bookmark this Reply and try to remember to do it in the morning.

...R

Sure that will be a big help...

also I am running it (ATtiny) on internal 8MHz clock. Will that cause any issue with NRF?

All my Attinys run at 8MHz - no problem.

If you put all the attached files into the same folder they should compile without errors. I don't have the hardware available to check that it actually works but I think it should.

Unfortunately this little .ino program does not do very much and any of the later versions that do useful stuff have a great deal of additional code that relates to my project - model train radio control - which would make them very hard to follow.

The file R2Attiny1634Spi.h has a few functions to implement SPI on the Attiny.
The file R2nRF24R2spi.h has functions to allow you to read and write the nRF24 registers
The file Definitions.h has the nRF24 register definitions (taken from the TMRh20 library)

The file SmallSendSerial1634.h has some functions to implement very simple serial output from the Attiny for short debug messages. This is a bit-bang blocking system designed to use as little SRAM as possible. Note that the Attiny1634 has a USART so I have different code and I don't need to use the bit-bang system and it may not work. However I have used the code with other Attinys and your Attiny84 does not have a USART.

Please note that I am posting this code with NO warranty and NO "after sales" service.

Have fun - and lot's of coffee !

...R

Attiny1634nRF24Demo.ino (1.48 KB)

R2nRF24R2spi.h (3.53 KB)

R2Attiny1634Spi.h (1009 Bytes)

nRF24L01.h (3.41 KB)

SmallSendSerial1634.h (4.31 KB)

thank You so much