attiny 85, any pointers?/

Watch out, by the way. I've managed to burn 3 nRF modules by swapping around the ground and VCC at 3 AM. Happened for a second or two and from then on it just wouldn't receive anything. It would return 0 or 255 randomly as status instead of working. I can confirm this as when I replaced it with a different card, it worked.

Davste:
I've managed after five days of mucking around with it :slight_smile:
Remember to try different channels. That may have been one of the problems for me.
Here's the code I'm using right now (that works):

ATTiny85:

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

const int bufferSize = 2;
byte buffer[] = {
  'D','S'
};

#define CE  PB3 //ATTiny
#define CSN PB4 //ATTiny

void setup(){
  Mirf.cePin = CE;
  Mirf.csnPin = CSN;
  Mirf.spi = &MirfHardwareSpi;
  Mirf.init();

Mirf.setRADDR((byte *)"clnt2");
  Mirf.payload = 2;
  Mirf.channel = 80;
  Mirf.setTADDR((byte *)"clnt1");
  Mirf.config();
}

void loop(){
  Mirf.send(buffer);
  while( Mirf.isSending() )
  {
    delay(1);
  }
  delay(1000);
}

I can't seem to find the below *85 header files, which libs are they from ??
#include <SPI85.h>
#include <Mirf85.h>
#include <nRF24L0185.h>
#include <MirfHardwareSpiDriver85.h>

Or could you just zip up all the attiny & headers and shared it as a dropbox links ?

Thanks

Stanley:
Or could you just zip up all the attiny & headers and shared it as a dropbox links ?

Thanks

They are on this thread, look at this post:

winner10920:
Guess my phone didn't upload it right, ill try again
i may have to get a different browser on my phone

make sure you are logged in or you won't see the file.

Great project! Tough challenges! Here are some pointers:

Cosa: The Virtual Wire Interface (VWI) See fig. 7 ATtiny85 with ultra cheap RF433 transmitter and 1-Wire Digital Thermometer. You can find the transmitter sketch at https://github.com/mikaelpatel/Cosa/blob/master/examples/VWI/CosaVWItempsensor/CosaVWItempsensor.ino and the receiver sketch at https://github.com/mikaelpatel/Cosa/blob/master/examples/VWI/CosaVWItempmonitor/CosaVWItempmonitor.ino

Your project is a great encouragement to port the Cosa NF24L01 driver to ATtiny85. First a USI/SPI driver will be needed.

Cheers!

Davste:
They are on this thread, look at this post:

Thanks Dave for the links.... still have not gotten it to work "yet"!!!

How do you debug the attiny85 ? I scope both the CSN and MOSI pins... but still nothing on the Arduino UNO side...

I finally got it working... thanks for the sample codes, spi85 and mirf85 libs..

I'm running on channel 0x50 as the scanner shows no traffic at this channel...

I made some modifications to add support for 1Mbps as the default mirf is running on 2Mbps..
*** Do the same for the mirf libraries..

[edit]
I got it working for RF24 as most of my UNO/RPi is running on RF24 here :- GitHub - stanleyseow/RF24: Arduino and Raspberry Pi driver/libraries for nRF24L01

Changes needed in the mirf / mirf85 codes :-

  1. the address is flipped when configure in mirf (no idea why???) :-
    byte TADDR[] = {0xe3, 0xf0, 0xf0, 0xf0, 0xf0}; will match RF24 :-
    const uint64_t pipes[2] = { 0x7365727631LL, 0xF0F0F0F0E3LL };

  2. Default CRC for mirf is 8bit so set the RF24 radio.setCRCLength(RF24_CRC_8) or change mirf85.h line 38 :-
    #define mirf_CONFIG ((1<<EN_CRC) | (1<<CRCO) ) // 1 << CRC0 is 16bit/2bytes

  3. Default data rate for nRF24L01/mirf is 2Mbps, so set the RF24 radio.setDataRate(RF24_2MBPS)

  4. Channels can be confusing, so use 0x50 or whatever in HEX ( 0xnn) when setting the channel for both

  5. Enable dynamic payload ( I enable them for all my RF24 receivers ) in mirf :-

