NRF24L01+ With ATtiny85 3 Pins

38K5119

Intro: 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

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


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

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

12 Comments

For anyone having issues getting any response on the receiving end, try the following fixes which worked for me. All credit to jvamps2017 on hackster.io for coming up with this.

Everything below is his comment from the identical hackster.io project. I've just pasted it here so anyone looking for fixes can find them:

----------------
Greetings!

I was having bad time with getting this to work, like I saw a lot of
others having. This actually turned out to be simple and a great
tutorial once you get over some hurdles.

-For starters...yes, the #define CE 3, and #CSN 3 needs to be changed to Pin 2 on the

attiny85. I'm guessing it was just reference.

--- matthew --- Pretty much got it right, use 1k resistor and .1 uf capacitor in place of

the 22k and .01uf.

-I also used a 10uf capacitor bridged on the gnd/pwr. (did not get a ping without it)

This set up so far has been tested and working for most of the day
now. Also tested with steady 3.3v 1000ma regulator as well as straight
off 2xAAA.

hopefully that helps!
----------------
I was in the same boat... felt like I was banging my head against a wall for days trying to solve the issue, then found this. So glad to hear it worked for you too.
I am not 100% sure, but with this setup you loose the possibility to put the nrf24l01 int a stanby mode. you need CE to make this operation.
This is showing me error while trying to upload Code on Attiny 85 .

invalid conversion from 'byte* {aka unsigned char*}' to
'uint64_t {aka long long unsigned int}' [-fpermissive]
I have a question, pins ATtiny 5 is MOSI and 6 is MISO, in Nrf24l01 are connected upside down in MOSI and MISO. It is correct?

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?

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

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

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

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!

Thanks for sharing :)