1
\$\begingroup\$

I have an Arduino Uno. Pins 2 and 3 are connected to pins UART_TX and UART_RX, respectively, on a bluetooth SMD module. I have the following sketch running on the Uno.

#include <NewSoftSerial.h>

NewSoftSerial bluetooth(2, 3);
byte b;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);   // opens serial port, sets data rate to 9600 bps
  Serial.flush();
  bluetooth.begin(9600);
  //enter command mode
  bluetooth.println("$$$");
  Serial.println("setup complete.");
}

void loop() {
  // if theres data from the bluetooth module
  if (bluetooth.available()) {
    //echo it to the serial monitor
    Serial.print("bt module said:");
    Serial.println((char)bluetooth.read(),BYTE);
  }
  //if theres data from the serial monitor
  if (Serial.available()>0) {
    b=Serial.read();
    //echo it back to the serial monitor
    Serial.print("serial said:");

    Serial.println(b,BYTE);
    //send it to the bluetooth module
    bluetooth.print(b,BYTE);
  }
}

I see the following on the serial monitor.

setup complete.

I expected to see

setup complete.
bt module said:C
bt module said:M
bt module said:D

Why am I not getting a response from the bluetooth module? Am I using NewSoftSerial incorrectly? Is the bluetooth module wired backwards? Are there examples communicating with a bluetooth module from an Arduino board?

\$\endgroup\$
  • \$\begingroup\$ have you tried "NewSoftSerial bluetooth(3, 2);" ? \$\endgroup\$ – vicatcu Apr 14 '11 at 3:54
  • \$\begingroup\$ @vicatcu I did try swapping them, same results, though for different reasons most likely. \$\endgroup\$ – antony.trupe Apr 14 '11 at 18:10
1
\$\begingroup\$

Did you see in the datasheet page 5 that you need some resistors on the RX line in the note "R1, R2 required if MCU logic=5V" the maximum rating on inputs to the devide is 3.4V. It's not inconceivable you fried the receiver... the Arduino is a 5V logic device.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.