// Enable dynamic payload in attiny85 mirf
Mirf.configRegister( FEATURE, 1<<EN_DPL );
Mirf.configRegister( DYNPD, 1<<DPL_P0 | 1<<DPL_P1 | 1<<DPL_P2 | 1<<DPL_P3 | 1<<DPL_P4 | 1<<DPL_P5 );

I made an 6-pin adapter on top of the attiny85 for easy uploading of hex to the attiny85 and I put an LED at Pin2 to blink 3 times during the 1 sec delays when isSending is successful..

Drawing 3.3V power from a breadboard power supply and USBtinyISP as my programmer...

attiny85

 Mirf.rfsetup = 0x06; // RF_SETUP settings :- 0x06 = 1Mbps, max power, 0x0e for 2Mbps, max power

mirf85.cpp

Nrf24l::Nrf24l(){
	cePin = 3;
	csnPin = 4;
	channel = 40;
	payload = 5;
	rfsetup = 0x06; // 1Mbps, max power
	spi = NULL;
}

void Nrf24l::config() 
// Sets the important registers in the MiRF module and powers the module
// in receiving mode
// NB: channel and payload must be set now.
{
    // Set RF channel
	configRegister(RF_CH,channel);
    // Set RF_SETUP
	configRegister(RF_SETUP,rfsetup);

    // Set length of incoming payload 
	configRegister(RX_PW_P0, payload);
	configRegister(RX_PW_P1, payload);

    // Start receiver 
    powerUpRx();
    flushRx();
}

mirf85.h

		/*
		 * Rate is RF_SETUP, 0x06 is 1Mbps, Max power
		 */

		uint8_t rfsetup;

Hi,

I've compiled all the files, headers and examples and made a github repo for future references :-

Pls let me know if you need me to add examples to the repo...

Anyone searching for attiny nrf24L01 at github should be able to find it...

Spectacular work stanley thanks for the work that you had done to collect everything in one place.

Thanks.

Stanley:
I've compiled all the files, headers and examples and made a github repo for future references :-
Pls let me know if you need me to add examples to the repo...

Thanks for sharing your success. I think a test example is always a good idea for these, so yes please. :slight_smile:

Geoff

I just got the ATTINY85 from sparkfun, I tried it with the stanley examples that put on github and it works great, at least I have the LED flashing 3 times. Now i need to make the receiver with the Arduino UNO and see what actually receive.

Some improvement, you could add the TinyDebugSerial to "see" what's going on...

I documented it in my blog for future reference...

Stanley, sadly i cant work whit TinyDebugSerial becouse i only got an arduino uno and the serial adaptor seems dont work whitout the atmega328.

I make this sketch to test if im getting something, but sadly seems not work.

[pre][left]

void setup()
{
  Serial.begin(9600);
  Mirf.spi = &MirfHardwareSpi;
  Mirf.init();
 
  byte RADDR[] = {0xe2, 0xf0, 0xf0, 0xf0, 0xf0};
  Mirf.setRADDR(RADDR);
  
  Mirf.payload = sizeof(unsigned long);
  Mirf.channel = 0x4c;
  Mirf.config();
  
  Serial.println("Listening..."); 
 
}


int data;


void loop()
{ 
   if(Mirf.dataReady())
   {Serial.print("Incoming data-....");
     
     Mirf.getData((byte *) &data);
     Serial.println(data);
     delay(100);
     
   }


data=0;

}
[/left][/pre]

Im doing it something wrong? maybe its about the dinamic payload?

here si the tx code

