I have an attiny85 microcontroller wireless transmitter to an arduino nano receiver using the wireless module nrf24l01 so this is the sketches and wiring for both
i'm using arduino Uno as ISP programmer to upload the sketch for the Attiny85 mcu
the nano (receiver) keeps disconnecting and connecting again and again... with the message (failed to connect!) in the serial monitor and there is no output for the sizeof(text)
Code:-
receiver nano
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(9,10);
const byte address[6] = "00001";
void setup() {
radio.begin();
radio.openReadingPipe(0, address);
radio.startListening();
Serial.begin(9600);
Serial.println("Started!");
}
void loop() {
if (radio.available()) {
char text[32] = "";
radio.read(&text, sizeof(text));
Serial.println(sizeof(text));
Serial.println(text);
}else{
Serial.println("Failed To Connect!!");
}
}
attiny85 transmitter code :
//Include Libraries
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
//create an RF24 object
RF24 radio(3, 4); // CE, CSN
//address through which two modules communicate.
const byte address[6] = "00001";
void setup()
{
radio.begin();
//set the address
radio.openWritingPipe(address);
//Set module as transmitter
radio.stopListening();
}
void loop()
{
//Send message to receiver
const char text[] = "Hello World";
radio.write(&text, sizeof(text));
delay(1000);
}
Wiring
Attiny85 ====>> nrf24l01
D3/PB3 =====> CE
D4/PB4 =====> CNS
D2/PB2 =====> SCK
D1/PB1 =====> MOSI
D0/PB0 =====> MISO
VCC =====> 3V BATTERY
GND =====> 3V BATTERY GND
Arduino nano ===> nrf24l01
D9 =====> CE
D10 =====> CNS
D11 =====> MOSI
D12 =====> MISO
D13 =====> SCK
VCC =====> 3V3
GND =====> GND