Hello, i think i am going insane on this one.
So, i have a nRF24L01 transmitter connected to arduino NANO like shown in the schema (not really sure about D9-13, but thats not important rn)
the problem is, that after i changed the addresses from "00001" to hex "0x7878787878LL", it stopped sending messages to other modules.
It can still receive however, without any problem.
#include <SPI.h>
#include <RF24.h>
#define CE_PIN 9
#define CSN_PIN 10
RF24 radio(CE_PIN, CSN_PIN);
const uint64_t rAddress[] = {0x7878787878LL, 0xB3B4B5B6F1LL, 0xB3B4B5B6CDLL, 0xB3B4B5B6A3LL, 0xB3B4B5B60FLL, 0xB3B4B5B605LL };
struct CommandPacket {
uint16_t killCooldown;
uint16_t sabotageCooldown;
};
struct DataPacket {
uint8_t nodeID;
uint8_t type;
uint8_t uid[10];
};
struct ResetPacket {
uint8_t type;
};
void setup() {
Serial.begin(9600);
while (!Serial);
if (!radio.begin()) {
Serial.println("NRF24 not working");
while (1);
}
radio.setPALevel(RF24_PA_MAX);
radio.setDataRate(RF24_1MBPS);
radio.setAutoAck(true);
radio.openReadingPipe(0, rAddress[0]);
radio.openReadingPipe(1, rAddress[1]);
radio.openReadingPipe(2, rAddress[2]);
radio.openReadingPipe(3, rAddress[3]);
radio.openReadingPipe(4, rAddress[4]);
radio.openReadingPipe(5, rAddress[5]);
radio.openWritingPipe(rAddress[0]);
radio.startListening();
Serial.println("MASTER ready");
}
void loop() {
byte pipeNum;
if (radio.available(&pipeNum)) {
DataPacket packet;
radio.read(&packet, sizeof(packet));
Serial.print("Datapacket recieved from pipe ");
Serial.print(pipeNum);
Serial.print(" | nodeID=");
Serial.print(packet.nodeID);
Serial.print(" | type=");
Serial.print(packet.type);
Serial.print(" | UID=");
for (int i = 0; i < 10; i++) {
if (packet.uid[i] == 0) break;
Serial.print(packet.uid[i], HEX);
Serial.print(" ");
}
Serial.println();
if (packet.type == 1) {
ResetPacket rp;
delay(1000);
rp.type = 0xA0;
radio.stopListening();
bool ok = radio.write(&rp, sizeof(rp));
Serial.print("Reset sabotage ");
Serial.println(ok ? " OK" : " FAIL");
delay(20);
radio.startListening();
}
}
if (Serial.available()) {
String cmdstr = Serial.readStringUntil('\n');
cmdstr.trim();
if (cmdstr.startsWith("SEND")) {
int killT, sabotageT;
if (sscanf(cmdstr.c_str(), "SEND %d %d", &killT, &sabotageT) == 2) {
CommandPacket cmd;
cmd.killCooldown = killT;
cmd.sabotageCooldown = sabotageT;
radio.stopListening();
delay(20);
radio.openWritingPipe(rAddress[0]);
bool ok = radio.write(&cmd, sizeof(cmd));
Serial.println(ok ? " OK" : " FAIL");
delay(20);
bool tx_ok, tx_fail, rx_ready;
radio.printDetails();
radio.whatHappened(tx_ok, tx_fail, rx_ready);
Serial.print("write() -> ");
Serial.println(ok ? "OK" : "FAIL");
Serial.print(" TX_OK: "); Serial.println(tx_ok);
Serial.print(" TX_FAIL: "); Serial.println(tx_fail);
Serial.print(" TX_LOST: "); Serial.println(rx_ready);
radio.startListening();
}
}
}
}
The outputs of radio.whatHappened() are all 0.
The other module, that transmits the messages works as intended, so the problem lies somewhere in here, but have no idea where ...
