Go Down

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

skootles

#60
Dec 19, 2012, 08:30 pm Last Edit: Dec 19, 2012, 08:32 pm by skootles Reason: 1

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.

Shrugs

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.

winner10920

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

Shrugs

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

Davste

#64
Mar 25, 2013, 11:54 pm Last Edit: Mar 25, 2013, 11:57 pm by Davste Reason: 1
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):
Code: [Select]
#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):
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] = {
 '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);

}



Go Up