Challenge - 5 Problems
nRF24L01 RF Communication Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output of this nRF24L01 initialization code?
Consider the following Arduino code snippet initializing the nRF24L01 module. What will be printed on the Serial Monitor?
Arduino
#include <SPI.h> #include <nRF24L01.h> #include <RF24.h> RF24 radio(9, 10); // CE, CSN pins void setup() { Serial.begin(9600); if (!radio.begin()) { Serial.println("Radio hardware not responding!"); } else { Serial.println("Radio initialized successfully."); } } void loop() {}
Attempts:
2 left
💡 Hint
The radio.begin() returns true if the module is connected and working.
✗ Incorrect
The code initializes the radio and checks if it begins correctly. If the module is connected properly, it prints 'Radio initialized successfully.'.
❓ Predict Output
intermediate2:00remaining
What will be the output when sending data with nRF24L01?
Given the following Arduino code snippet that attempts to send a message using nRF24L01, what will be printed on the Serial Monitor?
Arduino
#include <SPI.h> #include <nRF24L01.h> #include <RF24.h> RF24 radio(9, 10); const byte address[6] = "00001"; void setup() { Serial.begin(9600); radio.begin(); radio.openWritingPipe(address); radio.stopListening(); const char text[] = "Hello"; bool report = radio.write(text, sizeof(text)); if (report) { Serial.println("Data sent successfully."); } else { Serial.println("Data send failed."); } } void loop() {}
Attempts:
2 left
💡 Hint
The radio.write() returns true if data is sent successfully.
✗ Incorrect
The code sets the radio to write mode and sends the 'Hello' string. If the transmission succeeds, it prints 'Data sent successfully.'.
🔧 Debug
advanced2:30remaining
Why does this nRF24L01 receiver code never print received data?
Examine the following Arduino receiver code using nRF24L01. It never prints any received data. What is the most likely cause?
Arduino
#include <SPI.h> #include <nRF24L01.h> #include <RF24.h> RF24 radio(9, 10); const byte address[6] = "00001"; void setup() { Serial.begin(9600); radio.begin(); radio.openReadingPipe(1, address); radio.startListening(); } void loop() { if (radio.available()) { char text[32] = {0}; radio.read(text, sizeof(text)); Serial.print("Received: "); Serial.println(text); } }
Attempts:
2 left
💡 Hint
The receiver must listen on the same address the sender writes to.
✗ Incorrect
If the receiver's reading pipe address does not match the sender's writing pipe address, no data will be received, so radio.available() remains false.
📝 Syntax
advanced1:30remaining
Which option causes a compilation error in this nRF24L01 code snippet?
Look at these four code snippets initializing the nRF24L01 radio. Which one will cause a compilation error?
Attempts:
2 left
💡 Hint
Check the RF24 constructor parameters in the library documentation.
✗ Incorrect
The RF24 constructor requires exactly two pins: CE and CSN. Providing only one pin causes a compilation error due to missing argument.
🚀 Application
expert3:00remaining
How many bytes are transmitted when sending this data with nRF24L01?
Consider this Arduino code sending an integer array via nRF24L01. How many bytes are actually sent over the air?
Arduino
#include <SPI.h> #include <nRF24L01.h> #include <RF24.h> RF24 radio(9, 10); const byte address[6] = "00001"; void setup() { Serial.begin(9600); radio.begin(); radio.openWritingPipe(address); radio.stopListening(); int data[3] = {100, 200, 300}; radio.write(&data, sizeof(data)); Serial.print("Bytes sent: "); Serial.println(sizeof(data)); } void loop() {}
Attempts:
2 left
💡 Hint
An int in Arduino Uno is 2 bytes. Multiply by array length.
✗ Incorrect
On Arduino Uno, 'int' is 2 bytes (16-bit AVR). The array has 3 elements, so sizeof(data) = 6 bytes, which are transmitted by radio.write(&data, sizeof(data)).