Introduction: NRF24L01+ With ATtiny85 3 Pins

Picture of NRF24L01+ With ATtiny85 3 Pins

ATtiny85 is a cheap and powerful alternate when u don't need too many PWM pins. For a project just to read and transmit some sensor data ATtiny85 was enough for me. With cheaper ATtiny85 in place I was looking for cheaper ways to transmit the sensor data. Which brought me to nRF24L01+ a cheap, low power RF transceiver. This seemed to be the better solution for me. But there was one problem, limitation in number pins in ATtiny85. I can't connect both nRF24L01+ and the sensor in it. So I was looking out for solutions and came across "nrf24l01+ control with 3 ATtiny85 pins". Here I discuss how I implemented it.


Modules

There will be two modules in here transmitter and receiver. The transmitter would be a ATtiny85 sending some data and the receiver would be Arduino Uno receiving the data via nRF25L01+. I utilize the RF24 library (http://tmrh20.github.io/RF24/). Follow the instructions given there and add it to Arduino IDE before getting started with this. I won't be explaining much about RF24 as there is a very good documentation on it.

Step 1: ​Transmitter

Picture of ​Transmitter

The transmitter transmits a incrementing number every second. The ATtiny85 will send the data via nRF24L01+ using only 3 pins. The components required would be

  • ATtiny85
  • nRF24L01+
  • Ceramic Capacitor - 10nF
  • Carbon Film Resistor - 22kΩ
  • Switching Diode - 1n4148

Upload the code in sender.ino to ATtiny85. (https://www.instructables.com/id/How-to-program-the-ATtiny85-with-the-Arduino-uno-b/) Connect the components as shown in the diagram. If its not clear refer the fritzing file (nRF24L01+(With Socket) Attiny85.fzz) attached here. When power source is connected, the transmitter will start sending sequence of number every 1 second.

Note: Though rest of the nRF24L01+ 's pins are 5v tolerant you should always give 3v3 power to the Vcc or else you will damage it.

Step 2: Receiver

Picture of Receiver

The receiver receives the data sent by the transmitter and received data can be seen in the Serial Monitor.

The components required would be

Upload the code in receiver.ino to Uno. Connect the components as shown in the attached images. If the image is not clear refer the fritzing file (nRF24L01+ Arduino Uno.fzz) attached here.

Please note that Vcc should be always 3v3. In some Arduino Uno clones the 3v3 power might not have enough current which results in nRF24L01+ not working. Any one of the below methods are recommended to resolve this

  • Use a separate 3v3 power supply
  • Add a 10uF capacitor between Vcc and Gnd in the module itself
  • Use a nRF24L01+ Socket Adapter

With the transmitter and receiver ready now it time to test. Make sure the power supply to transmitter in ON. Connect the Arduino Uno to PC and open serial monitor in arduino ide. It should work as shown in the attached video.

Step 3: Making It Permanent

Picture of Making It Permanent

Here is the circuit soldered on the perf board.

This is a simpler module to demonstrate how the nRF24L01+ and how we can utilize only 3 pins of ATtiny85 to connect it so that the rest of the pins are available for reading sensor data.

Step 4: Power Consumption

nRF24L01+ draws ~900nA when powered down, and ~15mA when awake/sending. As for ATtiny85 it consumes 0.005mA at sleep state and 10mA when awake.

If you application doesn't require the ATtiny85 to be active always then you can bring ATtiny85 to sleep every now and then depending on your requirement which will save a lot of power. You can use a watchdog timer to bring ATtiny85 to sleep state.

Here is an article explaining it in detail https://learn.sparkfun.com/tutorials/h2ohno/low-power-attiny

Comments

atiyka (author)2017-02-19

Hi!

Thanks for this sharing, it's really useful :) But I have some questions:

In the sender code the CE, CS pins are defined as pin 3 (which is attiny pin 2), but in the circuit this pin is not connected. The other question is that we're connecting wires to the attiny pins: 5, 6, 7 (which are i/o pins 0, 1, 2) but in the code theese are not defined. Can you explain a bit please?

rachen (author)atiyka2017-10-12

Those pins 5,6,7 are Serial Peripheral Interface (SPI) Pins which allow transfer of data in a particular manner (which is what they call "SPI protocol") If you look closely, MOSI of NRF24l01 is connected to MOSI of ATTiny85 (pin 5), MISO to MISO (pin 6), and SCK to SCK (pin 7). So for any ATTiny85, these pins remain same (or for any microcontroller for that matter) and hence are defined inbuilt in the library files which we import them in the program. So no need to define them in the program as the program uses only those pins for transferring the data wirelessly.

The CSN (Chip Select NOT) and CE pin vary with your program and needs to be defined.

Hope this helps!!!

werlesonnery (author)atiyka2017-05-17

I tested and it worked, but I am trying to figure this out too...

chadouv (author)2017-07-23

I have tha same question with atiyka . Physical pin is not connected, why is it defined in your code.

zonkerharris (author)2017-01-16

Thank you for this instructable! I've looked at the NRF parts, and have 10(!), but haven't really used them in a project. I've thought about a multi-node temp/humidity sensor project, and I finally figurred out how to use ATtiny85 for projects (see https://www.instructables.com/id/IKEA-Star-With-ATtiny-and-NeoPixels/). I think I can use your start to get my idea going more quickly!

Swansong (author)2017-01-13

Thanks for sharing :)

About This Instructable

4,131views

23favorites

License:

Bio: 27. Web, Mobile and Desktop Developer. Hacker. Gamer. IoT Enthusiast. Electronics for Hobby and Fun.
More by arjun_g:nRF24L01+ with ATtiny85 3 PinsDIY 9V LED Torch - Quick Hacks
Add instructable to: