When I started playing with the nrf24L01+ radios, I got them working nicely with attiny84's, but realized soon afterward that the atmega had the power I really needed for my project. Here are some notes from my experience with the attiny and this module.

SPI and the Attiny84

I had a very difficult time getting any SPI communication on the attiny84 at first, but after reading several potss at the Bits on a board blog, I found some alternative libraries that compiled and lead me in a decent direction.

The best advice I can offer is to first get a transmit unit and receive unit talking reliably using my previous post with something bigger, like a pro micro. Transmit a float from one to the other and run a serial debugger to just watch. Once you have this working, build another transmit unit using the attiny84 and your same 'pipes' that you know worked. Any variation of this and you're just begging for frustration. Do what you know works, then build upon that.

Debugging the attiny84

Most of the challenges I came up against dealt with not really knowing what was going on once I got the attiny84 programmed. I hooked up LEDs and tried to light them up as the program progressed, but without really seeing output, it felt like a huge waste of time. Do yourself a favor - before you go any further with SPI or get frustrated with the various rf24 libraries, grab a copy o the avr-softuart library and get some debugging output. The other main issues I've seen had to do with flaky power or bad jumper wires. Don't use cheap jumper wires - solder some nice leads directly onto the rf24 while you're at this stage.

One nice little trick I learned was to get an FTDI module that can be used to supply 3.3v directly. You can use this as the power supply for your attiny unit, you can program using it, and you can quickly attach to your softuart for debugging. You end up swapping a few wires going from programming to watching the serial output, but it this is the most convenient way I've found.

Connecting the radio to the attiny84

Newbie alert - You'll notice on the pinout for the attiny84 that MOSI is listed as physical pin #7 and MISO is physical pin #8. I don't know why, but MOSI and MISO on the pinout for the attiny84 are flipped in some of the libraries.

Also you'll notice that I am noting the physical pins in this assignment table. Take a look at this pinout and you'll see that I'm telling you to connect CSN from the radio to pin #6 on the actual attiny84. Looking at the pinout, you'll see that physical pin #6 is internally called Pin 7 when you go to use this in code. When I was starting out, this whole mapping concept just blew my mind, so hopefully I can save you some time here. My pin assignments below are to physical pins and my code at the end will be using the internal pins.

nrf24L01+ Attiny84 nrf24L01+ Attiny84
VCC3.3v GNDGround
CSNPin 6 CEPin 5
MOSIPin 8 SCKPin 9
IRQNot Connected MISOPin 7

Code example

This is a very simple example that'll get a ping going back and forth. For this specific example, I'm using this SPI library and this RF24 library. jscrane of Bits on a board and gcopeland of Maniacal Bits have some of the best blog posts if you get stuck and they've done some interesting optimizations that you'll find interesting once you're past this first stage.

If you run into any problems, leave a comment below and I'll try to help!

Article posted on January 31, 2015
Top image by: Bryan Thompson

Share this post