Attiny85/Arduino uno +Nrf24l01 modules

Let me preface by telling you i am a noob. Ive gotten a servo to work with a wired button, but not i want to step it up to wireless.

I have 2 Nrf24l01 modules, an Attiny85 and an arduino uno board. A wireless button to communicate is the goal, but I haven't even been able to make much progress getting 2 modules to communicate by themselves.

So far Ive programmed the Arduino to give a serial monitor message while the Nrf24l01 module is actively looking for a signal. When I try to get a signal from the Attiny85, I get nothing.

I saw the post below was hoping it would help: NRF24L01+ and ATtiny85 not working for me

The solution was to use the library/code presented by Swe-man. However, when I went to verify it in the Arduino IDE, it can't locate the API.h file, which is in the same directory as the ino file (library folder).

I extracted the file folder into the library directory. The file name is the same as the INO code. Not sure how to fix the error or how to go forward trying to get wireless communication working between 2 modules.

I cant seem to find any resources to push me any further.

Let me know if there's any additional info needed to fix this.

Thanks

Start with two Arduinos communicating over NRF24L0.

DroneBotWorkShop does a good job of explaining the NRF24L01.

Thanks for the source. I will try to follow along and hopefully get it working with 2 unos at least!

Update:

I got the 2 modules to connect with the Unos.
One thing to note for anyone that will try this in the future using this tutorial. When you go to open through the IDE (File>examples>RadioHead>nrf24>nrf24_client/nrf24_server) the files wont open. At least it wouldnt for me. Also, when you try to open them in the directory its installed in (...>examples>nrf24>nrf24_client folder) the file will open, but the code wont show up. So what I did was open the file using the Arduino Ide by going file>open...> and found the folder the nrf24_client/nrf24_server pde files were in.

When you open the files this way you can see the code and verify/upload the code. I got a popup asking if I wanted to update, and I clicked do it later. I wired up the module to the controller as per the tutorial and uploaded the code to both controllers. Now i am getting the hello messages across 2 modules on 2 seperate pcs, wirelessly! Very cool.

Now I have to figure out how to implement this to the ATTINY85, then finally add a button to the mix to send the signal.

ATtiny85 button simulation.

Thanks for this. I wish I had an led and 4.7 ohm resistor to run it though :frowning:

Could I possibly use the arduino uno on board led to test this? I have 470 ohm and 22k ohm resistors on hand right now with 2 leg buttons.

It will work. Change the pin numbers to match the mcu. The fun part is the button interrupt.

Update: I didn't end up using your code, but I did use your wiring as a reference. I will test it if I ever end up getting LEDs for other projects :wink:

However, I think i may have isolated an issue that I didnt know was present before, which is one of the arduinos I have isn't working correctly. By that I mean that I can't use it as an ISP to program the ATTINY85.
I caught this when I made a program that was supposed to keep the LED off until I pressed a button -connected to the ATTINY85. I noticed the LED was VERY dim and blinking. Once I pressed the button it went, what i am assuming is, full brightness.
I Switched it with another arduino uno and the program is working fine. I verified with another program that I can get the ATTINY to control the light on the Arduino...now its wireless time.

I'll be messing around with it this evening. I appreciate the guidance :pray:

I do not know. Sometimes power supply, breadboard, wiring and even the USB data cable causes problems with burning a bootloader. Maybe @DrAzzy is watching?

I tried to make sure to isolate for all the hardware and software.
I used the same uploading method like using the dropdown menu - sketch>upload using programmer to to upload the code. Same with burning the bootloader tools>burn bootloader.
I also used the exact hardware setup that I used on the working board. I switched everything out twice to confirm. In addition to that I changed the code when I got to the working board to verify that it was actually updating the code.

I've had an nRF24L01 working with an ATtiny85 and the RF24 library. I ran into one gotcha that had me shaking my head a little at the time, and maybe knowing it will help you out.

The MISO and MOSI labels on pin #6/PB1/DO and pin #5/PB0/DI are for when the ATtiny85 is being programmed as an SPI slave.

When you're using it as a master, as you would be to control the nRF24L01, pin #6/PB1/DO is actually MOSI, and pin #5/PB0/DI is actually MISO.

My goodness! Thank you for your input! I just got hit in the head with a rush of dopamine LOL. It sent a signal!!

Thank you for verifying that RF24 library actually worked for you! I tried the library a couple days ago but I think because I was using a sketchy Arduino uno as an ISP it didnt work before!

Some things to note for anyone trying this in the future

1.) The RF24 library will want to use the TinySPI.h file. Verify the spelling of the files in the tinySPI library. The issue I had was that the default name for this file is tinySPI.h when you install the library. To fix it, I simply changed the name of the .h and .cpp files to match "TinySPI". Duh

2.) The Attiny does NOT allow for serial messages to be sent. So you can simply send a signal and modify the receiver chip (that has serial messaging capabilities) to write a message when theres a signal sent. Duh.

3.) Verify your hardware/programmer are working correctly. Duh

4.Verify/fix the spelling of files that the code/program is trying to use. Duh

These are all basic, but I am a noob and this post could've fast tracked me to this point in the project.

Ive been shaking my head perfuously at this project dw! Depending on how difficult adding a button to the mix is, I might be shaking it some more LOL.

Off to adding a button to send the signal now!

I did #define MINIMAL in RF24_config.h for any ATtiny processors to eliminate all the code that would have tried to use Serial. But that's the only config change I made there.

Can't say as I see any reference to TinySPI.h in the RF24 library. As far as I can tell, it's just using the stock SPI library in the ATTinyCore.

If it helps, here's an early test sketch I did when I was first trying to verify that I had things hooked up properly. It assumes that the /RESET pin has been disabled and uses it as an additional output.

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

// NOTE WELL: the MISO/MOSI labels on the ATtiny85 pins are for
// when the chip is being programmed and it's an SPI slave.
//
// When being used as a master, MOSI is pin #6/PB1/DO,
// and MISO is pin #5/PB0/DI.

RF24 radio(3, 4); // CE, CSN
const byte txAddr[6] = "00001";
const byte rxAddr[6] = "00002";

bool acked;

const byte ledPin = 5;

void initRadio() {
   if( !radio.begin() ) {
      while( true ) {
         digitalWrite(ledPin, !digitalRead(ledPin));
         delay(100);
      }
   }
   radio.openWritingPipe(txAddr);
   radio.openReadingPipe(1, rxAddr);
   radio.setPALevel(RF24_PA_LOW);
   radio.stopListening();
   radio.failureDetected = false;
}

void setup() {
   static const char msg[] = "Hello world!";
   pinMode(ledPin, OUTPUT);
   for( byte i=0; i<6; ++i ) {
      digitalWrite(ledPin, !digitalRead(ledPin));
      delay(500);
   }
   digitalWrite(ledPin, LOW);
   initRadio();
   sendMsg(msg, sizeof msg);
}

void sendMsg(const char *msg, unsigned lng) {
   do {
      acked = radio.write(msg, lng);
      if( radio.failureDetected ) {
         initRadio();
      }
   } while( !acked );
}

void loop() {
   char buf[6];
   static unsigned count = 0;

   delay(2000);
   snprintf(buf, sizeof buf, "%u", count);
   sendMsg(buf, strlen(buf));
   ++count;
   digitalWrite(ledPin, !digitalRead(ledPin));
}