0
0
Arduinoprogramming~20 mins

Sending data over Bluetooth in Arduino - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Bluetooth Data Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the output sent over Bluetooth?

Consider this Arduino code snippet that sends data over Bluetooth using SoftwareSerial. What data will be sent to the Bluetooth device?

Arduino
  #include <SoftwareSerial.h>
  SoftwareSerial BTSerial(10, 11); // RX, TX

  void setup() {
    BTSerial.begin(9600);
    Serial.begin(9600);
  }

  void loop() {
    int sensorValue = 123;
    BTSerial.print("Value:");
    BTSerial.println(sensorValue);
    delay(1000);
    while(true) {}
  }
AValue:123
BValue:123\r\n
C123\r\n
DValue\r\n123
Attempts:
2 left
💡 Hint

Remember that println adds a newline character after the data.

🧠 Conceptual
intermediate
1:30remaining
Which Arduino pins are commonly used for Bluetooth communication with SoftwareSerial?

When using the SoftwareSerial library to communicate with a Bluetooth module on an Arduino Uno, which pins are typically chosen for RX and TX?

APins 10 (RX) and 11 (TX)
BPins 0 (RX) and 1 (TX)
CPins A0 (RX) and A1 (TX)
DPins 13 (RX) and 12 (TX)
Attempts:
2 left
💡 Hint

Remember that pins 0 and 1 are used for USB serial communication.

🔧 Debug
advanced
2:30remaining
Why does this Bluetooth data transmission fail?

Look at this Arduino code snippet intended to send "Hello" over Bluetooth. Why does it fail to send the data?

Arduino
  #include <SoftwareSerial.h>
  SoftwareSerial BTSerial(10, 11); // RX, TX

  void setup() {
    Serial.begin(9600);
    BTSerial.begin(9600);
  }

  void loop() {
    BTSerial.write("Hello");
    delay(1000);
  }
AThe baud rate 9600 is too slow for Bluetooth communication.
BThe pins 10 and 11 are reversed for RX and TX.
CThe Serial.begin() call is missing.
DThe write() function expects a byte or byte array, not a string literal.
Attempts:
2 left
💡 Hint

Check the data type expected by write() when sending strings.

📝 Syntax
advanced
1:30remaining
Which option causes a syntax error in Bluetooth data sending?

Which of the following Arduino code snippets will cause a syntax error when trying to send data over Bluetooth?

ABTSerial.write((const uint8_t*)"Temp: 25", 8);
BBTSerial.print("Temp: "); BTSerial.println(25);
CBTSerial.print("Temp: " + 25);
DBTSerial.print(String("Temp: ") + 25);
Attempts:
2 left
💡 Hint

Check how string concatenation works in Arduino C++.

🚀 Application
expert
3:00remaining
How many bytes are sent over Bluetooth in this code?

Given this Arduino code sending data over Bluetooth, how many bytes are transmitted each time loop() runs?

Arduino
  #include <SoftwareSerial.h>
  SoftwareSerial BTSerial(10, 11); // RX, TX

  void setup() {
    BTSerial.begin(9600);
  }

  void loop() {
    BTSerial.print("A");
    BTSerial.println(123);
    delay(1000);
    while(true) {}
  }
A6 bytes
B4 bytes
C5 bytes
D3 bytes
Attempts:
2 left
💡 Hint

Count each character sent including newline characters added by println.