Hello,
I have followed the instruction as below link
http://forum.arduino.cc/index.php?topic=421081
and i have installed damellis Version of the attiny board.
the connections are as follows
attiny------NRF
pin-9 (SCK)-----SCK
pin-8 (MISO)----MISO
pin-7(MOSI)-----MOSI
pin-12--------CE
pin-11---------CSN
also i have rigged up another receiver with another NRF module and arduino nano
MISO connects to pin 12 of the NANO
MOSI connects to pin 11 of the NANO
SCK connects to pin 13 of the NANO
CE connects to pin 7 of the NANO
CSN connects to pin 8 of the NANO
The code of transmitter (using NANO as transmitter) is same as above tutorial
// SimpleTx - the master or the transmitter
//#include <nRF24L01.h>
#include <RF24.h>
#define CE_PIN 7
#define CSN_PIN 6
const byte slaveAddress[5] = {'R','x','A','A','A'};
RF24 radio(CE_PIN, CSN_PIN); // Create a Radio
char dataToSend[10] = "Message 0";
char txNum = '0';
unsigned long currentMillis;
unsigned long prevMillis;
unsigned long txIntervalMillis = 1000; // send once per second
void setup() {
// Serial.begin(9600);
//
Serial.begin(9600);
Serial.println("SimpleTx Starting");
radio.begin();
radio.setAutoAck(1);
radio.setDataRate( RF24_250KBPS );
radio.setRetries(3,5); // delay, count
radio.openWritingPipe(slaveAddress);
}
//====================
void loop() {
\
radio.printDetails();
currentMillis = millis();
if (currentMillis - prevMillis >= txIntervalMillis) {
send();
prevMillis = millis();
}
}
//====================
void send() {
bool rslt=false;
rslt = radio.write( &dataToSend, sizeof(dataToSend) );
// Always use sizeof() as it gives the size as the number of bytes.
// For example if dataToSend was an int sizeof() would correctly return 2
Serial.print("Data Sent ");
Serial.println(dataToSend);
Serial.println(rslt);
if (rslt) {
Serial.println(" Acknowledge received");
updateMessage();
}
else {
Serial.println(" Tx failed");
}
}
//================
void updateMessage() {
// so you can see that new data is being sent
txNum += 1;
if (txNum > '9') {
txNum = '0';
}
dataToSend[8] = txNum;
}
and the receiver code is as follows
// SimpleRx - the slave or the receiver
//#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 9); // RX, TX
#define CE_PIN 1
#define CSN_PIN 2
const byte thisSlaveAddress[5] = {'R','x','A','A','A'};
RF24 radio(CE_PIN, CSN_PIN);
char dataReceived[10]; // this must match dataToSend in the TX
bool newData = false;
//===========
void setup() {
mySerial.begin(9600);
mySerial.println("SimpleRx Starting");
radio.begin();
radio.setDataRate( RF24_250KBPS );
radio.openReadingPipe(1, thisSlaveAddress);
radio.startListening();
}
//=============
void loop() {
// radio.printDetails();
getData();
showData();
}
//==============
void getData() {
if ( radio.available() ) {
radio.read( &dataReceived, sizeof(dataReceived) );
newData = true;
}
}
void showData() {
if (newData == true) {
mySerial.print("Data received ");
mySerial.println(dataReceived);
newData = false;
}
else
mySerial.println("didnt");
}
both the code is compiling and is uploaded (for attiny84 I have uploaded using USBasp programmer)
the output of nano in serial monitor is
Data Sent Message 1
0
Tx failed
and of attiny is didnt
as per the code
I have used RF library by TMRh20 ver1.3.0
the data is not getting sent
I have also tried getting started example code of RF. No luck there too. Also all the modules are new. Please help me...
tinytinytx.ino (1.7 KB)