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,
50 unsigned long payloadID;
68 Serial.println(F(
"radio hardware is not responding!!"));
73 Serial.println(F(
"RF24/examples/MulticeiverDemo"));
74 Serial.println(F(
"*** Enter a number between 0 and 5 (inclusive) to change"));
75 Serial.println(F(
" the identifying node number that transmits."));
84 radio.setPayloadSize(
sizeof(payload));
102 unsigned long start_timer = micros();
103 bool report = radio.write(&payload,
sizeof(payload));
104 unsigned long end_timer = micros();
109 Serial.print(F(
"Transmission of payloadID "));
110 Serial.print(payload.payloadID);
111 Serial.print(F(
" as node "));
112 Serial.print(payload.nodeID);
113 Serial.print(F(
" successful!"));
114 Serial.print(F(
" Time to transmit: "));
115 Serial.print(end_timer - start_timer);
116 Serial.println(F(
" us"));
118 Serial.println(F(
"Transmission failed or timed out"));
125 }
else if (role ==
'R') {
129 if (radio.available(&pipe)) {
130 uint8_t bytes = radio.getPayloadSize();
131 radio.read(&payload, bytes);
132 Serial.print(F(
"Received "));
134 Serial.print(F(
" bytes on pipe "));
136 Serial.print(F(
" from node "));
137 Serial.print(payload.nodeID);
138 Serial.print(F(
". PayloadID: "));
139 Serial.println(payload.payloadID);
143 if (Serial.available()) {
146 char c = Serial.read();
147 if (toupper(c) ==
'R' && role <= 53) {
151 Serial.println(F(
"*** CHANGING ROLE TO RECEIVER ***"));
152 Serial.println(F(
"--- Enter a number between 0 and 5 (inclusive) to act as"));
153 Serial.println(F(
" a unique node number that transmits to the RX node."));
156 }
else if (c >= 48 && c <= 53 && c != role) {
160 Serial.print(F(
"*** CHANGING ROLE TO NODE "));
162 Serial.println(F(
" ***"));
163 Serial.println(F(
"--- Enter a number between 0 and 5 (inclusive) to change"));
164 Serial.println(F(
" the identifying node number that transmits."));
165 Serial.println(F(
"--- PRESS 'R' to act as the RX node."));
177 for (uint8_t i = 0; i < 6; ++i)
178 radio.openReadingPipe(i, address[i]);
180 radio.startListening();
186 payload.nodeID = role;
187 payload.payloadID = 0;
190 radio.stopListening();
191 radio.openWritingPipe(address[role]);
196 radio.setRetries(((role * 3) % 12) + 3, 15);
Driver class for nRF24L01(+) 2.4GHz Wireless Transceiver.