Written by 2bndy5 in 2020
A simple example of sending data from as many as 6 nRF24L01 transceivers to 1 receiving transceiver. This technique is trademarked by Nordic Semiconductors as "MultiCeiver".
This example was written to be used on up to 6 devices acting as TX nodes & only 1 device acting as the RX node (that's a maximum of 7 devices). Use the Serial Monitor to change each node's behavior.
23RF24 radio(CE_PIN, CSN_PIN);
31uint64_t address[6] = { 0x7878787878LL,
47 unsigned long payloadID;
65 Serial.println(F(
"radio hardware is not responding!!"));
70 Serial.println(F(
"RF24/examples/MulticeiverDemo"));
71 Serial.println(F(
"*** Enter a number between 0 and 5 (inclusive) to change"));
72 Serial.println(F(
" the identifying node number that transmits."));
81 radio.setPayloadSize(
sizeof(payload));
99 unsigned long start_timer = micros();
100 bool report = radio.write(&payload,
sizeof(payload));
101 unsigned long end_timer = micros();
106 Serial.print(F(
"Transmission of payloadID "));
107 Serial.print(payload.payloadID);
108 Serial.print(F(
" as node "));
109 Serial.print(payload.nodeID);
110 Serial.print(F(
" successful!"));
111 Serial.print(F(
" Time to transmit: "));
112 Serial.print(end_timer - start_timer);
113 Serial.println(F(
" us"));
115 Serial.println(F(
"Transmission failed or timed out"));
122 }
else if (role ==
'R') {
126 if (radio.available(&pipe)) {
127 uint8_t bytes = radio.getPayloadSize();
128 radio.read(&payload, bytes);
129 Serial.print(F(
"Received "));
131 Serial.print(F(
" bytes on pipe "));
133 Serial.print(F(
" from node "));
134 Serial.print(payload.nodeID);
135 Serial.print(F(
". PayloadID: "));
136 Serial.println(payload.payloadID);
140 if (Serial.available()) {
143 char c = Serial.read();
144 if (toupper(c) ==
'R' && role <= 53) {
148 Serial.println(F(
"*** CHANGING ROLE TO RECEIVER ***"));
149 Serial.println(F(
"--- Enter a number between 0 and 5 (inclusive) to act as"));
150 Serial.println(F(
" a unique node number that transmits to the RX node."));
153 }
else if (c >= 48 && c <= 53 && c != role) {
157 Serial.print(F(
"*** CHANGING ROLE TO NODE "));
159 Serial.println(F(
" ***"));
160 Serial.println(F(
"--- Enter a number between 0 and 5 (inclusive) to change"));
161 Serial.println(F(
" the identifying node number that transmits."));
162 Serial.println(F(
"--- PRESS 'R' to act as the RX node."));
174 for (uint8_t i = 0; i < 6; ++i)
175 radio.openReadingPipe(i, address[i]);
177 radio.startListening();
183 payload.nodeID = role;
184 payload.payloadID = 0;
187 radio.stopListening();
188 radio.openWritingPipe(address[role]);
193 radio.setRetries(((role * 3) % 12) + 3, 15);
Driver class for nRF24L01(+) 2.4GHz Wireless Transceiver.