void setup(){
  Mirf.cePin = CE;
  Mirf.csnPin = CSN;
  Mirf.spi = &MirfHardwareSpi;
  Mirf.init();

  // This address is compatible with my example of rpi-hub or nRF24_Arduino_as_hub
  // at repo https://github.com/stanleyseow/RF24/examples/ 
  
  byte RADDR[] = {0xe2, 0xf0, 0xf0, 0xf0, 0xf0};
  byte TADDR[] = {0xe3, 0xf0, 0xf0, 0xf0, 0xf0};
 
  Mirf.payload = sizeof(buffer);
  
  Mirf.channel = 0x4c; // Same as rpi-hub and sendto_hub
  Mirf.rfsetup = 0x06; // 1Mbps, Max power
  Mirf.setRADDR(RADDR);  
  Mirf.setTADDR(TADDR);
  Mirf.config();
  
  // Enable dynamic payload 
  Mirf.configRegister( FEATURE, 1<<EN_DPL ); 
  Mirf.configRegister( DYNPD, 1<<DPL_P0 | 1<<DPL_P1 | 1<<DPL_P2 | 1<<DPL_P3 | 1<<DPL_P4 | 1<<DPL_P5 ); 
    
}

void loop(){
  
  uint8_t sent = false;
  
  Mirf.send(buffer);
  while( Mirf.isSending() )
  {
    delay(1);
    sent = true; // Sent success
  }

  delay(400);
  if (sent) {   // Blink CE ( pin 2), 3 times 
      digitalWrite(3,HIGH);  
      delay(100);
      digitalWrite(3,LOW);  
      delay(100);
      digitalWrite(3,HIGH); 
      delay(100);
      digitalWrite(3,LOW);  
      delay(100);
      digitalWrite(3,HIGH); 
      delay(100);
      digitalWrite(3,LOW);  
      delay(100);
  } else {
      digitalWrite(3,LOW);  // Sent not success, OFF the LED
      delay(600);
  }

}

Stanley, sadly i cant work whit TinyDebugSerial becouse i only got an arduino uno and the serial adaptor seems dont work whitout the atmega328.

TinyDebugSerial is for attiny "only" not atmega... if you are using atmega328, Digital pin 0 & 1 is hardware serial....

Not sure I understand yr issue, can you post yr error messages here ??

*** again, attiny can take 5V Vcc but the nRF24L01 Vcc can only take a max voltage of 3.3-3.7V

How are you setting up yr components ?
attiny - nRF <==2.4Ghz==> nRF - Arduino UNO ???

Stanley:

Stanley, sadly i cant work whit TinyDebugSerial becouse i only got an arduino uno and the serial adaptor seems dont work whitout the atmega328.

How are you setting up yr components ?
attiny - nRF <==2.4Ghz==> nRF - Arduino UNO ???

Exactly that way, what I meant is that I have an Arduino UNO to use as serial adapter. what I do is connect the pin 2 of the ATtiny, with the RX pin of the UNO without the M328 chip.

So I wanted to make a receiver to see if it really is sending something. So far, nothing

Actually it should be to pin 1 TX on Arduino.

Se SadamHu's picture here, reply #18

Thank u Erni, now its working good, i got this ouput:

RF_CH :4C
RF_SETUP :110
TX_ADDR :E3F0F0F0F0
RX_ADDR :E2F0F0F0F0
üÿSent :E3,0001,000000
üSent :E3,0001,000001
üSent :E3,0001,000002

Now i need to meke the reciever (on arduino UNO).
Any hint on how i need to proceed?

Now i need to meke the reciever (on arduino UNO).
Any hint on how i need to proceed?

This code below should compile and work without any modification... install the Rf24 libs first...

https://github.com/stanleyseow/RF24/tree/master/examples/nRF24_Arduino_as_hub

Channel : 76 = 0x4c
Rate : 1Mbps
CRC : 16bit
Dynamic Payload enable

Stanly thanks u so much for ur support, now i got it working!!!

You are welcome...

I tried to get the attiny85 to receive packets... hmmm I got nothing when I put the below codes :-

while ( Mirf.dataReady() ) {
Mirf.payload = Mirf.getDynamicPayload(); // Added this function to mirf85.cpp and mirf85.h
Mirf.getData((byte *) inBuffer);
mySerial.print("Recv :");
mySerial.println(inBuffer);
}

Anyone got the mirf85 RX working ?

I read thru the threads, it seems no one got the attiny84 working with the nRF24L01+ ...

Lately, anyone manage to get it running on the attiny84 ?

I use a Logic Analyzer to probe the SPI pins ( MISO,MOSI,SCK ) but did not get any output from it at all..