Communication from esp8266 to Attiny85 via NRF24L01

Hey all, wondering if I could get some help, I seem to be stuck and have no idea where to go.

I'm trying to get an Attiny to communicate with an Esp8266 with an NRF24L01 so it can be part of an iot network and have the Esp act as sort of a wifi connected hub.

I've successfully managed to get an arduino uno to send data to the Esp with the radio modules in multiple ways, that's certain the Esp works.

But when I program an Attiny to do essentially the same exact thing, it just doesn't.

The code for the Attiny here

#define CE_PIN 3
#define CSN_PIN 4

#include "RF24.h"

RF24 radio(CE_PIN, CSN_PIN);

const byte addr[6] = "00001";



void setup() {
  radio.begin();
  radio.openWritingPipe(addr);
  radio.setPALevel(RF24_PA_MIN);
  radio.stopListening();
}

void loop(void){
  const char text[] = "Hello World";
  radio.write( &text, sizeof(text) );
  delay(1000);
}

The code for the Esp is here

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(2, 15); // CE, CSN
const byte address[6] = "00001";
void setup() {
  Serial.begin(9600);
  radio.begin();
  radio.openReadingPipe(0, address);
  radio.setPALevel(RF24_PA_MIN);
  radio.startListening();
}
void loop() {
  if (radio.available()) {
    char text[32] = "";
    radio.read(&text, sizeof(text));
    Serial.println(text);
  }
}

The connections are as follows:
Attiny

NRF ATtiny
CSN -------------- 3
MOSI ------------- 6
MISO ------------- 5
SCK -------------- 7
CE --------------- 2

Esp8266 connections:

NRF ESP-12E
CSN ---------------- D8 AND 3.3k Ohm Resistor (mentioned here )
MOSI --------------- D7
MISO --------------- D6
SCK ---------------- D5
CE ------------------ D4

Also, the arduino uno code I used is this

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(7, 8); // CE, CSN
const byte address[6] = "00001";
void setup() {
  radio.begin();
  radio.openWritingPipe(address);
  radio.setPALevel(RF24_PA_MIN);
  radio.stopListening();
}
void loop() {
  const char text[] = "Hello World";
  radio.write(&text, sizeof(text));
  delay(1000);
}

I have the attiny and nrf powered by a 3.3v supply, when plugged in nothing happens, I've tried as well just getting the attiny to do a blink sketch, which works fine.

Thanks for anyone who can help or offer anything

NRF ATtiny
CSN -------------- 3
MOSI ------------- 6
MISO ------------- 5
SCK -------------- 7
CE --------------- 2

According to the datasheet the MISO is 6 and MOSI is 5.

pylon:
According to the datasheet the MISO is 6 and MOSI is 5.

That's for programming. For SPI you use the DO and DI which is what the OP has done.

...R

Dean_Bean:
But when I program an Attiny to do essentially the same exact thing, it just doesn't.

You haven't included SPI.h for the Attiny. I don't know if it works with an Attiny but if not I believe you need an equivalent.

...R

Hmmm you're right, spi isn't supported but there is a version that should work for it. Thanks I'll try that and get back to you

Robin2:
You haven't included SPI.h for the Attiny. I don't know if it works with an Attiny but if not I believe you need an equivalent.

...R

Ok well I've looked back and I've installed tinycore for the attiny which claims it has support for spi internally. There isn't a library along with it, it's a board manager with support for spi apparently. So I don't think that can be the problem

Dean_Bean:
Ok well I've looked back and I've installed tinycore for the attiny which claims it has support for spi internally. There isn't a library along with it, it's a board manager with support for spi apparently. So I don't think that can be the problem

Without a link to the documentation for tinycore and the program that you have written using it I can't make sense of your comment.

I wrote my own SPI code for my Attinys but I also wrote my own version of the nRF24 code to work with it. I'm not sure what SPI functions the proper RF24 library needs. If it is just initialize() and transfer() then they are very short pieces of code

...R

Robin2:
Without a link to the documentation for tinycore and the program that you have written using it I can't make sense of your comment.

I wrote my own SPI code for my Attinys but I also wrote my own version of the nRF24 code to work with it. I'm not sure what SPI functions the proper RF24 library needs. If it is just initialize() and transfer() then they are very short pieces of code

...R

Oh sorry you're right I didn't link to the doc. I think this is what you need GitHub - SpenceKonde/ATTinyCore: Arduino core for ATtiny 1634, 828, x313, x4, x41, x5, x61, x7 and x8

I have no clue how to write a version of the nRF24 code so I wouldn't be able to make one or change one to get it to work.

