Greetings all,
I am trying to use an Attiny412+NRF24L01 to transmit an incrementing number to an UNO+NRF24L01, after which the UNO displays the numbers in the terminal window. A baby step toward a larger goal. But I can not get it to work.
I verified the UNO receiving side works by using an ATtiny85 + NRF24L01 as the transmitter. (The sketch I was running successfully on the ATtiny85 was a cut and paste of the failing ATtiny412 sketch shown below, but with a few pin assignment changes, and no SPI.h include. )
ATtiny412 Transmitter Sketch (does not work)
//I modified Robin2 "NRF...how-to" post
//with pin changes and no SPI.h this works perfectly on T85 and Uno
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#define CE_PIN 1
#define CSN_PIN 0 // tried 5, which did not work
int dataToSend = 0;
const byte slaveAddress[5] = {0x52,0x78,0x41,0x41,0x41};
RF24 radio(CE_PIN, CSN_PIN);
void setup() {
radio.begin();
radio.setDataRate( RF24_250KBPS );
radio.setRetries(3,5);
radio.openWritingPipe(slaveAddress);
}
void loop() {
delay(1000);
dataToSend++;
radio.write( &dataToSend, sizeof(dataToSend) );
}
UNO "receiver" sketch, which works with the ATtiny 85, but not the ATtiny412
//I modified Robin2's sketch from his "NRF... how-to" post
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
int dataReceived;
const byte thisSlaveAddress[5] = {0x52,0x78,0x41,0x41,0x41};
#define CE_PIN 9
#define CSN_PIN 10
RF24 radio(CE_PIN, CSN_PIN); // Create a Radio
void setup() {
Serial.begin(9600);
radio.begin();
radio.setDataRate( RF24_250KBPS );
radio.openReadingPipe(1, thisSlaveAddress);
radio.startListening();
pinMode(7, OUTPUT);
}
void loop() {
if ( radio.available() ) {
radio.read( &dataReceived, sizeof(dataReceived) );
Serial.println(dataReceived);
}
}
Here's how it's all hooked together.
I determined the above pin assignments using the file
.... megaTinyCore\megaavr\variants\txy2\pins_arduino.h which referred directly to the ATtiny412 and the SPI pins. AVRdude reports a success and the programming rig successfully loads blink.ino.
// ATtiny412 / ARDUINO
// _____
// VDD 1|* |20 GND
// (DAC) (AIN6) PA6 0 2| |19 4~ PA3 (AIN3)(SCK)(EXTCLK)
// (AIN7) PA7 1 3| |18 5 PA0 (nRESET/UPDI)
// (MOSI)(TXD*)(SDA) (AIN1) PA1 2 4|_____|17 3 PA2 (AIN2)(MISO)(RXD*)(SCL)
Unusual Compile Message - does this matter?
Multiple libraries were found for "nRF24L01.h"
Used: C:\Users\Dan\Documents\Arduino\libraries\NRFLite
Not used: C:\Users\Dan\Documents\Arduino\libraries\RF24
Screen-Shot of the Core/Programming Stuff
As always, your help and comments are greatly appreciated!
BTW, high praise and great appreciation to Dr. Azzy (aka S.Konde) for the tireless work on this platform. BTW_2, I highly recommend Konde's proto boards. I received them earlier in the week, and I couldn't be more pleased.
Thanks,
Dan
San Jose