attiny 85, any pointers?/

It works well on the 85? I think I'll go ahead and get some of those, then. I assume I'll have to change the pin assignments in the library? From PORTA to PORTB, that is.

In the library I included a define for the 84, perhaps depending on your method of enabling attiny use on arduino because I based it on the third party source that I used, I believe there are 2-3 different ones, perhaps that's the fault, ill try on an 84 when I get the chance, tho I think someone else said it worked on an 84

Oh ya, I forgot to specify that I had to manually comment out the ATTiny "if defined" part in SPI85 because it wasn't recognizing the core as an AVR_ATtinyX4. That's probably the problem. So would I use a different ATTiny core or what?

Yea, somebody above got it working on an 84.

Just change the core name to whichever yours is, youll find the name within the attiny core itself, I found it I think by pin definitions, then it will automatically recognize it

Right, right. Wait, since I manually commented it out and forced the pin definitions to be for the 84, wouldn't it work already?
I changed

#if defined( __AVR_ATtinyX4__ )
const static uint8_t SS   = PA7;
const static uint8_t MOSI = PA5;
const static uint8_t MISO = PA6;
const static uint8_t SCK  = PA4;
#endif

To:

//#if defined( __AVR_ATtinyX4__ )
const static uint8_t SS   = PA7;
const static uint8_t MOSI = PA5;
const static uint8_t MISO = PA6;
const static uint8_t SCK  = PA4;
//#endif

So the pins are definitely correct, I think.

Does anything change when you force the definitions?

It stops giving me the "SS/MOSI/MISO/SCK is undefined in this context" or whatever messages and compiles perfectly. I had done that previously, so now I don't think that it's related to my problems now. Thanks for helping, by the way.

Np, let me know if u figure it out, feels good to know something I made works for other people too lol

Shrugs:
It works well on the 85? I think I'll go ahead and get some of those, then. I assume I'll have to change the pin assignments in the library? From PORTA to PORTB, that is.

Keep in mind that you'll only have one digital pin left on the ATtiny85 if you do this. That pin is actually the RESET pin, so you need to set a special fuse on the microcontroller, and afterwards you'd have to use a high voltage programmer to program it. See this thread for more details.

It's really best to just try and get it working on an ATtiny84.

I guess I'll keep working on it. I don't know enough about the SPI protocol to actually debug the thing, though.

Is this to be run on a 1mhz chip or an 8mhz?

I'm going to try running the same code on the ATTiny and change the uno code to RF24 to see if that picks up any data.

For my situation with the 85, it worked fin because all I need is cs to be a dedicated pin, the rest are multipurposed for other things, and I used it on 8mhz

Right, because with the CS HIGH, the transceiver will ignore all the other pins. Smart.

This is an old thread but I can't get this to work. I have Shrugs' scripts running, one on my ATTiny85 and one on my Arduino Mega.

Here's my Arduino Mega pin layout:
(Starting from top left pin of NRF (IRQ), where bottom right pin is GND)
Arduino Mega – nRF24L01
N/A – IRQ
50 (MISO) – MISO
51 (MOSI) – MOSI
52 (SCK) – SCK
48 – CSN
53 (SS) – CE
3.3v – VCC
GND – GND

And the NRF to the ATTiny Layout:
ATTiny – nRF24L01
1 (Reset) – N/A
2 (PB3) – CE
3 (PB4) – CSN
4 (GND) – GND – Arduino GND
5 (MOSI) – MISO
6 (MISO)- MOSI
7 (AI, SCK) -SCK
8 (VCC) – VCC – Arduino 3.3v
I have tried swapping around MOSI and MISO on both the mega and the ATTiny with no luck.
If I add an LED (+) to PB4 in parallel, and ground it properly… I see it blinking every 3 seconds. So something is happening.

The problem is that with both scripts running, the receiver doesn't seem to receive anything.
I modified the reciever pins from the scripts a bit. Here they are:

Mega (reciever):

#include <SPI.h>
#include <Mirf.h>
#include <nRF24L01.h>
#include <MirfHardwareSpiDriver.h>
byte data[32]; //size of payload
void setup(){
  Serial.begin(9600);
  //begin nrf24ll01
  Mirf.cePin = 53; //Mega
  Mirf.csnPin = 48; //Mega 
  Mirf.spi = &MirfHardwareSpi;
  Mirf.init();

  Mirf.setRADDR((byte *)"reply");
  Mirf.setTADDR((byte *)"sendr");
  Mirf.payload = 32;
  Mirf.channel = 8;
  Mirf.config();
  Serial.println("Setup finished");
}
void loop(){
   Serial.print(".");

  if(Mirf.dataReady()){
    Mirf.getData(data);


    delay(50);
    for (int i = 0; i < 32; ++i)
    {
      Serial.print(data[i]);
      Serial.print(",");
    }
    Serial.println();
  }

  delay(200);
}