All I know is in the tinycore info (under SPI support) I found it says it simply provides full Spi functionality,
and for the attiny that I'm using (85) I think it says I need to flip the D0 and DI like I already have

Dean_Bean:
All I know is in the tinycore info (under SPI support) I found it says it simply provides full Spi functionality,

have you tried #include <SPI.h>

...R

PS.. I am using the same core for my Attinys

Robin2:
have you tried #include <SPI.h>

...R

PS.. I am using the same core for my Attinys

I hadn't used it before actually, none of the examples I saw online used it.
Just tried to compile now and got this error

In file included from C:\Users\DGDYN\Documents\Arduino\libraries\RF24/utility/ATTiny/RF24_arch_config.h:28:0,

                 from C:\Users\DGDYN\Documents\Arduino\libraries\RF24/RF24_config.h:48,

                 from C:\Users\DGDYN\Documents\Arduino\libraries\RF24/RF24.h:18,

                 from C:\Users\DGDYN\Documents\Arduino\attint_send\attint_send.ino:6:

C:\Users\DGDYN\Documents\Arduino\libraries\RF24/utility/ATTiny/spi.h:49:17: error: conflicting declaration 'SPIClass SPI'

 extern SPIClass SPI;

                 ^

In file included from C:\Users\DGDYN\Documents\Arduino\attint_send\attint_send.ino:1:0:

C:\Users\DGDYN\AppData\Local\Arduino15\packages\ATTinyCore\hardware\avr\1.2.3\libraries\SPI/SPI.h:477:16: note: previous declaration as 'tinySPI SPI'

 extern tinySPI SPI;

                ^

Multiple libraries were found for "RF24.h"
 Used: C:\Users\DGDYN\Documents\Arduino\libraries\RF24
 Not used: C:\Users\DGDYN\Documents\Arduino\libraries\RF24-master
exit status 1
Error compiling for board ATtiny25/45/85.

Dean_Bean:
Just tried to compile now and got this error

You have not posted the program that gave rise to the error !

...R

Robin2:
You have not posted the program that gave rise to the error !

...R

Oh I should have mentioned. It's the same code from the beginning for the attiny but with the spi added

#include <SPI.h>

#define CE_PIN 3
#define CSN_PIN 4

#include "RF24.h"

RF24 radio(CE_PIN, CSN_PIN);

const byte addr[6] = "00001";



void setup() {
  radio.begin();
  radio.openWritingPipe(addr);
  radio.setPALevel(RF24_PA_MIN);
  radio.stopListening();
}

void loop(void){
  const char text[] = "Hello World";
  radio.write( &text, sizeof(text) );
  delay(1000);
}

I get a similar error when I use #include <SPI.h> so maybe it is included elsewhere.

However in the code in my tutorials there are two #includes for RF24

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

Your code only has one of them.

I don't have time (or available hardware) to do any tests with your code

...R

I tried adding that to the code for the attiny in the beginning as well, still no luck.
It seems that nothing wants to work for this little module and that sucks because its a school project and I'll have to find another more expensive thing to work with.

I did more searching and found a comment you actually made a few years back. here
Apparently you got it to work with an attiny84. Would you by any chance still have the code for it? Probably too late to ask now but I'd love to try if it works on this attiny, thanks.

The code I use for the Attiny84 uses my own SPI code and my own variant of the RF24 library. However my RF24 code behaves exactly as the RF24 library. The same code works with an Attiny1634.

I can't even recall now why I decided to create my own variants and I won't post them because I don't plan to provide any follow-up support.

...R

That's understandable. I think I'll go look on another forum for help then. Or give up on these tiny modules and try something easier for my level.
Thanks

Have you read this part of the RF24 library documentation https://tmrh20.github.io/RF24/ATTiny.html

...R

Robin2:
Have you read this part of the RF24 library documentation https://tmrh20.github.io/RF24/ATTiny.html

...R

Yeah that's actually where I started with connecting the attiny, it also links to another library thing that supposedly adds support for attiny in something but I have no clue how to add it, or what to add it to.

I think that link is just where TMRh20 got some of his code.

...R

After many hours of effort I think I have tracked down the problem - but my testing is with an Attiny84 so I don't have the precise answer for your '85.

It seems that the "spi" pinouts built into the TMRh20 RF24 library do not match the numbering in the Attiny Core.

If you go into the RF24 library and open the file RF24.cpp in my copy the relevant lines start at line 1539

For my Attiny84 it shows DI as pin 4 and USCK as pin 6. I needed to swap them. I suspect you will need to do something similar for the Attiny85 - but be sure to check the numbering used by the AttiinyCore on SpenceKonde's Github page

What's really irritating is that the code acknowledges that the pinouts might be wrong but I saw no mention of it in the general documentation.

...R