Sunday, January 18, 2015

Using ATtiny85 With nRF24L01+ For Wireless Communication

After learning to program ATtiny85 MCUs using Arduino as ISP, next thing I wanted to try was how to use them with nRF24L01+ wireless modules. I found some libraries which facilitate it and after successfully trying it, I decided to write the steps down here.

Setting up software for Arduino IDE:

(1) Download the codes from the GitHub project I forked it into my account for my own future use which can be found in

(2) Extract the downloaded ZIP file and copy the two directories "Mirf" and "SPI85" into the libraries directory inside your sketchbook directory inside home directory.

(3) Download the "attiny" directory from the following project into the "hardware" directory of the sketchbook directory. It contains the board definitions for ATtiny85 and other ATtiny MCUs. This is a fork from the high-low-tech guys ATtiny library.

Now our software setup is ready. We are going to setup an ATtiny85 chip with an nRF24L01+ module to behave like a client program which send packets continuously into another device which is an Arduino Uno board with an nRF24L01+ module.

Setting up ATtiny85 with nRF24L01+:

(1)  Follow the steps in my previous article which can be  found in this link and
setup ATtiny85 chip together with Arduino Uno board as the ISP programmer. Plug this Arduino board into the computer.

(2) Open the Arduno IDE (I used version 1.0.5) and open the example program
"attiny85_counter_example" which is available inside  out newly copied "Mirf" directory. Program it into the ATtiny85 chip.

(3) Remove the ATtiny85 chip from the above programming setup and set it up
with another Arduino board and nRF24L01+ module as shown. Pin connectivity between nRF24L01+ module and ATtiny85 chip should go as below.

SCK -> PB2
CE -> PB4
CSN -> PB3

VCC pin of the nRF24L01 module should be provided with 3.3v while the VCC
pin of the ATtiny85 module should be provided with 5v. Both can be achieved
by connecting them with the appropriate pins in an Arduino board. Both GND
pins also should be grounded properly. 

ATtiny85 with nRF24L01+ powered by an Arduino board
This ATtiny85 MCU is now ready for communication. It can be powered up by an
Arduino board.

Setting up Arduino Uno with nRF24L01+:

(1) Plug a new Arduino Uno board with the computer.

(2) Start Arduino IDE again and open the example program "ping_server" inside "Mirf" directory. Program it into the Arduino Uno board.

(3) Connect an nRF24L01 module with this Arduino board according to the pin
connectivity details given below. 

MISO -> 12
MOSI -> 11
SCK -> 13
CE -> 8
CSN -> 7
VCC -> 3V3

This Arduino Uno board is also now ready for communication. 

Arduino Uno board connected with nRF24L01+
Running the setups:

Now, supply power to both setup, Arduino server and ATtiny85 client. Open the
serial monitor of the Arduino server side using Arduino IDE and check for any information on a baud rate of 9600. You will see that the server is receiving data from the client as the figure shown below. What happens is our ATtiny85 chip continuously send packets which are received and retransmitted by the Arduino Uno board as a reply.

Output of the serial monitor at the server side


  1. Thanks! Very helpful, thanks for taking the time to write this up!

  2. i can't seem to compile the attiny85_counter_example sketch. It give me SPI.h error. I checked that i have installed SPI.h library.