Hi,
The sketch didn't print out what asked, why?
also it doesn't receive at all, what can be?
Thanks
Adam
/* https://create.arduino.cc/projecthub/lightthedreams/nrf24l01-for-communication-1-way-and-2-way-80e65c
*/
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(9, 10); // CE, CSN
const byte addresses [][6] = {"00001", "00002"}; //Setting the two addresses. One for transmitting and one for receiving
int button_pin = 2;
boolean button_state = 0;
boolean button_state1 = 0;
int led_pin = 3;
char dataReceived[32]; // this must match dataToSend in the TX
int ackData[2] = {109, -4000}; // the two values to be sent to the master
bool newData = false;
const char *cmdOn = "StationCmdA1";
const char *cmdOff = "StationCmdA2";
const char *cmdBlink = "StationCmdAx";
//const char *msg = "hello";
void setup() {
Serial.begin(9600);
Serial.println("xxx_setup!");
Serial.print("File : "), Serial.println(__FILE__);
const char compile_date[] = __DATE__ " " __TIME__;
Serial.print("Compile timestamp: ");
Serial.println(compile_date);
pinMode(led_pin, OUTPUT);
Serial.begin(9600);
radio.begin(); //Starting the radio communication
radio.openWritingPipe(addresses[0]); //Setting the address at which we will send the data
radio.openReadingPipe(1, addresses[1]); //Setting the address at which we will receive the data
radio.setPALevel(RF24_PA_MIN); //You can set it as minimum or maximum depending on the distance between the transmitter and receiver.
}
void loop()
{
delay(5);
radio.startListening(); //This sets the module as receiver
if (radio.available()) //Looking for incoming data
{
// radio.read(&button_state, sizeof(button_state));
radio.read( &dataReceived, sizeof(dataReceived) );
Serial.println("dataReceived =");
Serial.println(dataReceived);
if (dataReceived == cmdOn)
{
digitalWrite(led_pin, HIGH);
}
else if (dataReceived == cmdOff)
{
digitalWrite(led_pin, LOW);
}
else
{
delay(2);
}
delay(5);
radio.stopListening(); //This sets the module as transmitter
button_state1 = digitalRead(button_pin);
radio.write(&button_state1, sizeof(button_state1)); //Sending the data
}
}