ATTiny (didn't change anything):

#include <avr/io.h>
#include <inttypes.h>
#include <avr/interrupt.h>
#include <util/delay.h>
#include <SPI85.h>
#include <Mirf85.h>
#include <nRF24L0185.h>
#include <MirfHardwareSpiDriver85.h>
#include "SoftwareSerial.h"



byte data[32] = {
  'T','T','W','I','R','E','L','E','S','S','Q','Q','Q','Q','Q','Q',
  'Q','Q','R','J','F','E','D','O','R','Q','Q','Q','Q','Q','Q','Q'
}; 

SoftwareSerial mySerial(9,10);

void setup(){
  mySerial.begin(9600);
  mySerial.write("ATTINY - Setup\n");
  
  // pinMode(3,0);
  pinMode(0, OUTPUT);
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  // digitalWrite(3,1);
  delay(1000);
  
  Mirf.cePin = 2; //attiny
  Mirf.csnPin = 3; //attiny
  Mirf.spi = &MirfHardwareSpi;
  Mirf.init();

  Mirf.setRADDR((byte *)"sendr");
  Mirf.payload = 32;
  Mirf.channel = 8;
  Mirf.setTADDR((byte *)"reply");
  Mirf.send(data);
delay(3000);
mySerial.write("ATTINY - End Setup\n");

}

void loop(){

  delay(1000);
  digitalWrite(0, HIGH);
  mySerial.write("ATTINY - Sending... \n");

  Mirf.send(data);
  digitalWrite(0, LOW);
  delay(100);

}

I wouldn't use any of my scripts; I never got the thing working. I eventually bought two ATTiny85s and it works. Are you using the attiny85 library on the Mega? If so, that's what's causing the problem. Try using the RF24 library on the Mega and the attiny85 one on the 85.

OK, so I'm trying to use this script with the RF24 library on the Mega.

#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
#include "printf.h"

// Setting up mega on 48 and 49.

RF24 radio(49, 48);


const uint64_t pipe = 0x8; //Problem might be here with cross-communicating between RF24 and Mirf

void setup(void)
{
  Serial.begin(57600);
  printf_begin();

  //Start radio
  radio.begin();

  //Setting a smaller packet size:
  radio.setPayloadSize(8);

  // Open pipe for reading:
  radio.openReadingPipe(1,pipe);
  radio.startListening();

  radio.printDetails();
}

void loop(void)
{
  

    // Wait here until we get a response, or timeout (250ms)
    unsigned long started_waiting_at = millis();
    bool timeout = false;
    while ( ! radio.available() && ! timeout )
      if (millis() - started_waiting_at > 200 )
        timeout = true;

    // Describe the results
    if ( timeout )
    {
      printf("Didn't get anything...\n");
    }
    else
    {
      // Read the response:
      unsigned long response;
      radio.read( &response, sizeof(unsigned long) );

      // Spew it
      printf("Got something! %lu",response);
    }

    // Try again 1s later
    delay(1000);
}

There's a screenshot of the thing running. From the config it spews out, I think the pins are wiring is set up correctly.
What I don't know is...

If I've set the channel on the ATTiny (using Mirf) with:

Mirf.channel = 8;

WIll it work if I set it on the RF24 with:

  radio.openReadingPipe(1,0x8);

I will add the updated ATTiny code soon... it's not working at the moment.
I do have two ATTinys, but I would like to make it work from one ATTiny85 to an Arduino first preferably.

8.png

I'm really surprised by the lack of interest here. This is a great combo and people have got it working! At the cost of £10, you can have your own wireless sensors, complete with onboard processing and batteries that last for more than 2 years if done correctly. These things can fit in a very small and confined space, and reading on them, they seem to have a decent (line of sight) range and great reliability. They'll just stop sending when not in range, they won't send garbage. So, why isn't there a plethora of information on this combination? I'll post my code if I get it working, anyway.. but I'm starting to doubt it at this stage.

I've used the nRF24L01+ before and they work pretty well.

But that discussion probably needs a different thread.

Shrugs:
I wouldn't use any of my scripts; I never got the thing working. I eventually bought two ATTiny85s and it works. Are you using the attiny85 library on the Mega? If so, that's what's causing the problem. Try using the RF24 library on the Mega and the attiny85 one on the 85.

Is an nRF24L01 useful on a Tiny85? It would need all 5 I/O pins to connect it.

That's true, BUT you can either re-program the reset pin... OR you can just disable the wireless card temporarily while you obtain readings, then re-enable it and send them (with the CS pin I think)

Davste:
That's true, BUT you can either re-program the reset pin... OR you can just disable the wireless card temporarily while you obtain readings, then re-enable it and send them (with the CS pin I think)

I guess it could be made to work. Much easier to use a Tiny84 though (unless you're trying to save cents on huge quantities of devices).