Hello,
After three night search solution in vain, I would like if possible to have your help.
I would like with a attiny84 send information by NRF24L01 + when read switch changed state.
The script works on a UNO by adding property :
#include <spi.h>
and changing:
RF24 radio (9,10)
pinMode (2, INPUT);
Here is my code for ATtiny:
#include <Arduino.h>
#include <RF24Network.h>
#include <RF24.h>
#include <avr/sleep.h>
#include <avr/power.h>
int this_node = 03;
int other_node = 0;
volatile boolean detectchange;
String val;
RF24 radio(8,7); //attiny84
RF24Network network(radio);
int serial_putc( char c, FILE * )
{
return c;
}
void printf_begin(void)
{
fdevopen( &serial_putc, 0 );
}
void enterSleep(void)
{
set_sleep_mode(SLEEP_MODE_PWR_DOWN);
sleep_enable();
sleep_mode();
}
void check_btn(void)
{
detectchange = true;
}
void setup() {
pinMode(5, INPUT);
attachInterrupt(0, check_btn, RISING ); // attache l'interruption externe n°0 à la fonction blink
printf_begin();
radio.begin();
radio.setDataRate(RF24_250KBPS);
network.begin(95, this_node);
detectchange = false;
}
void loop() {
if (detectchange) {
char SendPayloadBtn[10] = "";
val = "5@1:1";
val.toCharArray(SendPayloadBtn, 10);
RF24NetworkHeader header(other_node, /*type*/ 'S');
network.write(header, &SendPayloadBtn, sizeof(SendPayloadBtn));
detectchange = false;
}
enterSleep();
}
et mon montage:
+-\/-+
nRF24L01 VCC, pin2 --- VCC 1|o |14 GND --- nRF24L01 GND, pin1
PB0 2| |13 AREF
PB1 3| |12 PA1
PB3 4| |11 PA2 --- nRF24L01 CE, pin3
PB2 5| |10 PA3 --- nRF24L01 CSN, pin4
PA7 6| |9 PA4 --- nRF24L01 SCK, pin5
nRF24L01 MOSI, pin7 --- PA6 7| |8 PA5 --- nRF24L01 MISO, pin6
+----+