Hey all, I'm currently working with an ATTiny84 being programmed by an Arduino Uno as isp.
I'm trying to get it to receive or send anything at all using an NRF module.
Currently trying to get the ATTiny84 to be a Receiver. The transmitter (which I've been using for a month in testing, so I know it works) is an ESP8266 with another NRF module.
The code for the ATTiny is this
//ATTiny
#include <nRF24L01.h>
#include <RF24.h>
#include <EEPROM.h>
#include <math.h>
//#include <SPI.h> //apparently rf24 calls this already
#define CE_PIN 2 //connected to physical pin 11
#define CSN_PIN 3 //connected to physical pin 10
RF24 radio(CE_PIN, CSN_PIN);
const byte generaladdress[5] = {1,'e','l','l','o'} ;
int led = 0 ;
byte datacommands[3] = {0,0,0};
byte ackData[3] = {2,0,0};
void setup() {
pinMode(led, OUTPUT);
radio.begin();
radio.setDataRate( RF24_250KBPS );
digitalWrite(led, HIGH); //Just tell that the board has turned on
delay(1000);
digitalWrite(led, LOW);
delay(1000);
radio.openReadingPipe(1, generaladdress);
radio.setPALevel(RF24_PA_MIN);
radio.setAutoAck(true);
radio.writeAckPayload(1, &ackData, sizeof(ackData));
radio.startListening();
radio.enableAckPayload();
radio.enableDynamicAck();
ackData[0] = 1;
}
void loop() {
if (radio.available()){
radio.read( &datacommands, sizeof(datacommands));
digitalWrite(led, HIGH); //to signal a message received
delay(1000);
} else {
digitalWrite(led, LOW);
delay(1000);
}
}
Also the connections for the ATTiny are this
And the code for the ESP is this
//ESP
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>3
#define CE_PIN 2
#define CSN_PIN 15
RF24 radio(CE_PIN, CSN_PIN);
const byte generaladdress[5] = {1,'e','l','l','o'} ;
byte datacommands[3] = {4,1,1};
byte ackData[3] = {-1,-1,-1};
byte i = 0;
void setup() {
Serial.begin(9600);
Serial.println("Proto test ESP starting");
delay(10);
radio.begin();
radio.setDataRate( RF24_250KBPS );
radio.openWritingPipe(generaladdress);
radio.stopListening();
radio.enableAckPayload();
radio.enableDynamicAck();
}
void loop() {
for(i=0;i<3;i++) {
radio.write( &datacommands, sizeof(datacommands));
printCommands();
if ( radio.isAckPayloadAvailable() ) {
radio.read(&ackData, sizeof(ackData));
printAck();
delay(1000);
}
delay(1000);
}
}
void printCommands() {
Serial.print("Sending: ");
Serial.print(datacommands[0]);
Serial.print(" , ");
Serial.print(datacommands[1]);
Serial.print(" , ");
Serial.print(datacommands[2]);
Serial.print(" to: ");
Serial.println();
}
void printAck() {
Serial.print("Ackrecieved: ");
Serial.print(ackData[0]);
Serial.print(" , ");
Serial.print(ackData[1]);
Serial.print(" , ");
Serial.print(ackData[2]);
Serial.println();
}
Is there perhaps something I'm doing wrong? I have been testing various libraries and tutorials but none seem to work.
Imgur doesn't seem to work for adding the picture in preview mode so I attached the connections picture below