Go Down

Topic: attiny 85, any pointers?/ (Read 39306 times) previous topic - next topic


Srry I meant to post it last post, my phone doesn't seem to want to post it right now, ill tyr again tomorrow on an actual computer


Thanks, can't wait to get this working.


srry for the delay


No problem. Could I bother you for the receiver code as well?


heres some code that recieves a message and i think replies as ewell as readoff to an lcd, but it is for an uno and doesnt use the attiny85 spi


I'm not quite sure what I'm not doing correctly. Hopefully you can help me out. My pin connections:

ATtiny84        -> Nrf24L01+
SCK   (PA4) -> SCK
CSN   (PA3) -> CSN
CE     (PA2) -> CE

The code uploads to the ATtiny84 perfectly well, and seems to be working.

When I run the uno code you provided, though, it fails to detect any data. Here are the connections:

UNO            -> Nrf24L01+
D9               -> CE
D10             -> CSN
D11 (MOSI) -> MOSI
D12 (MISO) -> MISO
D13 (SCK)   -> SCK  

And here is the stripped down code:
Code: [Select]


#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] = {

SoftwareSerial mySerial(9,10);

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

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


void loop(){

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

 digitalWrite(0, LOW);


and for the UNO:

Code: [Select]


//mirf recieve and replay
PIN ||arduino || mirf
GND ||  GND   ||  1
VCC ||  5V    ||  2
CE  ||     9  ||  3
CSN ||     10 ||  4
SCK ||     13 ||  5
MOSI||     11 ||  6
MISO||     12 ||  7
IRQ ||  NA    ||  8
#include <SPI.h>
#include <Mirf.h>
#include <nRF24L01.h>
#include <MirfHardwareSpiDriver.h>
byte data[32]; //size of payload
void setup(){
 //begin nrf24ll01
 Mirf.cePin = 9; //uno
 Mirf.csnPin = 10; //uno
 Mirf.spi = &MirfHardwareSpi;

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


   for (int i = 0; i < 32; ++i)


I'm pretty sure the chips themselves work; the RF24 library was able to get the status register of the transceivers, so it must be a problem with the ATtiny and/or Uno code

Thank you again


Dec 18, 2012, 06:33 am Last Edit: Dec 18, 2012, 06:48 pm by skootles Reason: 1
I'm also having an issue getting this working on an ATtiny84. I've had success with the ATtiny85 however. Perhaps there's an error in the library?

Edit: Oh, and of course thanks winner10920 for your code.


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
Code: [Select]

#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;

Code: [Select]

//#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;

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

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131