ATTINY85 & NRF24L01 (3pins receive)

Hello,
I'm working on a light project with NRF24L01 as a receiver, and I would like to free one pin of my attiny85.
Here is my schematic :


And here is my code :

#include <SPI.h>
#include "nRF24L01.h"
#include <Adafruit_NeoPixel.h>

#define PIN_WS2812 3 
#define NUM_LEDS 8 

Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, PIN_WS2812, NEO_GRB + NEO_KHZ800);


#include "RF24.h"

RF24 radio(5, 4);
const uint64_t adresse = 0x1111111111;
const int taille = 3; // 3 octets pour RGB (rouge, vert, bleu)
byte couleur[taille] = {0, 0, 0}; // Initial : noir

void setup(void)
{
   strip.begin();
  // turn off leds 
  for (int i = 0; i < NUM_LEDS; i++) {
    strip.setPixelColor(i, strip.Color(0, 0, 0));
  }
  strip.show();
  radio.begin();
  radio.openReadingPipe(1, adresse);
  radio.startListening();
  
}

void loop(void)
{
  if (radio.available())
  {
    radio.read(couleur, taille);    // receive color LEDs WS2812 
    for (int i = 0; i < NUM_LEDS; i++) {
      strip.setPixelColor(i, strip.Color(couleur[0], couleur[1], couleur[2]));
    }
    strip.show();
  }
}

I put" RF24 radio(5, 4);" because CE is not connected and pin5 is unusable as it is the reset pin.
So, it's working well but I tried different things I saw on internet to free one pin but it doesn't work.
I tried to disconnect miso pin because I only need to receive data from NRF but it doesn't work.
Any idea ?

Thanks for your reply and have a nice weekend :slight_smile:

I think u cannot change the default spi communication pins as they are necessary. Now comes the part to mess with csn or ce pin. They are involved in setting different modes, and we would need a much better perspective of how are u using your nrf- like only to communicate, or to use both master and slave function, etc. from code it seems that u are using only the master function here. hmmmm

I just need it to be controlled so, I guess it is only slave fonction ?
I’m receiving the led informations (RGB) by another module (esp32 + nrf24L01).

Rather than trying to free up a pin, how about adding one and using the reset pin for I/O?

A while back, I found myself in a situation where I needed all 6 I/O pins on an 85 and so I built myself a high voltage ATtiny85 programmer with a Nano, a handful of resistors, an NPN transistor and one of those ubiquitous boost converters. I started with the following:

The modified ArduinoISP sketch has an additional command for manually setting the 85s fuses. Then you just use it like the normal ArduinoISP programmer to upload your sketch. Here's what the breadboarded version ended up looking like:

wait, so u are receiving here. Sorry my mistake

a source says that if u set the csn pin low (connect to gnd), the nrf starts listening as u said, ur only using your receive func here, so maybe this works?
source:Getting started with nrf module
read the point about CSN pin
I am also going to connect my nrf's csn pin to gnd and see if this works.(on the receiver board)
Maybe some luck with pin 3 of your attiny?

Yes maybe the high voltage programmer will be the solution but as I saw 3pins attiny85 is possible I'm wondering to make it work like this with the simple usb programming.
Thanks arunav, I tried but CSN to the ground doesn't work...

Ok so this is the solution :

and here is my code modified :

#include <SPI.h>
#include "nRF24L01.h"
#include <Adafruit_NeoPixel.h>

#define CE_PIN 3
#define CSN_PIN 3
#define PIN_WS2812 3 // Broche de la LED WS2812
#define NUM_LEDS 8 // Nombre de LEDs WS2812 (8 dans ce cas)

Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, PIN_WS2812, NEO_GRB + NEO_KHZ800);
//SEND - ATTINY85

#include "RF24.h"

RF24 radio(CE_PIN, CSN_PIN);
const uint64_t adresse = 0x1111111111;
const int taille = 3; // 3 octets pour RGB (rouge, vert, bleu)
byte couleur[taille] = {0, 0, 0}; // Initial : black
unsigned long payload = 0;

void setup(void)
{
   strip.begin();
  // Éteindre toutes les LEDs au démarrage
  for (int i = 0; i < NUM_LEDS; i++) {
    strip.setPixelColor(i, strip.Color(0, 0, 0));
  }
  strip.show();
  radio.begin();
  radio.setAutoAck(1); // Ensure autoACK is enabled
  radio.setRetries(15,15); // Max delay between retries & number of retries
  radio.openReadingPipe(1, adresse);
  radio.startListening();
  
}

void loop(void)
{
  if (radio.available())
  {
    radio.read(couleur, taille); // Lire la couleur depuis NRF24L01
    // Mettre à jour toutes les LEDs WS2812 avec la couleur reçue
    for (int i = 0; i < NUM_LEDS; i++) {
      strip.setPixelColor(i, strip.Color(couleur[0], couleur[1], couleur[2]));
    }
    strip.show();
  }
}

The last thing is that I write in the setup RBG to 0 but my leds are lighting full white when I power on the attiny, do you know why ?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.